Beispiel #1
0
        public static void solve()
        {
            unchecked {
                global::System.Console.WriteLine(((object)("Solving Day7")));
                global::Array <string> arr = global::haxe.lang.StringExt.split(global::solutions.Day7.input, "\r\n");
                global::solutions.Day7.bagMap = new global::haxe.ds.StringMap <string>();
                {
                    int _g = 0;
                    while ((_g < arr.length))
                    {
                        string rule = arr[_g];
                        ++_g;
                        global::Array <string> ruleSplit = global::haxe.lang.StringExt.split(rule, "contain");
                        {
                            global::haxe.IMap <string, string> this1 = global::solutions.Day7.bagMap;
                            string k = global::haxe.lang.StringExt.split(ruleSplit[0], "bags")[0].TrimEnd();
                            string v = ruleSplit[1];
                            ((global::haxe.ds.StringMap <string>)(global::haxe.ds.StringMap <object> .__hx_cast <string>(((global::haxe.ds.StringMap)(this1))))).@set(k, v);
                        }
                    }
                }

                global::System.Console.WriteLine(((object)(global::haxe.lang.Runtime.concat("a: ", global::haxe.lang.Runtime.toString(global::solutions.Day7.matchBags("shiny gold", new global::Array <string>(), 0))))));
                global::System.Console.WriteLine(((object)(global::haxe.lang.Runtime.concat("b: ", global::haxe.lang.Runtime.toString(global::solutions.Day7.countBags("shiny gold", 1))))));
            }
        }
Beispiel #2
0
        public override object __hx_setField(string field, int hash, object @value, bool handleProperties)
        {
            unchecked {
                switch (hash)
                {
                case 999785710:
                {
                    this.accessableSites = ((global::haxe.IMap <int, object>)(global::haxe.IMap__Statics_.__hx_cast <int, object>(((global::haxe.IMap)(@value)))));
                    return(@value);
                }


                case 23515:
                {
                    this.id = ((int)(global::haxe.lang.Runtime.toInt(@value)));
                    return(@value);
                }


                case 1147073522:
                {
                    this.game = ((global::game.Game)(@value));
                    return(@value);
                }


                default:
                {
                    return(base.__hx_setField(field, hash, @value, handleProperties));
                }
                }
            }
        }
Beispiel #3
0
        public override object __hx_setField(string field, int hash, object @value, bool handleProperties)
        {
            unchecked {
                                #line 31 "C:\\HaxeToolkit\\haxe\\std\\haxe\\iterators\\MapKeyValueIterator.hx"
                switch (hash)
                {
                case 1191633396:
                {
                                                #line 31 "C:\\HaxeToolkit\\haxe\\std\\haxe\\iterators\\MapKeyValueIterator.hx"
                    this.keys = ((object)(@value));
                                                #line 31 "C:\\HaxeToolkit\\haxe\\std\\haxe\\iterators\\MapKeyValueIterator.hx"
                    return(@value);
                }


                case 5442204:
                {
                                                #line 31 "C:\\HaxeToolkit\\haxe\\std\\haxe\\iterators\\MapKeyValueIterator.hx"
                    this.map = ((global::haxe.IMap)(@value));
                                                #line 31 "C:\\HaxeToolkit\\haxe\\std\\haxe\\iterators\\MapKeyValueIterator.hx"
                    return(@value);
                }


                default:
                {
                                                #line 31 "C:\\HaxeToolkit\\haxe\\std\\haxe\\iterators\\MapKeyValueIterator.hx"
                    return(base.__hx_setField(field, hash, @value, handleProperties));
                }
                }
            }
                        #line default
        }
        public override object __hx_setField(string field, int hash, object @value, bool handleProperties)
        {
            unchecked {
                                #line 31 "/opt/haxe/std/haxe/iterators/MapKeyValueIterator.hx"
                switch (hash)
                {
                case 1191633396:
                {
                                                #line 31 "/opt/haxe/std/haxe/iterators/MapKeyValueIterator.hx"
                    this.keys = ((object)(@value));
                                                #line 31 "/opt/haxe/std/haxe/iterators/MapKeyValueIterator.hx"
                    return(@value);
                }


                case 5442204:
                {
                                                #line 31 "/opt/haxe/std/haxe/iterators/MapKeyValueIterator.hx"
                    this.map = ((global::haxe.IMap <K, V>)(global::haxe.IMap__Statics_.__hx_cast <K, V>(((global::haxe.IMap)(@value)))));
                                                #line 31 "/opt/haxe/std/haxe/iterators/MapKeyValueIterator.hx"
                    return(@value);
                }


                default:
                {
                                                #line 31 "/opt/haxe/std/haxe/iterators/MapKeyValueIterator.hx"
                    return(base.__hx_setField(field, hash, @value, handleProperties));
                }
                }
            }
                        #line default
        }
Beispiel #5
0
        public override object __hx_setField(string field, int hash, object @value, bool handleProperties)
        {
            unchecked {
                switch (hash)
                {
                case 121:
                {
                    this.y = ((double)(global::haxe.lang.Runtime.toDouble(@value)));
                    return(@value);
                }


                case 120:
                {
                    this.x = ((double)(global::haxe.lang.Runtime.toDouble(@value)));
                    return(@value);
                }


                case 1477328871:
                {
                    this.rivers = ((global::haxe.IMap <int, object>)(global::haxe.IMap__Statics_.__hx_cast <int, object>(((global::haxe.IMap)(@value)))));
                    return(@value);
                }


                case 1707283357:
                {
                    this.isMine = global::haxe.lang.Runtime.toBool(@value);
                    return(@value);
                }


                case 23515:
                {
                    this.id = ((int)(global::haxe.lang.Runtime.toInt(@value)));
                    return(@value);
                }


                case 1147073522:
                {
                    this.game = ((global::game.Game)(@value));
                    return(@value);
                }


                default:
                {
                    return(base.__hx_setField(field, hash, @value, handleProperties));
                }
                }
            }
        }
Beispiel #6
0
        public static void decoderV2()
        {
            unchecked {
                string mask = "";
                {
                    int _g = 0;
                    global::Array <string> _g1 = global::solutions.Day14.arr;
                    while ((_g < _g1.length))
                    {
                        string line = _g1[_g];
                        ++_g;
                        global::Array <string> lineArr = global::haxe.lang.StringExt.split(line, "=");
                        string instruct = lineArr[0].TrimEnd();
                        if ((instruct == "mask"))
                        {
                            mask = lineArr[1].TrimStart();
                        }
                        else if ((global::haxe.lang.StringExt.substr(instruct, 0, new global::haxe.lang.Null <int>(3, true)) == "mem"))
                        {
                            string addr          = global::haxe.lang.StringExt.split(instruct, "[")[1];
                            int    parsedAddress = ((int)(((double)((global::Std.parseInt(global::haxe.lang.StringExt.substr(addr, 0, new global::haxe.lang.Null <int>((addr.Length - 1), true)))).@value))));
                            global::Array <string> writeAddresses = global::solutions.Day14.applyMaskToAddress(mask, parsedAddress);
                            {
                                int _g2 = 0;
                                while ((_g2 < writeAddresses.length))
                                {
                                    string address = writeAddresses[_g2];
                                    ++_g2;
                                    {
                                        global::haxe.IMap <string, long> this1 = global::solutions.Day14.memory;
                                        long v = ((long)((global::Std.parseInt(lineArr[1].TrimStart())).@value));
                                        ((global::haxe.ds.StringMap <long>)(global::haxe.ds.StringMap <object> .__hx_cast <long>(((global::haxe.ds.StringMap)(this1))))).@set(address, v);
                                    }
                                }
                            }
                        }
                    }
                }

                long sum = ((long)(0));
                {
                    object key = ((object)(new global::haxe.ds._StringMap.StringMapKeyIterator <long>(((global::haxe.ds.StringMap <long>)(global::haxe.ds.StringMap <object> .__hx_cast <long>(((global::haxe.ds.StringMap)(((global::haxe.IMap <string, long>)(global::solutions.Day14.memory))))))))));
                    while (global::haxe.lang.Runtime.toBool(global::haxe.lang.Runtime.callField(key, "hasNext", 407283053, null)))
                    {
                        string key1 = global::haxe.lang.Runtime.toString(global::haxe.lang.Runtime.callField(key, "next", 1224901875, null));
                        sum = (((long)(sum)) + (((global::haxe.ds.StringMap <long>)(global::haxe.ds.StringMap <object> .__hx_cast <long>(((global::haxe.ds.StringMap)(((global::haxe.IMap <string, long>)(global::solutions.Day14.memory))))))).@get(key1)).@value);
                    }
                }

                global::System.Console.WriteLine(((object)(global::haxe.lang.Runtime.concat("b: ", (global::haxe.lang.Runtime.concat("", global::Std.@string(((long)(sum)))))))));
            }
        }
Beispiel #7
0
        public virtual void setupPunters(int punterIds)
        {
            {
                int _g1 = 0;
                int _g  = punterIds;
                while ((_g1 < _g))
                {
                    int i  = _g1++;
                    int id = global::game._PunterId.PunterId_Impl_._new(i);
                    {
                        global::haxe.IMap <int, object> this1 = this.punters;
                        global::game.Punter             v     = new global::game.Punter(this, id);
                        ((global::haxe.ds.IntMap <object>)(global::haxe.ds.IntMap <object> .__hx_cast <object>(((global::haxe.ds.IntMap)(this1))))).@set(id, v);
                    }
                }
            }

            this.punterCount = punterIds;
        }
        public virtual void Add(global::shoppingcart.ItemModel item, global::haxe.lang.Function callback)
        {
                        #line 17 "/my-component/src/shoppingcart/ItemRepository.hx"
            if (!(((global::haxe.ds.StringMap <object>)(global::haxe.ds.StringMap <object> .__hx_cast <object>(((global::haxe.ds.StringMap)(((global::haxe.IMap <string, object>)(this.items))))))).exists(item.cartId)))
            {
                                #line 18 "/my-component/src/shoppingcart/ItemRepository.hx"
                global::haxe.IMap <string, object> this1 = this.items;
                                #line 18 "/my-component/src/shoppingcart/ItemRepository.hx"
                string k = item.cartId;
                                #line 18 "/my-component/src/shoppingcart/ItemRepository.hx"
                global::Array <object> v = new global::Array <object>();
                                #line 18 "/my-component/src/shoppingcart/ItemRepository.hx"
                ((global::haxe.ds.StringMap <object>)(global::haxe.ds.StringMap <object> .__hx_cast <object>(((global::haxe.ds.StringMap)(this1))))).@set(k, v);
            }

                        #line 20 "/my-component/src/shoppingcart/ItemRepository.hx"
            int idx = ((global::Array <object>)(global::Array <object> .__hx_cast <object>(((global::Array)((((global::haxe.ds.StringMap <object>)(global::haxe.ds.StringMap <object> .__hx_cast <object>(((global::haxe.ds.StringMap)(((global::haxe.IMap <string, object>)(this.items))))))).@get(item.cartId)).@value))))).length;
            item.idx = idx;
                        #line 22 "/my-component/src/shoppingcart/ItemRepository.hx"
            ((global::Array <object>)(global::Array <object> .__hx_cast <object>(((global::Array)((((global::haxe.ds.StringMap <object>)(global::haxe.ds.StringMap <object> .__hx_cast <object>(((global::haxe.ds.StringMap)(((global::haxe.IMap <string, object>)(this.items))))))).@get(item.cartId)).@value))))).push(item);
            callback.__hx_invoke1_o(((double)(idx)), global::haxe.lang.Runtime.undefined);
        }
Beispiel #9
0
 public static bool @remove(global::haxe.IMap this1, object key)
 {
                 #line 110 "C:\\HaxeToolkit\\haxe\\std\\haxe\\ds\\Map.hx"
     return(this1.@remove(key));
 }
Beispiel #10
0
 public static object arrayWrite(global::haxe.IMap this1, object k, object v)
 {
                 #line 165 "C:\\HaxeToolkit\\haxe\\std\\haxe\\ds\\Map.hx"
     this1.@set(k, v);
     return(v);
 }
Beispiel #11
0
 public static global::haxe.ds.StringMap toStringMap(global::haxe.IMap t)
 {
                 #line 170 "C:\\HaxeToolkit\\haxe\\std\\haxe\\ds\\Map.hx"
     return(new global::haxe.ds.StringMap());
 }
Beispiel #12
0
 public static string toString(global::haxe.IMap this1)
 {
                 #line 154 "C:\\HaxeToolkit\\haxe\\std\\haxe\\ds\\Map.hx"
     return(this1.toString());
 }
Beispiel #13
0
 public static void clear(global::haxe.IMap this1)
 {
                 #line 161 "C:\\HaxeToolkit\\haxe\\std\\haxe\\ds\\Map.hx"
     this1.clear();
 }
Beispiel #14
0
        public virtual void searchRivers(global::game.Game game, global::game.Site site, int punterId, int i, global::haxe.IMap <int, int> distances, global::Array <object> nextSites)
        {
            unchecked {
                object river = ((global::haxe.IMap <int, object>)(site.rivers)).iterator();
                while (global::haxe.lang.Runtime.toBool(global::haxe.lang.Runtime.callField(river, "hasNext", 407283053, null)))
                {
                    global::game.River river1 = ((global::game.River)(global::haxe.lang.Runtime.callField(river, "next", 1224901875, null)));
                    int another = (((river1.a == site.id)) ? (river1.b) : (river1.a));
                    if (!(distances.exists(another)))
                    {
                        if ((river1.owner == punterId))
                        {
                            distances.@set(another, i);
                            this.searchRivers(game, ((global::game.Site)((((global::haxe.IMap <int, object>)(game.sites)).@get(another)).@value)), punterId, i, distances, nextSites);
                        }
                        else
                        {
                            {
                                int v = (i + 1);
                                distances.@set(another, v);
                            }

                            nextSites.push(((global::game.Site)((((global::haxe.IMap <int, object>)(game.sites)).@get(another)).@value)));
                        }
                    }
                }
            }
        }
Beispiel #15
0
 public static global::haxe.IMap copy(global::haxe.IMap this1)
 {
                 #line 145 "C:\\HaxeToolkit\\haxe\\std\\haxe\\ds\\Map.hx"
     return((global::haxe.IMap)(this1.copy()));
 }
 protected static void __hx_ctor_haxe_iterators_MapKeyValueIterator <K_c, V_c>(global::haxe.iterators.MapKeyValueIterator <K_c, V_c> __hx_this, global::haxe.IMap <K_c, V_c> map)
 {
                 #line 36 "/opt/haxe/std/haxe/iterators/MapKeyValueIterator.hx"
     __hx_this.map  = map;
     __hx_this.keys = map.keys();
 }
Beispiel #17
0
        public override object __hx_setField(string field, int hash, object @value, bool handleProperties)
        {
            unchecked {
                switch (hash)
                {
                case 207998018:
                {
                    this.moves = ((global::Array <object>)(global::Array <object> .__hx_cast <object>(((global::Array)(@value)))));
                    return(@value);
                }


                case 586597902:
                {
                    this.maxScore = ((int)(global::haxe.lang.Runtime.toInt(@value)));
                    return(@value);
                }


                case 740702967:
                {
                    this.punterCount = ((int)(global::haxe.lang.Runtime.toInt(@value)));
                    return(@value);
                }


                case 1571143203:
                {
                    this.riverCount = ((int)(global::haxe.lang.Runtime.toInt(@value)));
                    return(@value);
                }


                case 1333325768:
                {
                    this.siteCount = ((int)(global::haxe.lang.Runtime.toInt(@value)));
                    return(@value);
                }


                case 1682944316:
                {
                    this.mineCount = ((int)(global::haxe.lang.Runtime.toInt(@value)));
                    return(@value);
                }


                case 1350575496:
                {
                    this.scoreDictionary = ((global::haxe.IMap <int, object>)(global::haxe.IMap__Statics_.__hx_cast <int, object>(((global::haxe.IMap)(@value)))));
                    return(@value);
                }


                case 473088699:
                {
                    this.punters = ((global::haxe.ds.IntMap <object>)(global::haxe.ds.IntMap <object> .__hx_cast <object>(((global::haxe.ds.IntMap)(@value)))));
                    return(@value);
                }


                case 1477328871:
                {
                    this.rivers = ((global::haxe.ds.IntMap <object>)(global::haxe.ds.IntMap <object> .__hx_cast <object>(((global::haxe.ds.IntMap)(@value)))));
                    return(@value);
                }


                case 141062784:
                {
                    this.mines = ((global::haxe.IMap <int, object>)(global::haxe.IMap__Statics_.__hx_cast <int, object>(((global::haxe.IMap)(@value)))));
                    return(@value);
                }


                case 2094299916:
                {
                    this.sites = ((global::haxe.IMap <int, object>)(global::haxe.IMap__Statics_.__hx_cast <int, object>(((global::haxe.IMap)(@value)))));
                    return(@value);
                }


                default:
                {
                    return(base.__hx_setField(field, hash, @value, handleProperties));
                }
                }
            }
        }
Beispiel #18
0
 public static global::haxe.ds.EnumValueMap toEnumValueMapMap(global::haxe.IMap t)
 {
                 #line 178 "C:\\HaxeToolkit\\haxe\\std\\haxe\\ds\\Map.hx"
     return(new global::haxe.ds.EnumValueMap());
 }
Beispiel #19
0
 public MapKeyValueIterator(global::haxe.IMap map)
 {
                 #line 35 "C:\\HaxeToolkit\\haxe\\std\\haxe\\iterators\\MapKeyValueIterator.hx"
     global::haxe.iterators.MapKeyValueIterator.__hx_ctor_haxe_iterators_MapKeyValueIterator(((global::haxe.iterators.MapKeyValueIterator)(this)), ((global::haxe.IMap)(map)));
 }
Beispiel #20
0
 public static bool exists(global::haxe.IMap this1, object key)
 {
                 #line 101 "C:\\HaxeToolkit\\haxe\\std\\haxe\\ds\\Map.hx"
     return(this1.exists(key));
 }
Beispiel #21
0
 public static object @get(global::haxe.IMap this1, object key)
 {
                 #line 93 "C:\\HaxeToolkit\\haxe\\std\\haxe\\ds\\Map.hx"
     return(this1.@get(key));
 }
Beispiel #22
0
 public static global::haxe.ds.ObjectMap toObjectMap(global::haxe.IMap t)
 {
                 #line 182 "C:\\HaxeToolkit\\haxe\\std\\haxe\\ds\\Map.hx"
     return(new global::haxe.ds.ObjectMap());
 }
Beispiel #23
0
 protected static void __hx_ctor_haxe_iterators_MapKeyValueIterator(global::haxe.iterators.MapKeyValueIterator __hx_this, global::haxe.IMap map)
 {
                 #line 36 "C:\\HaxeToolkit\\haxe\\std\\haxe\\iterators\\MapKeyValueIterator.hx"
     __hx_this.map  = map;
     __hx_this.keys = map.keys();
 }
Beispiel #24
0
 public static object keys(global::haxe.IMap this1)
 {
                 #line 118 "C:\\HaxeToolkit\\haxe\\std\\haxe\\ds\\Map.hx"
     return(this1.keys());
 }
Beispiel #25
0
 public static object iterator(global::haxe.IMap this1)
 {
                 #line 127 "C:\\HaxeToolkit\\haxe\\std\\haxe\\ds\\Map.hx"
     return(this1.iterator());
 }
Beispiel #26
0
 public static void @set(global::haxe.IMap this1, object key, object @value)
 {
                 #line 75 "C:\\HaxeToolkit\\haxe\\std\\haxe\\ds\\Map.hx"
     this1.@set(key, @value);
 }
 public MapKeyValueIterator(global::haxe.IMap <K, V> map)
 {
                 #line 35 "/opt/haxe/std/haxe/iterators/MapKeyValueIterator.hx"
     global::haxe.iterators.MapKeyValueIterator <object, object> .__hx_ctor_haxe_iterators_MapKeyValueIterator <K, V>(((global::haxe.iterators.MapKeyValueIterator <K, V>)(this)), ((global::haxe.IMap <K, V>)(map)));
 }
Beispiel #28
0
 public static object keyValueIterator(global::haxe.IMap this1)
 {
                 #line 136 "C:\\HaxeToolkit\\haxe\\std\\haxe\\ds\\Map.hx"
     return(this1.keyValueIterator());
 }
Beispiel #29
0
 public static object __hx_cast <K_c_c, V_c_c>(global::haxe.IMap me)
 {
     return(((me != null)) ? (me.haxe_IMap_cast <K_c_c, V_c_c>()) : default(object));
 }
 public static global::haxe.ds.StringMap <V> toStringMap <K, V>(global::haxe.IMap <K, V> t)
 {
                 #line 170 "/opt/haxe/std/haxe/ds/Map.hx"
     return(new global::haxe.ds.StringMap <V>());
 }