public void Part2Test(string input, Item[] expectedOutput) { var baseItem = TowerParser.Parse(input)[0]; Assert.That(baseItem.Balanced, Is.False); Assert.That(baseItem.Children.Count(_ => _.Balanced), Is.EqualTo(3)); var foundWeights = baseItem.Children.GroupBy(_ => _.CombinedWeight).OrderBy(_ => _.Key); Assert.That(foundWeights.Count(), Is.EqualTo(2)); }
public void Part1Test(string input, Item[] expectedOutput) { Assert.That(TowerParser.Parse(input), Is.EquivalentTo(expectedOutput).Using <Item>(new ItemComparer())); }
static void Main(string[] args) { string inputString = @"uglvj (99) -> ymfjt, gkpgf vvwrg (51) qrpgt (5) qhqbqj (55) taxdaf (23) zbbdyc (81) xhymdo (185) -> errip, lsppdni, mxukll qlrcubm (81) ukgzz (7) ubvvr (288) -> hrpzu, msjeeks, ozizlok zfotzg (45) -> ovomgd, mqhwlq khdgj (49) idjugav (99) heuuqx (77) yierd (96) -> ubnxkza, whlsvf, pnnpym, tznsg yciccp (173) -> ijpsv, fjtafl, lxwntcm, saacvs jcekn (38) boxtod (126) -> sxtbzfe, etdah iunue (25) iceaj (216) -> zbqgiy, taxdaf vobnuq (64) grkyj (7) etgjaum (61) erjcx (47) sqcodst (19) vimzk (67) gldkli (29) yikzq (164) -> yhrnh, yipnm aqksi (155) -> olotqeb, vioyx wkjhmcd (33) awsdwry (14) dgehtvc (191) -> sxwcr, usfkacz ohprzku (5) aztstf (32) grrbzan (61) spcyi (23) olntlo (299) qczgjc (26) svdlp (11) ormhqr (83) wfnox (15) hqwdr (19) cwoyko (138) -> uycwnb, pttvms, ingae, tedoj dgeseao (64) iejyzgu (97) -> lgnfrti, lomvf eqxumuo (44) vqpkne (11) gmpoe (164) -> gpxhd, deylq yhxkh (185) -> vyabn, xtwaov ugeudg (68) -> dxffsoq, nyzvofv, tvrosaa, nmojt wfuoll (1715) -> cciwzc, qpafkjx, axlitg xmbafj (44) xvpopw (58) -> wkhzk, zlnks tcawlkc (38) nddekdg (57) jtejd (16) -> fzklxq, jrbqu, qhxns, lerqv vyybi (86) arhlwh (90) ffizjl (84) -> szeszcp, wgmvio bmwankt (71) -> tdmok, ygkwtl, sgose, uohurz viantn (67) qnqwt (14) pcpcm (36) orpzr (57) ttfdct (37) xjsyk (217) -> zhjzpaa, qylvdk wiqpx (75) pfyexc (252) -> zzqjykw, alflnz rhifo (66) lerqv (68) pohqjzd (103) -> qltdz, ppzlmxg scqhs (61) vcgyi (391) whlsvf (40) edyfj (85) jpvyg (82) -> lhbmgxc, qtxkvx, kynyas, easamud jjwadjm (32) lomvf (40) snxgfl (148) -> ypufgmt, qvtwlq gqxhfjz (85) vzpkp (24) ddkhuyg (57) -> alywuv, nvdoenr, mnyng, rhsztrd iouamne (10) tnkptkm (45) xxqwea (82) comyzns (69) -> fcmnfq, nrzhlvo liwwgd (12) nfbcs (185) -> vzpkp, wmfydk kmoov (7) yoabvhm (78) tiwxhoa (107) -> wfnox, bwdijxn tedjgv (5) pqeph (56) slqmpe (35) wbntjyi (81) pgmnqws (11) indhpfx (163) -> umlbvg, fjdki, ctjygk cokjdc (54) bzapqu (76) etevb (52) dlluqgz (89) -> asdbbxb, vfetz cxqdrz (17) mynuy (249) lgtpuqr (102) -> cdooel, eozsgq, dfsas, ldbwwt iqcjr (27) ythoww (176) -> alqkr, qicxdmg ykshd (464) -> qufymlj, simlhnw, kjljvr bqzfjn (609) -> txywrwk, tpvcmkz, fklkig, katovn, jgckfb, vwqquk kywxkgm (96) vzpwamg (84) mgqfs (10) zdljb (193) -> wviisf, zhavocr sqdhc (79) -> cwoyko, pfyexc, mdyhk, zscqv, eqpuq, zspohe zznkz (51) -> vyybi, sblacv elvsrz (38) xvgcls (73) eylfls (71) qrjor (13) gqmls (40973) -> fqvvrgx, szmnwnx, jfdck oprsej (181) -> rpijkf, wtosgg ejkxeg (29) mqccum (47) zhjzpaa (20) wsqlsgl (94) zdncj (15) xttsj (29) zjzkwxq (92) hlsoglk (6) srbczq (70) rvzjawx (54) rkgvdhv (83) pnnpym (40) atzcjm (75) optohy (43) jsuevqz (5) xdraxfj (16) hlkvwq (216) -> wiqpx, bhxtgro wgapb (7) fyrauka (35) kzeubgd (270) -> wwritm, wrcpxdx, kxouhtb hughxts (215) -> asxiywb, dzwnzm kvvjhrt (155) -> zsajqjv, nvcmjx, qczgjc goaazlt (8) errrzm (249) kuhyqad (66) gwohx (93) kocwei (16) yftqma (91) -> fewgbm, cukwe katovn (559) -> ffizjl, ondvq, nbbctar, aonrg rrrxeic (240) -> gwwxkxx, aeljb vuldvce (107) -> mdoyb, hukfj uwaxli (79) -> ortan, hlglt, oivlxe, eilfrxc zsnenc (33) pjzyj (48) fewgbm (80) igiqnkc (242) -> idjugav, cwkqb xvteib (12) ykhrxqf (54) fjtafl (12) syrnxgz (152) -> flzcf, rblzgyw, yzkzx ztxam (5) qzoas (13) iolil (49) fqisabu (50) dismcam (76) phwddnu (84) nmojt (58) txmdxj (94) omkgoai (71) dyamtle (33) kqawctp (93) klkodi (93) -> edyfj, wtsesxe bpzwq (56) ldwogg (76) enswibe (379) -> hlsoglk, nkpzu nmfsbu (24) lybjgk (82) cjxuj (30) -> gtjgxiw, wxksnf bzbyqoq (39) deylq (83) owprin (97) -> komav, zzdvozt, eordj rblzgyw (22) bymyuke (511) -> dadlbnn, htwkr, dlluqgz szsfe (45) tedoj (47) arjsnz (70) -> rwrusdg, krgdzw, olhbx fkagf (88) imuupp (7) ghebwaz (15) -> xxqwea, lybjgk obbei (215) -> jsuevqz, hxsuo pnctz (5) cxgxbo (44) ivqduu (15) qzuirrb (55) rdihhfv (408) -> ozjka, mskbq, qrpis, dqury hhivpic (78) emdnkj (81) hhdth (356) -> ylixmj, ukgzz jovgiy (96) cvkec (71) sgaefd (93) bkomu (19) effjvcu (89) ayvcc (43) ocmuu (109) -> pbjuhpo, ovlbvyj sxbee (32) -> fplzsya, yftqma, hweub, yhxkh, xhymdo, cafxx llbsax (97) ylfgaps (217) -> tzbreu, izxgcf qhxns (68) ymheeao (52) qzzhap (127) -> uhyboog, nzlhfa mskbq (191) -> hqwdr, askqu fhlbjvx (73) wcwqeyz (17) crlgf (203) -> cxqdrz, kjtdypr ngvqne (83) jjeci (43) lurly (16) klzgol (52) ctjygk (43) sjyso (72) -> usbjn, puuwu wustjt (7451) -> quinb, sqdhc, kcekden rlsnxvu (628) -> xdkin, wnvmb, tfrjlk wnmbn (13) -> egoezf, nodgjd, vrrmn, uicpy hqmxuv (23) rnhom (20) ifmgil (81) nmmxms (68) bryrofn (35) fixbeu (46) ebfzjux (53) nnoaqvv (433) -> isixko, frklhh, ugeudg nyzvofv (58) czgov (32) gpkltyi (95) ortan (34) ylmixxx (17) -> ewycyf, iddby uaxhb (91) pqjrycz (117) -> urjsyac, olwudc, ezntvw, gpktinr igrih (240) -> cdahg, vqpkne ifajhb (36753) -> thuzqqo, fwlspf, mhfci, bbeclr, arjsnz hipirzc (989) -> vpmtex, hhzjn, oilsjpr, mpxfrig, geibkdq, xzjdfbr mqgculh (73) -> yvchtk, zmiee msjeeks (333) -> tqclz, fjayhh nkpzu (6) jgckfb (568) -> bcjpkwf, ungcoot, mzhyo, iwcpvdx, dvuug cwkqb (99) zanpviw (57) qkzklgx (37) wdycxsw (246) -> gzokm, yqpxoki sskog (64) ucqru (52) ipruxk (39) bbvrbl (45) idgmre (15) tcclaa (221) -> wdblza, vfdnvk xybhge (66) sgose (32) tzcymqj (28) jzjxhyw (153) -> krovuvc, brolhd ixlern (201) -> llzodgr, hwdtq ahuboc (173) -> jkszke, lpxleg xnxcez (94) kynyas (71) ylixmj (7) jnojpf (54) qicxdmg (29) xwmjpb (96) -> eqxumuo, xmbafj gqzczp (27) -> bzapqu, dismcam zwxjsev (33) ypvews (69) cdooel (34) zwaky (53) -> dqcxe, ojyssxz ovomgd (8) fzklxq (68) vjvjnc (988) -> hoyipx, qoxsu, comyzns efehrqd (11) ghqvymr (12) kcvhi (39) hrpzu (179) -> rlhqosc, bryevj zknbqr (35) dcibpv (30) kndpli (186) -> gegrzz, vandhv iiurfqv (62) ovvmrux (304) -> ulvoyev, lgkrhh errip (22) zjxspcp (1244) -> tiwxhoa, pqjrycz, sdstw gwwxkxx (11) yziwzua (70) cczfm (749) -> pnghx, tusimd, putdqt, sbcyifk, uxblgk alywuv (81) -> mlhga, odzzie, awddb, koxzwq, cczfm, hipirzc, qqktjg corqny (57) -> crlgf, xkfuz, gzoyqay, cakpt cqdkb (99) atkstsn (57) -> kntyjf, hwcwcn jfdck (65) -> marnqj, moxiw, sxijke, ojgdow, fnlapoh afjqx (115) -> unokgle, bwsvr mdoyb (57) upair (102) -> xfxqbqv, svdlp, hqget sdstw (73) -> czgov, tgrtt vlcrx (61) ymrfvp (203) -> veplkeo, iouamne vtlxs (92) wxakaqf (253) -> xnpbhpt, liwwgd qigsvd (218) -> gmpoe, ymqmr, wdycxsw, ixszebq joyncgz (73) saxamw (30) vyabn (33) fafvyk (62) -> egjsilp, usodp uigot (69) myhfh (9816) -> howpl, upvrm, xjsyk kfohhmp (81) rirch (72) bzjze (94) -> wsjuynd, aicwnq, fixbeu hzrphej (74) ozjka (229) ppkxgj (62) zgmrmd (167) -> sebtdcx, nmfsbu mtgsssx (96) ruxqapz (66) -> xhhtjwu, xhirm cwrllq (91) cpwxm (22) lsxnn (232) lijnzj (5) eozsgq (34) uohurz (32) rklnuv (41) tgrtt (32) umyqf (89) txywrwk (787) -> lbflpug, indhpfx, sxcxmg ttbtij (22) uohmo (432) -> zznkz, ustkg, stflbsr, qzeljtb qowagej (82) ingae (47) lpxleg (32) moxiw (184) -> cqtkhqi, pohqjzd, oagvuu, nfbcs, hughxts, kvvjhrt, qzzhap puuwu (47) oywnenv (245) -> fhlbjvx, joyncgz deiso (34) pnghx (158) -> wktjf, umyqf nuyake (5) sxtbzfe (68) elhjwu (54) mbsaywb (38) hcetpw (99) idcgo (52) uosltv (86) -> wxmxkzn, xvgcls cqtkhqi (233) wkhzk (88) qdxvydf (70) alicosg (52) hwcwcn (94) cxqgvb (41) nthusc (80) elxydx (145) -> orpzr, nddekdg chpjfv (83) -> psyino, hivoik, qhqbqj, qzuirrb wmfydk (24) uusufw (74) tzbreu (41) abmlupq (49) -> fcpejj, qgiijpu, iolil, khdgj qfitmrm (23) -> tmgoed, gkhrgd, zjzkwxq, bjcthpx ygkwtl (32) qclhx (79) hgyelhc (7) riogbaf (5) uhyboog (53) qoxsu (189) -> qzoas, jedlbro iakgro (52) koxzwq (1633) -> geuopn, ransdtt, bmwankt, qmdbgke fwkxcq (89) sqauq (218) -> paquh, goaazlt walei (418) -> wipafb, rzpxffj mflvlww (51) yzvvyb (144) -> eyiiwv, awaoi uspzk (173) -> idcgo, etevb kbtfnu (34) mpuhqjm (78) krbsvt (17) xdkin (59) -> gkzbah, cxgxbo, jdvbztj, mviyuy rtngius (83) -> boxtod, wpwlg, igrih, tgxuhxp, iceaj, kqecnz vpemk (5) wtosgg (59) dgoocsw (99) -> ifajhb, gqmls, sgmbw, ddkhuyg, rhqocy paquh (8) zsajqjv (26) vuknf (55) zzdvozt (45) rgonoq (33) vlglq (98) wsrmfr (6) -> optohy, tcxwrcv, wbckbcz vpmtex (240) wnvmb (79) -> hhivpic, pikqy unllgjg (38) -> dgeseao, vobnuq smbaw (89) bpgbauh (48) isixko (284) -> kkuzi, ssdpo mgghj (61) anraget (52) kqecnz (262) uqgco (161) -> uwuouhv, ocmuu, uvogit, mvwcdq, errrzm, mynuy gpktinr (5) xmhil (37) -> wloqry, gzrmt, gmktbew howpl (191) -> qlkhbf, rnqtg pozhxfb (81) twpxg (20) ransdtt (135) -> suriq, vqbaw olotqeb (52) szmnwnx (3808) -> mgayiu, nnoaqvv, kupsxf, rlsnxvu gvtnin (171) -> awgucd, krqff, ipruxk yquhjrb (59) xcrmvq (57) uhuieb (27) yqkwau (99) kkszxy (9) fvtmh (118) -> neltlwg, irzscv nzlhfa (53) aqfjqh (47) uqraz (93) alqkr (29) mnyng (12185) -> plvjk, vjvjnc, clxlfgu qbvurh (86) emsacsk (161) -> jcekn, tcawlkc mlhga (83) -> qfitmrm, enswibe, tefmun, qshflsm, vcgyi, oywnenv rmvdiwr (15) zlnks (88) zmiee (35) bmswiwx (37) dapjjl (26) -> pbxzzdi, elxydx, ghlkk, rnjqmh, dgehtvc, aqksi jfhqmi (61) fiehsiq (71) zbqgiy (23) ssdpo (8) mdyhk (326) tefmun (391) rzned (54) uhalup (15) nodgjd (195) -> feygolx, mtgsssx plevjup (190) -> kmcjs, vtwtgf nqkpd (7) srhcew (39) fjdvux (95) fqvvrgx (8363) -> xmhil, dbzwyez, bmhlcgg askqu (19) jlsxjq (162) -> zanpviw, xcrmvq kbjpgv (71) -> atzcjm, vldxx kntyjf (94) awddb (1643) -> npsuo, rrrxeic, fhyfd aonrg (52) -> fyqlzxt, ehhlvc, bpzwq, qeoicwx nconokw (45) qsgkmc (28) qxubki (10) nepmits (19) krzuab (135) -> jtxsofx, xrockzz hwvnv (83) gmktbew (74) wdblza (21) ijpsv (12) ainqphn (45) zwwrwfy (9536) -> fquyicp, sbxkokp, corqny, kzeubgd yjlzpv (198) -> jshaf, vzpwamg vqbaw (32) xnpbhpt (12) zlmvme (234) fhyfd (154) -> tevxh, cpphf easamud (71) mgayiu (93) -> ksvdw, euueza, txfnjo, bhtwp, pvnjsr tgqnyb (8591) -> rtngius, uqgco, zjxspcp ixszebq (140) -> atfgzcb, fjdvux ymjxuy (67) veplkeo (10) whgqhb (91) -> nqehtaf, wnshgr, wfuoll, cmnjg, olqgu jlryq (54) nyaqnau (79) uwuouhv (215) -> pwguzgm, krbsvt ogpunov (34) -> eqsrff, uwaxli, tszcogp, zgmrmd, wugret, zdljb efajqe (70) obvvk (29) tfpjxcv (52) gtjgxiw (80) egoezf (373) -> kmoov, hgyelhc sxwcr (34) geibkdq (148) -> oaqtjz, nwcbnxq yirmii (27) ifdeve (25) ouxdvp (202) -> gbrqt, edncj isbppt (92) -> rkgvdhv, hwvnv bajtat (252) -> wsqlsgl, ykohs aofkt (84) zbgjuk (84) ondvq (122) -> wthxapy, vqghnm fzerj (83) -> feuirvn, rklic, vxbzw, rzvrn etdah (68) jjwpqn (20) xykcof (1152) -> ptmqqpk, zfotzg, jfhqmi, kivlu, vvkgsba dlzlo (75) -> viantn, ymjxuy, vimzk sdiyd (25) krgdzw (70) -> oxvcp, sdllj, jtejd, fjiemrs, gvtnin, dfnijm, yzvvyb exuelye (57) ymfjt (19) jtxsofx (37) oagvuu (79) -> heuuqx, meqbgw kthzxmf (23) kuqnndb (57) gtdfvuu (56) wktjf (89) mpxfrig (78) -> elhjwu, cokjdc, rvzjawx etdmt (35) -> emsacsk, emvml, egcyvrv, srjbcye, ffyfj, ahuboc psblh (90) -> kfhcuvf, uspzk, wxakaqf tobzv (440) futsmzx (333) -> efehrqd, hmfyf, pgmnqws ubnxkza (40) kesgd (54) hhzjn (116) -> npmafis, ppkxgj cxthvz (20) tdmok (32) wsuihj (61) gkpgf (19) ncqiou (38) gwgdt (47) qufymlj (241) -> bbvrbl, ainqphn zscqv (188) -> acvrb, ggplfue, iygtv zzqjykw (37) xtwaov (33) acvrb (46) qbdhk (51) fjuudqb (37) kxolyhi (29) evgupeo (91) marnqj (1283) -> upair, mkrrlbv, vqkwlq, wsrmfr ssbjh (130) -> vfzlh, tdrsmxa wlefwf (30) tbute (89) diupl (79) dadlbnn (99) -> qrpab, jejvld yipnm (37) ymqmr (66) -> xcqhk, yxcliv, dubsgvx, kuhyqad nldgsz (68) hlglt (34) nrzhlvo (73) kxpffcy (27) -> cqdkb, hcetpw, yqkwau lhbmgxc (71) ehhlvc (56) fwxtdml (156) -> wfzbtxa, mygjnz, pqeph dbzwyez (195) -> mcvws, kocwei, lurly, xdraxfj jipgo (772) -> qgptpig, klkodi, tcclaa atfgzcb (95) sbcyifk (336) jdfrbhy (48) -> sgrwrkz, czfza, ymheeao, ucqru mohhap (7) raormr (23) fyqlzxt (56) eodyisb (11) wchwgnd (62) thuzqqo (1588) -> dapjjl, lvbjtf, bijhyzu xqukn (79) mmdrry (21) -> gwgdt, hiwslh, erjcx, mqccum efsbeb (245) vwltm (40) ixrrfy (48) sfbpnnz (41) -> cwrllq, evgupeo mjvopd (59) vjeiie (54) sblacv (86) tmgoed (92) iddby (63) asxiywb (9) qmdbgke (155) -> ttbtij, cpwxm wpdwdep (90) wbckbcz (43) wenper (45) emvml (47) -> vipgc, gpkltyi xvtwfks (14) kzpml (81) yqpxoki (42) xcqhk (66) pbxzzdi (127) -> rgonoq, zsnenc, zwxjsev, dyamtle auulu (68) jedlbro (13) welid (17) sbxkokp (341) -> gxzgsaa, sjyso, snxgfl, unllgjg gybgrld (51) jmazezm (32) -> grrbzan, hxnnsp, etgjaum, wccpr tusimd (260) -> rfrgmgz, mbsaywb mqhwlq (8) ydurwqb (43) fyeqds (93) dhhpxsj (55) upvrm (79) -> effjvcu, uwrqxmj bhtwp (65) -> scqhs, sixicw, mgghj fcpejj (49) awaoi (72) ahqlq (23) dqcxe (84) kddvj (23) usbjn (47) izxgcf (41) bqfsjz (86) -> ldwogg, mbvjj sxijke (987) -> dlzlo, jlsxjq, jmazezm ulvoyev (33) cpphf (54) qfanlc (11) kqtmc (83) hiwslh (47) mviyuy (44) hgyyml (91) fquyicp (113) -> fudpn, sfbpnnz, ymrfvp, fyptb xvawgcm (62) suriq (32) tfrjlk (235) dfnijm (168) -> saxamw, sgwcf, wlefwf, dcibpv xrockzz (37) zeximw (81) rckuzt (97) gvtzws (35) dlqmd (81) fjcibi (84) foldo (31) -> skyucv, ncunr gvzze (70) -> mupwbp, qowagej zgrdyl (96) rpijkf (59) drdvm (37) wxksnf (80) ungcoot (161) -> ejijju, gldkli pvnjsr (228) -> tedjgv, vpemk, lijnzj, ohprzku lgnfrti (40) ryrtqj (73) -> fvtxd, vuknf, dhhpxsj npznojo (47) usfkacz (34) vandhv (24) hoyipx (119) -> rpqvli, ixrrfy tevxh (54) bvrarwr (12) mxukll (22) ytbnpd (5612) -> rdihhfv, ctdey, vetgu, bymyuke, ogpunov, uohmo feuirvn (64) -> yjlzpv, mibwe, hlkvwq, ufses, jpvyg, auzdz, futsmzx oaqtjz (46) srjbcye (181) -> xvtwfks, skwbfku, qnqwt, awsdwry bjcthpx (92) xmiygp (35) tszcogp (189) -> abzdsbs, qrjor cklbsi (71) npmafis (62) ksvwjw (31) -> pcuxhb, zigfjrn pluph (15) tggyn (80) yrdpurl (30) igjmhxe (23) bkzzc (258) hmfyf (11) klvncy (98) -> slqmpe, kbyrlz, xzjiiwl hscywgt (61) ilsqjz (285) -> nqkpd, grkyj ksvdw (120) -> sskog, xettl wpwlg (86) -> kuxclnz, fkagf gkzbah (44) qtxkvx (71) xiksvn (114) -> cklbsi, ydhrzjf fjrrlug (16) rzpxffj (11) wviisf (11) waoiyzo (23) dtyaj (184) gbcnx (64) xtwtv (83) lsppdni (22) ydhrzjf (71) clxlfgu (86) -> yciccp, lhhlg, zwaky, kbjpgv, vuldvce, jzjxhyw, crxuc wccpr (61) zqkgqs (126) -> obvvk, ejkxeg ufses (326) -> jjwpqn, rnhom emdtn (87) kbgfqwc (70) yzkzx (22) pkeua (68) jdvfkii (69) -> qdibw, fthyzq, kdcijis twxwtr (47) ojyssxz (84) tvrosaa (58) rhsztrd (12713) -> etdmt, ykshd, xykcof hvjgdxs (43) fklkig (1573) -> ykcmvla, owhxvku, yrdpurl ejijju (29) hfgokdn (85) yxljri (103) -> ttfdct, jshxbra ykavsf (7) tkpcmi (32) ovlbvyj (70) fmvdadz (107) -> opqpgol, bryrofn urjsyac (5) jejvld (86) ygbecwq (85) -> mjvopd, midqcpz pttvms (47) xzjdfbr (176) -> jjwadjm, tkpcmi kxsweg (43) kmcjs (22) fqqzx (669) -> fafvyk, syrnxgz, xofjd dvuug (45) -> nxtmr, emdtn xhhtjwu (83) sebtdcx (24) xxiymn (110) -> ryrtqj, yikzq, fvtmh, bqfsjz, lgtpuqr, diila onwqbz (177) ffyfj (199) -> nepmits, sqcodst kdmuzrx (90) -> efhuz, yziwzua, wxnoy, kbgfqwc coxtcw (153) -> jdfrbhy, orulm, xiksvn avsoisf (81) aicwnq (46) fudpn (87) -> nldgsz, oluzb ozizlok (21) -> kfohhmp, dlqmd, zbbdyc, qlrcubm yrmifh (11) hxsuo (5) zfmqgun (85) htwkr (73) -> rhifo, xybhge, slhmny kzzedp (81) ocobkpo (322) -> yquhjrb, akmjes kzupr (72) frklhh (256) -> qfanlc, ouuud, gamlcl, chlyf alflnz (37) xettl (64) vfzlh (63) pcmimkt (19) mcvws (16) ezntvw (5) nqehtaf (1857) -> vkmtnn, iouczne, krzuab, mmdrry bbeclr (1645) -> zwqgf, wnmbn, jipgo ompzpgp (290) -> uemklxf, vwltm mbvjj (76) kbyrlz (35) adwzzi (71) -> yirmii, pptok, iqcjr, uhuieb fplzsya (201) -> ifdeve, sdiyd qrpis (19) -> srbczq, efajqe, qdxvydf qdibw (78) ouuud (11) wohob (108) -> drdvm, mdbzm, bmswiwx, fjuudqb lbflpug (252) -> mgqfs, bpknup, qxubki, bbijzr xeyfy (51) mohbkpv (81) szeszcp (96) myeqz (50) jmbptp (11) quinb (1927) -> jnojpf, qtzor xkfuz (75) -> rzned, eyqkgna, vjeiie kasnq (96) npsuo (10) -> phwddnu, zbgjuk, aofkt uvogit (93) -> alicosg, iakgro, aujqr zgbzqf (21) -> dunscc, qndcql, bzbyqoq, srhcew xqvmqe (198) -> gyrgr, kkszxy, mourke boipij (116) -> vtlxs, uyzpz gzokm (42) ppzlmxg (65) hukfj (57) wnshgr (1978) -> avzxg, afjqx, mqgculh, ylmixxx, pzxfm mvwcdq (149) -> myeqz, fqisabu komav (45) lgkrhh (33) gpxhd (83) zwqgf (661) -> obbei, bxdxjoa, xqvmqe, pcqhhy bbijzr (10) wcsnr (39) dubsgvx (66) pmakzzf (129) -> funtwzh, lccukr funtwzh (24) vqkwlq (111) -> bvrarwr, ghqvymr czfza (52) xieqyy (89) nbbctar (96) -> wpdwdep, arhlwh ykohs (94) nvdoenr (14321) -> coxtcw, psblh, foyabk sdllj (260) -> mzbhs, wgapb, ykavsf, mohhap bwdijxn (15) skyucv (73) jshxbra (37) krivqx (35) fthyzq (78) ghlkk (73) -> kqawctp, sgaefd pcuxhb (53) zdofuei (83) qiutta (15) fvtxd (55) bhxtgro (75) vqghnm (77) dnivyr (64) qltdz (65) wiqsy (156) -> kzupr, rirch uicpy (387) awpyosw (14) -> smbaw, xieqyy, tbute, fwkxcq stflbsr (190) -> yrmifh, eodyisb, jmbptp bcjpkwf (15) -> auulu, eeqoiz, nmmxms iieig (101) -> elvsrz, ncqiou exqhrl (61) tqclz (6) eyiiwv (72) feygolx (96) gkgka (21) -> xnxcez, txmdxj, yqlduph tznsg (40) flzcf (22) rhqocy (36632) -> fzerj, myhfh, bqzfjn lhhlg (111) -> wjsijg, szvfc jshaf (84) efhuz (70) qtzor (54) imeyrl (23) vrrmn (47) -> gqxhfjz, hfgokdn, zfmqgun, dljfl egcyvrv (132) -> cdkadkn, gvtzws, zknbqr qgptpig (177) -> jjeci, dpvwrn kjljvr (15) -> qclhx, xqukn, nyaqnau, diupl euueza (146) -> xeyfy, gybgrld kupsxf (724) -> zxtwo, klvncy, ygbecwq rfrgmgz (38) vxbzw (1698) -> uosltv, bzjze, owprin, lsxnn pptok (27) vipgc (95) gzoyqay (141) -> pjzyj, bpgbauh kjtdypr (17) mhdhb (86) zxtwo (135) -> ckaqw, ovcxkye lvbjtf (1466) -> kuqnndb, exuelye vfdnvk (21) pzxfm (107) -> xvteib, gookalb, rpaudj ubxume (68) dljfl (85) tfmvb (128) -> vlglq, kcscgb zspohe (78) -> jkfnrik, iiurfqv, wchwgnd, xvawgcm uycwnb (47) rwrusdg (1351) -> atkstsn, efsbeb, abmlupq gbrqt (16) hxvizze (85) kcscgb (98) iwcpvdx (161) -> kxolyhi, xttsj pnmkw (190) zhavocr (11) eyqkgna (54) rnqtg (33) llzodgr (5) bmnsk (17) rwaeimg (137) putdqt (78) -> qbvurh, rbauepa, mhdhb meqbgw (77) cwahmsr (56) endpyd (97) wgmvio (96) mdbzm (37) aeljb (11) tcrpymd (97) owhxvku (15) -> pnctz, riogbaf, qrpgt pwguzgm (17) ihwkjjt (16) eqsrff (33) -> hgyyml, uaxhb rpaudj (12) cdahg (11) gwgas (54) gzrmt (74) kuxclnz (88) ffdxovh (25) geuopn (13) -> fyeqds, uqraz umlbvg (43) gamlcl (11) ywnji (37) aezwvo (146) -> ayvcc, kxsweg xqdih (23) pbjuhpo (70) qltdv (32) irzscv (60) kdcijis (78) olwudc (5) rbauepa (86) kcekden (1504) -> pmakzzf, fmvdadz, zgbzqf olczth (39) hxnnsp (61) psyino (55) vkmtnn (139) -> augxmyy, fyrauka edncj (16) bryevj (83) vlisesb (39) ykcmvla (20) -> cvgoojy, codttfw wgnoil (79) -> vpmywt, xjekui, gtdfvuu, cwahmsr gookalb (12) aujqr (52) fjiemrs (220) -> wcwqeyz, welid, sytip, bmnsk avzxg (7) -> pkeua, ubxume vwqquk (25) -> ythoww, sqauq, plevjup, ouxdvp, qtbnqo, kndpli, gvzze usodp (78) qpafkjx (71) -> hxvizze, klvufp, txwsp stttgb (13) lxwntcm (12) vpmywt (56) gyrgr (9) rpqvli (48) fcmnfq (73) ovcxkye (34) sgrwrkz (52) yejoqrc (16) qeoicwx (56) txfnjo (140) -> gwgas, jlryq ioyiklx (120) -> uigot, ypvews hwdtq (5) wjjsgvw (74) fwlspf (176) -> qpoodx, sxbee, xxiymn, qigsvd wwritm (245) mzhyo (198) -> cxodl, aaecklm, imuupp mcpcxw (61) txwsp (85) iyrapzn (84) awgucd (39) pbeegf (180) -> ztxam, nuyake rklic (832) -> ylfgaps, gedajwo, olntlo, ilsqjz, tdqxy, oprsej ypufgmt (9) mourke (9) wjsijg (55) pikqy (78) ckaqw (34) wrcpxdx (83) -> avsoisf, kzzedp xhirm (83) rnjqmh (97) -> kzpml, emdnkj oilsjpr (195) -> pluph, rmvdiwr, idgmre qqktjg (1859) -> cjxuj, pnmkw, pbeegf hqget (11) qrpab (86) vtwtgf (22) vdpnz (158) -> qkzklgx, ywnji hweub (201) -> vdebg, vcihirs oluzb (68) gegrzz (24) tgxuhxp (262) wxnoy (70) jdvbztj (44) mupwbp (82) wtsesxe (85) uwrqxmj (89) orulm (128) -> dnivyr, gbcnx vcihirs (25) cdkadkn (35) yvchtk (35) yffid (143) -> deiso, kbtfnu sytip (17) qylvdk (20) fyptb (100) -> gnbjv, rklnuv, cxqgvb ldbwwt (34) tcxwrcv (43) zglws (56) -> kasnq, jovgiy, kywxkgm, zgrdyl aikmwxj (173) -> bkomu, pcmimkt chlyf (11) oivlxe (34) ggplfue (46) bmhlcgg (103) -> yoabvhm, mpuhqjm xlxct (137) -> twpxg, cxthvz xzjiiwl (35) krqff (39) dunscc (39) cxodl (7) axlitg (234) -> imeyrl, waoiyzo, hqmxuv, spcyi yhrnh (37) mygjnz (56) wloqry (74) qndcql (39) cmnjg (843) -> hhdth, ompzpgp, kdmuzrx, ovvmrux, awpyosw pcqhhy (63) -> pozhxfb, mohbkpv rlhqosc (83) vioyx (52) pegoi (27) -> qsjwlq, kxpffcy, fwxtdml, tfmvb ljeztky (51) -> exqhrl, mcpcxw, hscywgt lccukr (24) brolhd (34) plvjk (1222) -> ksvwjw, uglvj, rwaeimg xfxqbqv (11) gnbjv (41) egjsilp (78) vbkqzje (36) simlhnw (223) -> kesgd, ykhrxqf midqcpz (59) tcwzc (33) cakpt (29) -> anraget, tfpjxcv, klzgol, ntpmw ncunr (73) crxuc (176) -> qiutta, ivqduu, uvatphy wipafb (11) cukwe (80) kxouhtb (181) -> aztstf, qltdv wdjgdoh (51) -> ngvqne, zdofuei, kqtmc uvatphy (15) jkszke (32) hivoik (55) fjdki (43) abzdsbs (13) odzzie (1585) -> aikmwxj, yffid, qmhaa, ixlern yqlduph (94) mzbhs (7) mibwe (162) -> qbdhk, mflvlww, vvwrg, nslyvt wfzbtxa (56) kivlu (35) -> hagdjuz, stttgb szvfc (55) uxblgk (230) -> lcfur, ebfzjux hagdjuz (13) slhmny (66) qshflsm (361) -> uhalup, zdncj oxvcp (232) -> ujupo, qsgkmc jkfnrik (62) qzeljtb (101) -> wsuihj, vlcrx wugret (29) -> zrhyprz, gwohx vvkgsba (61) cafxx (152) -> zjzxav, tcwzc, wkjhmcd otmpv (171) -> dopdknn, hvjgdxs, ydurwqb eilfrxc (34) mhfci (2359) -> pegoi, ubvvr, fqqzx dqury (179) -> iunue, ffdxovh gkhrgd (92) bwsvr (14) gedajwo (299) dpvwrn (43) vfetz (91) dopdknn (43) bxdxjoa (225) qpoodx (1001) -> gqzczp, adwzzi, ghebwaz fnlapoh (1284) -> yxljri, xlxct, foldo mkrrlbv (43) -> ahqlq, igjmhxe, xqdih, raormr bijhyzu (368) -> jdvfkii, chpjfv, wgnoil, gkgka dfsas (34) unokgle (14) qsjwlq (268) -> tzcymqj, gtzrs eordj (45) tdqxy (77) -> hzrphej, uusufw, wjjsgvw klvufp (85) kfhcuvf (83) -> llbsax, rckuzt vetgu (556) -> yierd, wohob, ssbjh eqpuq (254) -> vbkqzje, pcpcm zjzxav (33) ustkg (57) -> ormhqr, xtwtv ujupo (28) vdebg (25) skwbfku (14) nslyvt (51) cvgoojy (5) qvtwlq (9) iouczne (139) -> krivqx, xmiygp foyabk (390) -> iieig, iejyzgu, onwqbz kkuzi (8) akmjes (59) fjayhh (6) bpknup (10) zrhyprz (93) olqgu (53) -> walei, bajtat, igiqnkc, tobzv, ocobkpo, zglws xofjd (77) -> npznojo, twxwtr, aqfjqh ptmqqpk (13) -> yejoqrc, ihwkjjt, fjrrlug krovuvc (34) tdrsmxa (63) qmhaa (31) -> szsfe, nconokw, wenper, tnkptkm sixicw (61) sgwcf (30) aaecklm (7) ewycyf (63) olhbx (1384) -> zlmvme, ljeztky, xvpopw uemklxf (40) nwcbnxq (46) nvcmjx (26) eeqoiz (68) ntpmw (52) qgiijpu (49) iygtv (46) jrbqu (68) yxcliv (66) codttfw (5) wsjuynd (46) dxffsoq (58) sxcxmg (98) -> tcrpymd, endpyd wthxapy (77) sgmbw (613) -> ytbnpd, tgqnyb, whgqhb, wustjt, zwwrwfy opqpgol (35) zigfjrn (53) tpvcmkz (1111) -> dtyaj, xwmjpb, zqkgqs uyzpz (92) ctdey (628) -> aezwvo, vdpnz, ruxqapz gxzgsaa (88) -> wcsnr, kcvhi rzvrn (1852) -> bkzzc, isbppt, ioyiklx auzdz (82) -> fiehsiq, eylfls, cvkec, omkgoai gtzrs (28) diila (192) -> kthzxmf, kddvj ojgdow (15) -> wdjgdoh, gwgnf, bzznyu, boipij, otmpv, wiqsy saacvs (12) qtbnqo (156) -> vlisesb, olczth dzwnzm (9) neltlwg (60) qlkhbf (33) xjekui (56) lcfur (53) augxmyy (35) nxtmr (87) cciwzc (158) -> fjcibi, iyrapzn asdbbxb (91) vldxx (75) bzznyu (140) -> tggyn, nthusc wxmxkzn (73) gwgnf (57) -> wbntjyi, ifmgil, zeximw"; //using (WebClient webClient = new WebClient()) //{ // webClient.Headers[HttpRequestHeader.Cookie] = "session=53616c7465645f5f85f63314a0cee11b2b23543970d34a959602f6ceaccc21f28df18de536ed26515ca91c2a5d779f21"; // inputString = webClient.DownloadString("http://adventofcode.com/2017/day/7/input"); //} { var result = TowerParser.Parse(inputString.Trim()); Console.WriteLine(result[0].Name); var unbalanced = FindLowestUnbalancedChild(result[0]); var groupedChildren = unbalanced.Children.GroupBy(_ => _.CombinedWeight).OrderByDescending(_ => _.Count()); var most = groupedChildren.First().Key; var wrong = groupedChildren.Skip(1).First().First(); Console.WriteLine(wrong.Weight + (most - wrong.CombinedWeight)); File.WriteAllText("temp.json", JsonConvert.SerializeObject(result[0], Formatting.Indented)); } Console.Read(); }