diff --git a/2020/Makefile b/2020/Makefile index fbee5e7..ede9575 100644 --- a/2020/Makefile +++ b/2020/Makefile @@ -1,17 +1,5 @@ -day1.out: out/types.o day1.cpp - g++-10 -std=c++2a $(flags) day1.cpp out/types.o -o $@ - -day2.out: out/types.o day2.cpp - g++-10 -std=c++2a $(flags) day2.cpp out/types.o -o $@ - -day3.out: out/types.o day3.cpp - g++-10 -std=c++2a $(flags) day3.cpp out/types.o -o $@ - -day4.out: out/types.o day4.cpp - g++-10 -std=c++2a $(flags) day4.cpp out/types.o -o $@ - -day5.out: out/types.o day5.cpp - g++-10 -std=c++2a $(flags) day5.cpp out/types.o -o $@ +day%.out: out/types.o day%.cpp + g++-10 -std=c++2a $(flags) $(@:out=cpp) out/types.o -o $@ day%.cpp: cp template.cpp $@ diff --git a/2020/day6.cpp b/2020/day6.cpp new file mode 100644 index 0000000..ae1035b --- /dev/null +++ b/2020/day6.cpp @@ -0,0 +1,64 @@ +/******************************************************************************* + * + * Copyright (c) 2020 Gnarwhal + * + * ----------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files(the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *******************************************************************************/ + +#include +#include +#include +#include + +#include "types.hpp" + +auto main(i32 argc, char * argv[]) -> i32 { + { + auto line = std::string(); + auto file = std::ifstream("day6.input"); + + auto answers = std::vector(26); + + auto sum_1 = usize(0); + + auto group_size = usize(0); + auto sum_2 = usize(0); + while (getline(file, line)) { + if (line == "") { + for (auto i = usize(0); i < answers.size(); ++i) { + sum_1 += (answers[i] > 0); + sum_2 += (answers[i] == group_size); + answers[i] = 0; + } + group_size = 0; + } else { + ++group_size; + for (char c : line) { + ++answers[c - 'a']; + } + } + } + std::cout << sum_1 << ", " << sum_2 << std::endl; + } + + return 0; +} diff --git a/2020/day6.input b/2020/day6.input new file mode 100644 index 0000000..f8efe7a --- /dev/null +++ b/2020/day6.input @@ -0,0 +1,2249 @@ +fekdcbayqxnwvh +fycwqktvxandeb +kqbafvcxyewrdn +akwqcvenxfydbs +ewbaxdcvnkyfq + +timjneyhbvxkfagdpzrous +gsumijvxoheptbafnkyzrd +yxtbnupramvdezhkfojsig +soaruhxnpiemjvytzbfdkg +vfanlgjoiskzmubtxhceyprd + +dhgabzfspkltq +pflzsbtaxhqdkg +kzpbfgasthldq + +xeu +uoe +tnpeox +e +vrdzwglecbk + +nucwl +hnmx +fqv + +kfubtzpovrdlw +vdjmblrztpkosfg +kavpdbgfzreol +qpdzfrvokibcy + +yhknrqpubeolzixtvsj +tlysdjzovxhnuqreimk + +bclpmatw +btqmcw +cvwtbm +bmwct +ctmwb + +qmo +oqm + +su +s +s +s +s + +ztfmocgiesxdq +fpjmthksidlbo + +smzbn +bmnzes +skzmnb +mbszn + +kibmrznqcyladupv +umnbkdpievlqcyar +idavpbmnrklqucy + +favynhqocijkmtbzsrulp +ycbzrmkuvlhnpfqsitjao +ujbomprktafvliqhycnzs +nymjkczihqbpfvutosalr + +tdev +vh +wva +va +gzv + +d +d +d + +ejrmqwg +merjguw +jmreugw +mjrgwtie + +wxiqgpu +guxqiwp +puigxqw +pugqwxi + +ealugrzsvhpxfmjdbqknoy +doyhvplkjqarnbeutxsgfmz +uhvxjaklmzoyqdbegrpfsn + +iv +os + +o +amtle +n +npz + +vbfxystq +knsxyqubtvf + +t +p +p +o + +xtz +ptz +ftx +ujt +tp + +rs +qdfan +mkpz + +idewynukmzac +yacfmdwuizke +ieuamdczkywf +iczwymuekad +adwekumyciz + +agnq +gn +gno +gni +vkmnxug + +ftlyhuvaj +xsribwknlgmt + +a +nay +a +a + +leq +q +qj + +sxrwi +isrwx +wrsix +iwsvxjr +rixwbs + +p +p +p +p +p + +unvlyxripzbmaedwjsfqth +uvefyibspxrzjdlwtqhnam +hnbapqzflsvxreiutmydwj +nwdefhtzrxuqpsvljabyim +razbwymsdfpnlutqxveijh + +zfihqcvwdbsm +sufwpahczlbvd + +tqjanyicszeodpmk +ljmtwvkrcfghdqbu + +ydxnthpazbskufcq +txymsjdfhwuqbz +vhyuqsfjbxdrtzg + +smyvegtwiu +imyqtuesv +idrluzhjatkvpc + +pzacglju +pzulcagj +jcalgupz + +rgzbvefacsw +vafbrezcw +wegjvrczfqba +zwrvabpfce +rlhekwzyfbacovm + +hfqu +fq + +kywvrsxgiojp +xosvigpkwyjr +irwkjfvmxpsyog +pvxyrwiksjgo + +ynebghqmrkcjlpiuftdoaz +reaqjoyngdbiltkmuphcf +ynobfdgluriphskejcqtam + +uac +ca + +fmxawgkrin +xfrnbigok +sfighjeckrux +girxkfl +gaxirnfk + +smoyaxbku +uobkxysam +kyszxumojba + +uocvgjr +hjponwcuzg + +fobhkeascqluwrzm +hzcolfipysnrjaguwkeq +ezwlhkcfsoxqrua + +blnosjgezuqcrvxwm +cmeznoglqxubwjrsv +zxnqvwoubpremsjcgl +umxrlsgqoczwbvnej +cuxanesjkivzrmlboqgw + +dewtyuqjlv +ucvazfm + +kbm +imltbj + +ydqnxlmbouvaztcg +vhrkwxjzfnpisye + +jqeadkcibtgflsz +ltbxqifjedsawkzcg +zdfqgkijestcl +jczfqdektlsig +scdgufyjeizlkqt + +w +w +w +w +s + +wygptc +ygctpw +gcptyw +tpycgw + +xaqicwhtdpvk +aixdcpkzhvqwt +qkcdhxpwaivt + +wt +xtrowm +wt +wt +tw + +sncq +cus + +zehxb +txe +exuma +exz + +epjgfknhvuwmr +nkwrmfhjegp +rjkpynefgmwh +ehfprjkgndmw +mewkfdnrgjhp + +hgyc +kgc +ghc +cgxjzl + +evsloum +leosvmu +mejvuzoxdsl +evmolsu + +fugckqhymrxbtvdpnose +beyorulcqxgdkzafh + +s +s +sq + +wtjfgezdhsxckibrqyunvpo +uaonrpkmidbgftwlsjz + +mrylewxsgvfodhu +sfdxoyghwlrvmu +dungfohvlwrxsym +ulmsoghvxfrwdy +uoifgdlwrsvymhx + +tbg +btdg +tbg +tgb +btg + +pukht +huk +fhkqu +hykcfu +hedvmgubsk + +dxycvosnr +xcsdyrgmapf +qoyrsxdc +uedsxtyrc +ucdrsbxy + +m +xz +m + +gcjsybuhrotm +dojcsubhprt + +opmgsudhej +mjceogdsuhp +djpgmoushe +jgeptsluhfomakdvyq + +jugocetyrzwfbhp +ipvqwcozxbsdu +gybprkmznowultcaj + +ipcau +n + +juzmidp +iudjp +digjups +pajiud + +zxnugrosjvlcphwmqbdyt +bvtlmqnudzrjwysxcohagp +tdxhyuwemcvbrpzgnoqfjls + +hoefmguvxyiazwcpbrjk +umlbagzxeowthjfpik +hmxeziglfbwjup +jgxbspifzwqhneum + +mgvupsk +ezwcui + +adczjnguyq +ygnujdacqz + +ohricgqjfu +rqgucfhoji + +vygwkszidxqa +onxkejczsguywqv +stvzbqypwmxkg + +ydjm +fpbustykx +yrq +ry + +vjphn +npvhj +phvnj + +bryndzmekui +oathqpcv + +yczewurklaxnfdhoqbt +rlyhawcdunqeofxkzbt +lhbsqfkxctyonwrdzuea +zltnhdkqybaxufoerwc + +cjwarkog +joawgrkc +wcjgkrao +wrcjogak +coerwgsajk + +umwjqsetdg +sjwmet +jbteyhownvsaxm +dmuspcztjrew + +xtswpc +eahncvzqxkgmo +lcixybdrsuft + +pcrfwszodmqnj +vrcylgb +iruc + +bqigzouxryndpa +jaixybnro +oabixhnjry + +pbznr +xrb +bdntx +qecbyi + +zbvhxyfm +vxmbyfpz +vbxzmyfh + +nfcqwuhsrxojk +jrqvokfscnxuh +nxqiaulkrojszchyf + +dkwqfb +wd +hwd +nhwd +dnw + +vjtpxorsdyzbwhqi +kirdlmofpnectxqwuz + +ynzxtvqogrdhwl +yhdjomktn + +hqwn +hnwq +hnqw +hwnq + +gosxz +xog +gfomxa +ogxd + +wctesuhxonyl +oxwhtecynusl +cslwxehupyton + +pr +spr +pr +pr + +maqfseovdhzj +sqodparevimfzjl +dxosqmafejvz +dqzojehfasvm + +awsicurgfmxeqjylnvktbd +dywmreaitvjgcnbklxs + +wmvbnqtxuriz +hbuwefypzlkadq + +asjcpwml +lcasmjpw +ajspcmwl +cmslwjap + +unkrl +n +ny +yan +nv + +zrjwsxduie +jswxrziunde +xrujwhsidze + +qnl +unc +xhtdjbvf +omauis + +wxvoqihatseg +setwqgi +ewgstqci +fetwqgis +wqtfgkiesd + +vmpikgfsarbnxqudwjtoh +bdovpatjgnxkqufsihmrw +bjhnrtaokxudmfqpigwvsc +kaqbvihwmsnxjpgrtoufd +fmabtdgkuhxpwrivsoqnj + +eazsitkjronml +otmrenjakzsi +samrojenitzfk +tkzenmrjoais +tszkioaejrnm + +r +rbq +r +r + +lwbrfsuahoq +yjawifugdtrvs +rfbaswu +cfsarlknupw + +ist +ay +kc +cu +kd + +mbku +bkva + +sxktwmyfaldbn +ymkbnfpdltx +xbyftnmkdl +dlkfetbimxycn + +cjru +rcju +rjucl +kcjrum +auzcjrtn + +vkinfzqbrled +rinldvbqfze +rqizebfvldn +aciqrfbsnelvxdz + +ig +ig +gi +gi + +rskzxocuq +kcovqsnztur +skzocrnyuq +vourxysqzkc +opescqukrhjz + +i +u + +xqfviycpuzjbwkn +lnxbfkpcyqdawm +xofypnwkbcqv +wbvxcfkqtnpry +bnoixpfqgkcwy + +ziwlofkdgpc +qzayrwjvks + +krybec +ryk +yrk +kyr +yrk + +xkhdreqfbyipmzalco +wiepqtyhxflvcomabjdsz + +jpgankzcvbtw +kxzugtvnbjp +gknqpjxzvtb +kbtjpvzgmn +bptzvmjkng + +hdaxwiypslz +ndbylw +xdkwtflpyqsz +wlrvcdyjg +mlfewsqodyu + +c +c +o +c + +mah +a +gwa + +heczudoqwmvtyab +acevwozyqtdumhb + +v +e + +rom +mor +romi +rom + +uxdj +d + +p +p +m +db +t + +dtpzeykh +pkdhryzetu +zdkhtpyac + +qanetkhrc +ndlhkceqof + +khbfjlnacvz +cmavfjlkn +aynljofvqkgc +tlkjcnavfm + +ejcbnl +mbgcoiuhsfl +qblyc +blyjevc + +vgqlcfhnx +xwgonuc +pystigbca +cnqlgmdk +rlfcwg + +nazyhitgcjr +nytgizahwprjc +zjcgrinmahyt +nrcdhzgjyati + +xtljebqpg +bpjewtgn +gjtpebx +gmoipkebtcsj +ptwejlbng + +e +exa + +h +nohegc +h + +ivbgpd +isfglyvbdo +dgvbi +bdivug +gvikbd + +wyjmpxghiqfeoctdnbuar +qetnaimxlgsfcbrpj +kbcrhxgjnqpadefzimwt + +kindbwqlusyh +tpzryjgehaucfmov + +wzgou +ugo +guo +voug + +ndwhzsrugpjmltxiqofvkbyc +lgirqyotwjbmvuspfnxhdzck +jbqzgwcvhxofkrmsdlytpuni +xrqzfjolsywtcghdbmukpivn +oqryngdmhljvctxwkbfusipz + +saw +as +sa +msajv +sfa + +oxtrnhvfqyswldb +tmzwgrakc + +coqyrbzjhsmwivanep +xkshzgft +hsz +slzh + +z +glh + +dtusogw +fmpkzvbxnjwh +eaqdciyw + +bgcyqhrztvdxwn +vqtanbyurxczowdg +kmjxyvnbqztfgcrwd + +vospejybinm +fiosvkbnjep +johqpznbeisv +iysbokmjvepn + +nxsrfohagwb +agblosrxwnhf +xgircuhsaobfw +hfxpgosarnbw + +bgqurk +eumkrnvxqg +gkrqhspafuoc +qtogubkr + +bxlapnm +nptix +oqxpn +npx + +rytbpswaezlufdqxo +imazhtjqnglc + +encpqudzigamorv +vamkeznqirdcgp +opvrglqsmcindzae +mpvncrisdezaqg + +ikxqemun +zadbkqjtxney +kenmpxuoq + +vjdqxfyhckrpton +hmngcfpytkdxqvo +ohdvuywpstzkcaqf + +tepj +te +ecvty + +jqotiphkmsexvfugd +gwpyfuhlevkdiotjqx +tjkfvghibocaqxeudp +onexjzpgthuidfkvqs + +ltfq +lqts +oqtl + +nqsyglepwzhmtiojbuvxf +wihkgaoydpzvfxclsenqjmt + +fqxmt +bsgtmxqyrjfdv +tfqmx +itmhqwfx +qtmxf + +rgv +vjwo +nlekpa + +ldytkguwhazeqpb +pqzaytglhbmfuedki +dqbatkpyezhglu +ztgyqjebhkdvpual +kpalzeytqghudb + +xsynhr +hsnury + +qyjukdtmnwhrczvolsb +ymsutqrchdblznowvj + +mpw +wmq +tdwm +wmd + +n +n +n +no + +vnutqbxrygmjwhks +rhoalixstfyuq + +jeyfhsotc +setchyoj +hcyoejst + +ylhpvfiawoekjbq +pkroabqvljiyefhw + +akqbyjpziglmfedw +wjdbyeaqpzligmkf +lfikyqwzbmadjegp +aswgkzdyfrqpmnlibje +fqpmyedjklgzibaw + +qe +eqo + +jbxoe +qoikde + +c +n +j +j +j + +rfh +rhf +rfyh +rhbf +qfrh + +hokvgpxyunam +bmpyogvhunlw +morevjuznhydgit + +ohns +nhos +ohns +hons +hsno + +kxclzyqpan +aexnyqzkpc +pakcqnxzy + +gkytw +mgtw +gptmw + +fixsozjwykhupqmvtbrc +syimxhzbpwcktrofuvjq +xuiwfjvzcpykqhbrosmt +mwrbvqjtkcsipxfolyhzu + +bzhxpyfmk +yfzxmakphb +mkzpxbhyof +hbmzfkxpwyu +pxzhkoybmf + +osdyp +dbsroy +sydoj + +yterzphvxdm +vtxrmyhzedp +vymperdhxtz +mpxrvyhedzt + +esakn +cseak +hxasge +enksta + +u +gfzua + +jsymd +dmxjy +jmdy +xymjd + +sezfhlvxmaqtd +ajvtmqsecyghfixzwl +ksbhxzvafqpmuet +zfeqytxhadmsvc +nextsvazhmyfq + +rucla +auclyr +uticrapl + +akizsuwdmnhpxbgyceft +gwxpfeoyihcklbndasz +zwhsbigdynkpxceaf + +zag +vmisa +yphkcant +jdma +bia + +nplydbkoq +oasptkqgldnbey +doypnqklbc +yblkodncpuq +lqkynpdob + +hmj +jm + +gniearxpdbjlkfm +qdvjlute + +omsihqlnwzbt +blzmhisnqoftw +onqlmwsetzbphi + +jzoxcwdf +wdcjzifxq + +ykdshgzwjfecimnp +jhipmsaftezkoc +ziaspcjfmkhve + +t +t +t +f + +zmevcjhbsainxoquwpftkydlr +cygwbtvxemnzfjhrqkdspaolu +efdtnrlwczymxqvpsoukjbah + +oujkhnlzydsirva +dxgzjsuptaohqvnkic +aoiujdlnkzehvs +uriadhksjyoznv +iydmovnzakhfusj + +ycajzrtie +zctyriesap +pxiacrztehby +qaenyxtzirc +saecrytzi + +xrnjkgdpuzqvcm +ndqkvuxczjpgrm +ucgmzjpqrnxkvd +npqxkumdcezvgrj + +thymlxwaoz +ylhowtmazx + +nwaisrejbtqfmh +mbwhqnrfjesa +hfnrqebjasmw +jecwhfgrsqodanmb +qasbhnjwferm + +ny +ny +yne + +lgkmfbthwaouscxpznvyrdi +nhlmtpwyrojfvbuaczxkgds +askbuvdozmnxhfygrlwctp +fytznqhlbmxgrwcdoupavks +wcplxyvsrdjnfgkmuzbtaho + +fklceui +kclfiue +klefiuc +clfekiu +iklcufe + +yavcmhwbp +capvymhbw +whypmabcv +pbzmcywvhja + +lbevjz +gnvefbu +webvd + +ewzcqndmjhvy +jevrqnym +guqpiotaevsbmynlj +vqmekjynf +nefqmjxvy + +akgwyjfi +giwfyljak + +pdejr +jerd +redj + +liwtk +kiwl +wikl + +rbwvox +bxvnor +vbwxro +vkrxob +xbvirwo + +ntsbkwqefjphro +nqdvgxihopwc + +dn +nd +nd + +j +f +g +k +j + +tfsul +usftl + +ov +v +w +tj +sl + +gdlufaesv +uagvd +vudag + +cbegxmuiwkzo +okrmgbfwvnecp +uybxehawmgqkoc +yloqmbwgtczke + +jms +ymsfjo +lmsuiwhe +ydsmk + +wgckujsd +irp + +zgeulsjvimptdaxrqnk +zbxtefdmvganulqprikjs +ptslznrjqkxemagiudv + +fqtb +qp +aq +q +q + +hrkzci +bhwkpidxtflcue +hkic +chki +kcjhiv + +gi +s + +rakewmostbfvjzgi +begtioavfrkzjm +zoeikjtbfagrvm + +xnbhdlctm +bgfhwlxsaqnkov +pelmnhuxryb + +e +qr +jh + +vhtwuokdqpa +jfaniksczbeymr + +ngedtljsvybxkmhfuzw +tbzedwsjgknvhlmfu +lzbgdsuhkjtvermwfn +smizqluwdetfavbnhjg +blwtngusvdjzhefm + +lxaiqvkoh +feioxvwbsrl + +fy +yfbqlm +fy +yf +yf + +cuygpzd +kv +k +v + +antp +nat + +uk +ku +uk + +tdjbri +rdwezgjtlck +stvfhapyx + +psu +spy +ps +pksy +bpsq + +db +o +o + +yi +iq +pmxi +i + +oxt +atox +txo + +wn +sgzth +b +m +ynq + +ayxvhzu +vhyzxu +hvzuyx + +cxoygklt +toky +ovkpyt +voystpk + +yqtjwifbvsn +vstyfbxjqwin +vsjtinqfwby +qxysnitjwfvb +bjfynsthqiwv + +zobny +zynob +ozbyn +noybz +onyzb + +inpdmtkblgqrvaowzxu +zhrbpuwiqdomgvlnt +topveguwzrcbndmqli + +eapmtqrski +islukrmpe +sevcbzfngx + +pcbl +vxqwe + +ky +t +p +qzfo + +bkhdlpnrxezivu +lztsfxpgknho +knwlxmzjhpy + +t +ita +oqt +sbt + +omwk +eowm +wmo +wmo +osbtmxwd + +dwgpvjemitbcnuhr +vyjlitenkbpmuhqwxd +iedvbwjczstunpmhg + +yfakujntsriwgxm +rfatigyjkxusnm +uyxitmkagnjfs +isjafytxumgnek +tiknjmugxsyaf + +pahkyfojrv +enxmd + +sehnkcr +shkrc +hcwxilkru +skgchrfpjt + +zdcvpant +nizclpmtgbv +jtcpnzv +phtnscvza +azcntrowvpd + +ativhgmyedozw +nvztmiahewg +uhaimgzventw +txiqfmzglphvwae +ehmgiwtzav + +qdpreikohtyjc +ihtydekrocpqj +djkoticqhpery +jcorkdepqyiht + +kgwunqm +qgjunwk +oinqruwzyk + +wtkqceimludr +mkhpwdcqleurzt +mqweldutkcr +kdtmwceulrq +rqlutcidwmke + +k +h +k +k +k + +irb +arbi +bri +irb +fbxvri + +umpkng +qmnugpk + +sbdxmlzacj +sbzlcamjxd +cajmslzxdb + +fwndcxr +xbmusn + +t +t +gh +p +t + +zovqiwdhuaslkjxrbcnt +flhnkoxvadiqrwpzbjs +gqkisrxodznabjwvlhp +koqlswdahnzjvbrmyxie + +apecofvgshiyqbj +icegjhasytobfpvq +ocsheqagjfpyivb +pewjncobqiysgzrfahv + +wzomnlgyxj +thazprgi + +rywgaemsubhvkqcozpnxl +avehbwolxnzmqyprgu +qyrgpxhazluvenobmw +jhtrzywlnmbeoxvgpiaqu +gavmwzrponyxhduqble + +tw +wt +tw + +qpzxrctf + +iqpunlsawtcykmxbdvgfzjr +vnwdruyptakbgqxjimlzcfs +fgizdmcblparnsvtuqwxkjy +pxwylavndgqtjbicfksmzru +xtpdfrbkcglzvqjuminaysw + +xkyvhtdwpjnulig +hvegnyitdwxjz +vthsnxjaywdig +whdagyqvxjtni +wjvgytdaxnhi + +ygduev +clqoa +qxc +xaz +fc + +rzeqvofasyhjgxwkmtcudn +vkuogexmwhznrycdqft +zupwcondeklthrbvxgmyfqi + +mtredzn +xcnozebtrmd +elzrmwtund +emtdnrz +tedmzorn + +tlbunpqygz +xmehasrifvwj + +hoskgitlw +owrailhtfkg +wigbjvhtolk +tbhivwgsuklo + +fxnachtsdmiwvuzkg +hacwldskfgvuixmtzn +xghufdizawvnmsctk + +gnauvfizjdortq +rinjautyqdzvg +giunqazvtdrjmc +wndhjzuqviatgr + +vtpsy +sptvy +svpty +ptksyv + +yaskce +xdtvyjnqma +faoyb +psyfa + +lbxounj +lijrmoxnb +mioybjnx +afbjnvopxsch +bjlzoknx + +vqmsgwjfkzdbthal +jszvlwthkmqfgdba +akmfjzgldswvqth +tuswfahjmdqkgvlcz +jvatqgfmnwzhdksl + +uqyfkzdwta +hctzeiywabpgvlqonmuf +zyurtaqwsxf +wyruzjaqft + +rwltyhqdecxagbov +azthexlkoqmvrdngcwfs +corjvwqhutexadlg +lecogwrhavqdtx +qpdvrgctyaohwlex + +egsilhd +hxmijg + +tzdmnvsyiwjrhakbgp +wmzhsctpdrbnagvyei +bvwtaylgdnzhsmipr +rhmlswzvpandgtybi + +qriopbacexhnlwfvsmdk +wblaondrszhcfpei +pdnahlrjseiwfcob +cerwaoshjldbfnipzu +oalsrdienwcfhpb + +xcpe +pcx +cxpl +nbpyzixc +lpecx + +xyfcgdaew +jdlcopnaixqbv +ehkcdrax +dcytarmuhgxews + +bqozpsd +pqzosd +zgqdop +ocqzdfp + +uxy +szj +jzl +fhvk + +muz +m +omycvi +im + +t +u + +xslkmbzarnfeo +axmndjpsqzelrbkfo +eykroszbaxlmhfn + +rsz +rzq +kzrit + +hkmqiydpzlosuanvwj +czsjklbvwaidhnxpu +ejvwqmatlkziundhps +udgjnfoepkwilrhsvaz + +czlnqtdy +bcv +cvga +hvcb +ac + +lcmytwdeqifzakjhuon +mdqxhfgpzykvteajn +emfpxqnhbykzdatj + +rtgmujlen +eguclrkmtnj +npjgemtrlu +untmegrjl + +olykiz +orxyswdtka + +qelnh +yijmfxtvbs +gweh +wrc + +vjcediawtnrmoh +lvnhmabrxcjwet +ajmkbntrvchlegw + +yicrxeztbdpjuqlfgnvksmah +rayjtgdsfhexiqvpcznlkubm +crxijflabsgkhtqmdeunpvyz + +gpbklvxy +pybxg +ypwgxbd +gpxyb + +vos +sv +vs + +hqiktnmezpvacby +uekhv +egskvh +kvehog + +myhoetiwlqrpdk +pgfkbqleywmhtic +tezpslhymwkiq + +t +vxh +g +t + +gjimn +ijugmn +njmgi + +drojlynvs +nrysdjvlo +lydosnjvr +sjylnrodv +nyjrdvols + +vjrclek +vuljbckqfteds +cihklevgj + +rqbvni +flxuv + +gpywjntefcm +cnoaetmyjpgd +mpeynjcg +rbnpymcgexzhqji +cjumnegpwy + +h +c +h +h +h + +hzrqoybi +wynqkcmlduae +zqybh + +itnoq +rtinoq +tqhlin +imtbq + +moetialxhyqkznjwscgdpv +qwcagyzjvtoednmixlsphk +kxqajsiotvnlhcgwdzympe +ynejvlhsopakcmzdtxgiqw +yaxdpiqktjsozmgvncewlh + +qyrlgevbzsutwmxjhindcaokp +vtdjrqaocngwehspylbukmz + +aev +ve +a +byqg + +ycfvpamkhliot +wmckyrthxusfqiedjlaz +atcmhkboiylf + +sfqkmlhdc +mlhkscqdf +fcqsdhmlk +kqfhcdmsl +kqslzfdmhoc + +dgveoupsmhabyfkrztclj +vedwkmptusfhzaygqolcr + +tfoaevgbi +yfu +sfwqh +kpfxlj +dufl + +mlwhb +jvgtzp + +jzp +szwipyj + +larkxcqsbpeuiv +fharycntpzi + +lsympnqboj +nlpjmobqys +njoslbqpym +qsnodjtlmbyp +lnosbmpjyq + +jpovmflgikracyqunwthe +hawgrlcyvpnmkjeofuit +pltojwgrcfkhaneuivmy +klaoumwtfgejnhcripvy + +hmvxakwrtundglz +mkacvnhwrlxbzdug + +asvoizlprxjefycmthugnqw +zohmwpxdaiyvrfnulecgjtq + +natmhjdg +zctmdalg +vbiamufq + +vhxbajdokyn +dkvxonyhmab +hnexvbdaoyk + +gyjfnm +gmfnyj +jfygmn + +bjqn +bnqj +nqbj +qbnj + +hawjpsxeolr +rwlqenjhpsobgamx + +tovhgbwjdckpqn +ifzl +mleysuzrax + +sky +ky +mgfpwk + +zx +h +ict +gz + +zsjitm +lijor +jmwabyit + +nbzmj +abvfwrdn +csnbm + +hdqyski +ywvclhdsq +hsqbyxd + +jmt +mtsuhxjzkla + +fijlt +psjbtfieg +zqcohan + +gwnfpqb +pnwf +wpnf +wfnp +nwpf + +irgkabh +khgibar +akgirhb + +emonkbuycsz +noyzscmuk + +ejsqzftblax +scomdrxgibw + +afdjtiyvgqorsmnhubweplkxzc +fmznscjliqbyevhxwoktdugrap + +cgyxhiubmptdokesrjzlafq +pmdqvjuygbeslzatokxfr + +hyawt +wh +wh +wh + +vojux +ei +nq + +pvnjgmxksluctq +zfrdoa + +d +z +x +xd +d + +dwpscgknx +kwxc +xcwk +wxkci + +qipb +ildp +ziacpr +pbdi + +x +xb +x +x +x + +fenqcuwi +niczkhxeq +mcejqnxit +iycrngpqel + +uyj +yju +yuj +ujy + +b +bd + +e +e +e +e +fei + +tncbizahupsdwlog +oclbqdskwnaymx +atloswndebjcriv + +msojaeqnphzylgdbc +ebmzlphcgyjoadq + +apehlz +tozlmeba +ekyflaz + +qpnhfgjdzymlctkrb +slmbhkqpfyngzj +mlpqjyzbghnkf +nmzghjyblkfpq +bngqfhymkzpjl + +apgvczsfuybdiklq +gmhxdubftesavzlpjcqyi +aswyzugkicpfvqldb +oylsvgbcnuqzdafpi + +ncrkh +nhkrc +kncrh +hkrnc +hcknr + +nvrjtzamfuhqxp +ebdigavktsywflmco + +evrabhcmxkonl +vlcxmbnkrheo +cxloknrmeb +pkclmerbonx +lbkoryunexmc + +zdmhgatfpqcwrsu +beravdksgly + +wfo +fw +bfwh + +kpzlhbtjfiw +fjwpzhkbli +bfhpkjzwil +pjwoikhzlbf + +yworad +adsyr + +atqhenzlswmufgkojrb +lfoanzusbhgtjkyeqwm +nsgajlhqeobkfztwmu +mlcisaozwkhetnqfjgbdu + +xhqkmdutfzasylbw +hqubgdwxlztkmsyfae +pfhuacyitsqxmbwlzkd + +tqbpnosumlj +jdtpqbyoli +ulobptqjn +tfqlvwzopbajc +jxpeobqtulis + +awg +wag +awgk + +czbledy +avgwqu + +kf +f + +bh +gm +tj + +l +dm +lspg +zfeauxn +qt + +zwep +pwze +wpze +ewzp + +jptngbzhk +tgnkrpzxdjh +ghjznktp + +ofrbuieszcakqt +snomauqcerdpbt + +nbjxhyvtpl +tbxzgovhjy +yhbtxjovizk +bytvxhj + +pibogfjn +fogbinjl +bonqgfji +banjisugcmwfvoe +iobghfjn + +tz +t +ta + +qnraf +qrxf +qfr +ezroqf + +iachtzfemxwbs +gzsfycehaqwkm +twmhzcsbrafe +zmafhcewxs + +gqoznmrlxvudwehf +uvzrohmlgdnwqxef +frgvqedxohmlnuwz +fqledmnvwghruzxo + +rxcvnyjbqgm +cjygxmrvbqn +vuybxmkcrnqg +ipgrxvnobcmeyq +yvqnbmrgcx + +ay +ay +ay +ya +ay + +np +xa +ba + +ibrcmtxqvyaed +vycdaeitmbxqr +dvqiytmcxabre +dvbaicqeyxrtm + +hgzd +zdlho +zhd +zdh +zdh + +hcipn +zchnipb + +rwptzv +ymoedzaltsc + +ubdwmjecyqxltipzfn +mvfulhydqewjtzpnci + +najhotpuyrsxdlqbk +wxetrjaobduqpznklsyc + +jwcgbxoipeyfmkvhr +cmblwpoudxteyfvnhkrg +qzseparbjxvykfocghwm +eqvwroycibpxmfghk + +xwedaqgiznj +khubyeatir +avgncxeljzmsoif + +zf +f +f +htbcr + +st +kmr +rm +tvebzs +cig + +gdij +gvi +jhgies + +fduipkhlz +izdplfu + +pdculaojmwsqebvgh +zmhjsdwlefgoucrpvy + +bzwagcde +uhsqpmloni + +mf +f +ltfn + +xlhmpdyieob +mlxpyhideo +mixkldhpoye + +lwthjcvgnmxuypos +vixqojmy +evrxmoyj +ymkajoxv +zfvjdymaxo + +voh +h + +onqdyf +qmnf +wiktfqsajgn + +poaheifqcl +plqcoifaeh +paegritwhnvlofzucjd +ipeohaflc +oielhpafcs + +tzvenpcqxisbjhmgkrw +xvnckipbhszegfwm +pkchgoxbavsmewizn +csvzekmhyngipxbaw + +wgim +ixaw +wixka +iyownrps +iwk + +caofbkuznsiqrtvpjyg +pyroglzcjtfub +pcfjryzgtubmo + +junoecpfwmhtxkayziqvgrl +zqigynpcvufwohjlemtkxar +oeavkrhizljumtgfpxwcqny +tyizfjnoqcbgxarepklvwsudmh + +itvqcxburwo +idtvacoqbex +btvifjxcqyo +ojikvqcltbx + +bromkxwdfq +dkfrbwqamxo +korxywiqfdmb + +smyfvkg +xmkgvsf +kgnsfvem +mkfvgs + +pdxa +mqgx +lxsezkbjic +xy +wfprx + +ynhepftgslro +wytlefgosarn +ysgtndocwlrf +lrgnfoswtya +zlibfutmrkxsvjnqgyo + +kht +tkh +htk +hkt + +pcdxhjnovlusitq +dbtrjizv + +bjhnkitaegvrsx +nxghvbestra +bwetgsarvhxdn + +oleswygxbnfmtzkjuar +xuaezbtcwlgmnrofsjy + +hdrgyowbfktavjuqlzm +gtkvfdulwqjzhymabro +rzojgmltbyhafvwdqku + +uxpwqbyr +xpquwyrb +rwxyqubp +rwbyquxp +qxrbyuwp + +kqlwz +rkve +klnf +ucqk + +irqgpjmdk +ctqmvnkfbgj + +dv +dv +dv + +fariyqplzoetb +zykjphxcg + +pytmwqvx +txvpqmdwy +xtyqvwmp +wvqmxypt + +oekfrmuatwl +axsvpcjkgqdzhiby + +fnyuqsihvmatgwxlr +ufjmioapebxnqydhtk + +tpskxdqc +kxsqcdtp +ytqsdkxcp +cxpqdtks +tcxpsdqk + +soivtnhezljymw +mhcyptneuvob +nfetymhgdavo +vnbhmxetaoy + +sqruavzncixgbpof +vioanzfgreuxqc +acetqngfrxoziuv +gqcfmxvrnzaoliju + +earxh +gmizfq + +tejlcvwgxpdbhsorufmiz +oftmijdscxlvzbuwpehgry +cvnksdzamhgbporwtufiljxe + +wdmgbxyihk +khmxyidwg +hikxwdlpygm + +nzcf +cz + +vhfecblgmowtqxpaskyi +xwgztblrjiacpfmheksvy + +pemi +e +e +ze +e + +fxwy +xyfw +yzxfw + +kshfqrlmyea +xsqboukan + +vknp +levn +pknv + +vqsdyhzwei +poijeyhscazl + +ryf +ofit +txw +jqvlhmbgeuznps + +qhzycdugf +cuhqdzfg +fghuqzcd + +emqngdv +meaqh +ezqmax +exqm +qmaze + +jgrnahfyvotupkxziqsdmceblw +ntughqlksexifdraozvmbcpwy + +imt +tim + +pthzw +tpnwhz +piztlw +tzpw + +xpuh +xbqrvys +lxw + +cpidsmqk +rkpcdmisq +pcdkqsmi +pmskqdic + +thxqby +bqxohty +qybhxt +yqtbxh +yqbxth + +qkplixrshe +jndbsraivm +zrgelsyit +lfsri + +zqr +zrtc +rz + +deabt +ueatgs +hwiqknj +ulxb +tdm + +sfpwq +phsqw +kpsqw + +guhmbl +gmuhb +mhndpub +yuihmgcb +uismhby + +qioblnp +olnqbip +loqbinp + +rqc +qcr +crqay +rqc + +z +z +z +z +zp + +ljo +lcbajeorg +jlox +oljx + +loasmqxdy +mqld +lvmdqb + +iq +qi + +filjwt +fwitlj +fliwtj +wtljif +tjwfil + +dx +xd +dx +xnd +xd + +vzo +zov + +ogbwntefukpch +ebwnsfkgupocht +noctepwgfhkub +wfqkugnpodjthbce + +genbzqkvspy +brkwjevpqsczn +fdxnvtzsobqiekau + +nxwb +wnj + +imfvncxbhlrdzgok +vbfdakgnhlcrixmo +cnzbholrkvdifmxg +ucoklqmbdxnvigrhf +blndpvmhkirgcxfo + +hquykcmexvza +evnayxkchmzq +jfyxamhqpiwzeokgcvs +ekzdruqamhlbtvxyc + +nk +knwct +pbykwan +dzsegnfqrom +linuwk + +tbc +tqbe +tcub + +lzxybkftrhis +ylrxhdasutjzncipgbfw +xktyhfizlrobqsmv + +sjb +pdkaowvu + +bnhcaqjprkx +ncdrqxbolaijkt +zaxrnksqchybj +cbnaxejqrk + +bteqziwsumofxpvchr +choiepzjxuwtvfrsm +irtuwcsemlpvfzhox +twhximepcsfzorlvgu + +ta +at + +xjdybasehgpm +edaosjpgxhmby +xybgpdjemsha +dmexjpbaslhywg +xpmedyahjbsg + +cbjxvynghstrfluoempdk +idhbtapleufcsrgywnvmox +xohdljfecvupmsgrbytkn +rvleksucfbdymxgotqpnh + +klfewtsaihpxnmogudy +seqdufxypnlikwtogah +ewpohdiknstxugayfl +xwenydkuhfasotlgpij +fignpyousdtkwexalh + +oudzygfimh +xvj + +qbpviwoadmfr +dimbswlpqnh +yzgxbqidwuj + +ismkdvnyzajbuowlpqfr +vjqwufylscopgmkrdabi +rhbwefvqiykupsajolmd +msdqtukoipvfxlyjrabw + +lho +hol +jfolhv + diff --git a/2020/day7.cpp b/2020/day7.cpp new file mode 100644 index 0000000..97991ea --- /dev/null +++ b/2020/day7.cpp @@ -0,0 +1,104 @@ +/******************************************************************************* + * + * Copyright (c) 2020 Gnarwhal + * + * ----------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files(the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *******************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +#include "types.hpp" + +struct SubBag { std::string type; u32 count; }; + +auto find_bag(const std::string & line, usize & index, SubBag & new_bag) -> bool { + while (++index <= line.size() && (line[index] < '0' || line[index] > '9')); + if (index >= line.size()) { + return false; + } + auto end = line.find(" ", index); + auto count = std::stoi(line.substr(index, end - index)); + index = end + 1; + end = line.find("bag", index); + new_bag = SubBag{ line.substr(index, end - index - 1), u32(count) }; + index = end; + return true; +} + +struct Edges{ std::vector from; std::vector to; }; + +auto count_to(const std::string & search, std::map & map) -> usize { + auto counted = 1; + for (auto & bag : map[search].to) { + counted += bag.count * count_to(bag.type, map); + } + return counted; +} + +auto main(i32 argc, char * argv[]) -> i32 { + auto bag_graph = std::map(); + { + auto line = std::string(); + auto file = std::ifstream("day7.input"); + while (getline(file, line)) { + auto find = line.find("bag") - 1; + auto bag_type = line.substr(0, line.find("bag") - 1); + if (!bag_graph.contains(bag_type)) { + bag_graph.insert_or_assign(bag_type, Edges()); + } + + auto new_bag = SubBag(); + while (find_bag(line, find, new_bag)) { + if (!bag_graph.contains(new_bag.type)) { + bag_graph.insert_or_assign(new_bag.type, Edges()); + } + bag_graph[new_bag.type].from.push_back(bag_type); + bag_graph[bag_type].to.push_back(new_bag); + } + } + } + + auto seen = std::set(); + auto search = std::stack(); + search.push("shiny gold"); + while (search.size() > 0) { + auto current = search.top(); + search.pop(); + for (const auto & bag_type : bag_graph[current].from) { + if (!seen.contains(bag_type)) { + search.push(bag_type); + seen.insert(bag_type); + } + } + } + std::cout << seen.size() << std::endl; + + std::cout << (count_to("shiny gold", bag_graph) - 1) << std::endl; + + return 0; +} diff --git a/2020/day7.input b/2020/day7.input new file mode 100644 index 0000000..4a770f4 --- /dev/null +++ b/2020/day7.input @@ -0,0 +1,594 @@ +faded plum bags contain 5 wavy cyan bags. +dull aqua bags contain 4 dark fuchsia bags, 1 shiny purple bag. +dotted olive bags contain 1 striped gray bag. +vibrant brown bags contain 4 dark tan bags, 4 mirrored gray bags. +shiny black bags contain 3 mirrored black bags. +dull bronze bags contain 2 plaid aqua bags, 4 shiny magenta bags, 2 faded green bags, 3 dotted gold bags. +wavy plum bags contain 5 dim indigo bags. +drab brown bags contain 5 clear fuchsia bags. +vibrant maroon bags contain 3 shiny coral bags, 1 dim indigo bag, 4 muted crimson bags, 5 clear black bags. +posh magenta bags contain no other bags. +dull brown bags contain 3 dim violet bags, 3 striped silver bags, 1 shiny purple bag. +pale gray bags contain 3 plaid magenta bags, 3 clear teal bags, 3 pale white bags. +plaid turquoise bags contain 4 bright orange bags, 5 drab white bags, 4 dotted coral bags. +dotted silver bags contain 2 pale silver bags, 4 dark teal bags, 5 posh gold bags, 1 bright orange bag. +light red bags contain 1 dark violet bag, 1 mirrored coral bag, 3 drab tan bags, 4 muted olive bags. +shiny brown bags contain 5 vibrant lavender bags, 4 dark lavender bags. +plaid plum bags contain 1 faded green bag. +vibrant lavender bags contain 4 bright chartreuse bags, 3 dark teal bags, 4 muted aqua bags. +muted yellow bags contain 5 posh yellow bags, 3 dim olive bags, 1 light cyan bag, 1 plaid gray bag. +light beige bags contain 2 wavy orange bags, 5 vibrant salmon bags, 2 dim brown bags. +muted indigo bags contain 3 dim brown bags, 3 drab brown bags. +dim bronze bags contain 4 dim black bags, 5 wavy turquoise bags, 5 bright violet bags, 2 dark bronze bags. +shiny teal bags contain 5 plaid chartreuse bags. +pale aqua bags contain 2 striped lime bags, 4 dark turquoise bags, 3 dull tomato bags, 2 mirrored lavender bags. +plaid violet bags contain 2 light olive bags. +dotted maroon bags contain 5 striped maroon bags, 2 shiny turquoise bags, 2 dull gold bags, 4 pale olive bags. +dim chartreuse bags contain 5 striped plum bags. +plaid gold bags contain 1 striped green bag, 3 plaid coral bags, 4 dotted violet bags. +faded tomato bags contain 2 dark indigo bags. +posh plum bags contain 1 wavy chartreuse bag, 4 vibrant blue bags. +drab bronze bags contain 2 mirrored gray bags, 3 vibrant plum bags. +muted blue bags contain 1 bright brown bag, 2 pale coral bags, 5 plaid purple bags, 4 dim lavender bags. +striped indigo bags contain 5 dark salmon bags. +shiny tan bags contain 2 faded bronze bags, 3 mirrored lavender bags, 2 mirrored cyan bags. +dim red bags contain 5 dull salmon bags, 3 dim purple bags, 2 striped crimson bags. +plaid gray bags contain 5 bright violet bags, 4 vibrant aqua bags, 4 dull tomato bags. +dotted white bags contain 1 drab brown bag, 5 light brown bags. +plaid tan bags contain 3 striped teal bags, 2 dotted brown bags. +vibrant black bags contain 3 plaid tan bags, 4 muted white bags, 4 drab orange bags, 5 muted aqua bags. +drab purple bags contain 5 muted violet bags, 2 vibrant blue bags, 4 pale olive bags. +mirrored beige bags contain 1 plaid gray bag, 2 mirrored lime bags, 3 dark brown bags. +vibrant olive bags contain 5 shiny indigo bags. +drab green bags contain 1 muted violet bag. +faded turquoise bags contain 2 striped brown bags, 3 vibrant white bags, 1 dull lavender bag, 5 bright olive bags. +shiny maroon bags contain 1 dim bronze bag. +dull white bags contain 1 muted salmon bag, 4 dim olive bags, 5 drab white bags, 1 dotted teal bag. +dim white bags contain 3 mirrored lavender bags. +clear beige bags contain 5 shiny cyan bags, 3 clear chartreuse bags. +plaid tomato bags contain 5 muted beige bags. +bright teal bags contain 5 shiny gold bags, 4 clear beige bags, 5 vibrant chartreuse bags. +dotted salmon bags contain 1 clear fuchsia bag, 2 muted maroon bags, 4 posh yellow bags, 1 drab chartreuse bag. +light gold bags contain 4 light maroon bags. +faded cyan bags contain 2 posh magenta bags, 2 dark violet bags. +drab cyan bags contain 5 faded purple bags, 4 striped crimson bags, 1 shiny maroon bag, 4 drab tomato bags. +dotted black bags contain 3 striped turquoise bags, 4 dark tan bags, 4 vibrant lavender bags. +faded purple bags contain 4 dull purple bags. +dim violet bags contain 2 clear blue bags. +wavy gray bags contain 4 muted crimson bags, 2 mirrored silver bags, 5 vibrant chartreuse bags. +posh tan bags contain 4 drab tan bags, 3 muted crimson bags, 2 striped crimson bags, 2 plaid fuchsia bags. +mirrored magenta bags contain 5 pale bronze bags. +plaid brown bags contain 1 bright chartreuse bag. +drab orange bags contain 4 drab teal bags, 1 dark bronze bag, 2 clear purple bags. +dim green bags contain 5 dull maroon bags, 1 dull green bag. +faded teal bags contain 2 bright yellow bags, 2 posh red bags, 2 posh indigo bags. +dim gray bags contain 4 wavy blue bags, 2 shiny maroon bags, 1 pale cyan bag. +light crimson bags contain 1 wavy plum bag, 3 muted magenta bags, 3 plaid aqua bags, 2 striped chartreuse bags. +clear white bags contain 2 posh magenta bags, 5 bright white bags, 5 drab bronze bags, 3 vibrant beige bags. +drab magenta bags contain 4 pale olive bags. +plaid silver bags contain 4 bright violet bags, 3 dim brown bags, 1 dark teal bag. +bright bronze bags contain 4 posh white bags, 3 dull salmon bags. +drab maroon bags contain 3 clear black bags, 2 dotted orange bags. +dark fuchsia bags contain 3 faded chartreuse bags, 5 clear green bags, 4 bright brown bags. +vibrant salmon bags contain 1 bright red bag, 5 clear black bags, 2 clear green bags. +shiny crimson bags contain 4 muted fuchsia bags, 2 plaid red bags, 3 clear green bags. +plaid crimson bags contain 4 bright gold bags, 2 clear turquoise bags, 3 faded magenta bags. +dim turquoise bags contain 3 drab brown bags, 5 plaid cyan bags, 3 plaid teal bags, 5 shiny silver bags. +clear crimson bags contain 3 plaid blue bags, 2 drab tomato bags, 2 dull cyan bags, 3 mirrored fuchsia bags. +pale tomato bags contain 1 dull yellow bag, 3 muted aqua bags. +dim orange bags contain 1 posh magenta bag, 2 wavy gray bags, 5 faded indigo bags. +mirrored orange bags contain 1 posh bronze bag, 2 faded white bags, 1 light orange bag, 2 posh red bags. +striped turquoise bags contain 5 muted salmon bags, 5 dark white bags, 1 mirrored purple bag, 3 pale chartreuse bags. +dotted coral bags contain 3 bright brown bags, 2 posh yellow bags, 3 drab maroon bags. +wavy maroon bags contain 2 clear lime bags. +mirrored indigo bags contain 1 mirrored cyan bag, 1 posh plum bag, 2 plaid silver bags. +wavy indigo bags contain 5 dark violet bags, 5 drab black bags, 4 dark orange bags, 5 muted green bags. +striped tomato bags contain 4 dark indigo bags, 5 light lavender bags. +pale lime bags contain 2 bright orange bags. +muted maroon bags contain 2 bright violet bags, 1 shiny coral bag, 1 posh gray bag. +drab lavender bags contain 1 muted magenta bag. +bright fuchsia bags contain 1 striped lime bag. +wavy beige bags contain 2 bright brown bags, 1 pale black bag, 1 drab tomato bag, 4 vibrant blue bags. +shiny olive bags contain 2 dim teal bags, 1 mirrored cyan bag, 4 dim yellow bags, 4 muted aqua bags. +posh coral bags contain no other bags. +dark green bags contain 2 posh brown bags, 2 muted white bags, 4 bright fuchsia bags. +shiny green bags contain 1 faded crimson bag, 3 striped purple bags, 4 shiny salmon bags, 2 dark bronze bags. +clear coral bags contain no other bags. +dull salmon bags contain 1 muted white bag. +dark lavender bags contain 2 plaid gray bags, 4 muted olive bags. +bright silver bags contain 5 pale black bags. +posh green bags contain 5 muted olive bags, 4 dotted crimson bags, 4 dotted brown bags. +dotted fuchsia bags contain 5 shiny chartreuse bags, 1 dotted coral bag, 1 shiny cyan bag. +dim fuchsia bags contain 1 striped orange bag, 1 clear crimson bag. +dotted cyan bags contain 5 muted olive bags, 3 shiny white bags. +dark beige bags contain 4 light teal bags, 4 drab teal bags, 5 wavy beige bags. +striped magenta bags contain 5 plaid purple bags, 3 dotted crimson bags, 2 dull tomato bags. +striped blue bags contain 3 dim aqua bags. +light silver bags contain 3 shiny green bags, 2 vibrant black bags, 1 wavy turquoise bag, 3 faded bronze bags. +pale indigo bags contain 4 pale silver bags, 3 dotted tomato bags, 1 dark violet bag, 3 clear lime bags. +mirrored turquoise bags contain 1 pale salmon bag, 2 dotted crimson bags, 1 drab tomato bag, 2 muted green bags. +striped beige bags contain 3 dotted tomato bags, 4 vibrant purple bags, 2 plaid tomato bags, 4 dark salmon bags. +pale silver bags contain 5 dark lavender bags, 4 drab tan bags, 5 clear yellow bags. +dark lime bags contain 3 pale aqua bags, 5 posh green bags. +faded coral bags contain 3 dull tomato bags, 4 dark bronze bags, 3 drab tomato bags, 2 bright white bags. +mirrored lavender bags contain 3 mirrored cyan bags. +bright crimson bags contain 2 mirrored silver bags. +striped gray bags contain 3 dotted coral bags, 4 muted maroon bags, 4 dark teal bags, 5 pale bronze bags. +dotted magenta bags contain 2 dim teal bags, 2 wavy turquoise bags, 5 dull turquoise bags. +posh white bags contain 4 drab tomato bags, 2 muted aqua bags. +striped red bags contain 2 plaid blue bags, 1 light plum bag, 3 bright white bags. +pale white bags contain 1 light purple bag. +shiny coral bags contain no other bags. +dark magenta bags contain 4 pale tan bags, 1 posh chartreuse bag, 2 pale yellow bags, 2 pale indigo bags. +light gray bags contain 4 pale green bags, 5 dotted green bags, 4 shiny gray bags. +dim gold bags contain 3 clear violet bags, 5 plaid aqua bags, 2 bright tomato bags, 2 wavy teal bags. +dim crimson bags contain 4 muted blue bags, 2 light tan bags. +wavy tan bags contain 1 posh plum bag, 3 mirrored gray bags, 1 muted purple bag. +posh brown bags contain 4 mirrored black bags. +bright plum bags contain 3 vibrant plum bags, 3 mirrored crimson bags. +faded black bags contain 1 pale lime bag, 2 pale tomato bags. +mirrored yellow bags contain 1 pale aqua bag, 4 dull aqua bags, 4 shiny white bags, 3 clear lime bags. +muted tan bags contain 2 clear brown bags. +drab white bags contain 5 dull coral bags, 2 drab green bags, 4 wavy tomato bags, 5 mirrored cyan bags. +dull black bags contain 4 vibrant tan bags, 1 shiny chartreuse bag, 5 pale gold bags. +posh maroon bags contain 5 dark coral bags, 5 faded yellow bags, 2 light lavender bags, 2 wavy teal bags. +drab coral bags contain 4 posh chartreuse bags, 2 dim red bags. +posh indigo bags contain 2 plaid brown bags, 4 muted green bags. +drab aqua bags contain 2 pale magenta bags, 2 posh orange bags. +drab crimson bags contain 2 pale bronze bags, 4 dotted blue bags, 2 dim silver bags. +drab silver bags contain 5 clear blue bags, 4 pale bronze bags. +clear salmon bags contain 2 pale aqua bags, 1 plaid gray bag, 1 clear coral bag. +wavy chartreuse bags contain no other bags. +dull plum bags contain 3 plaid gray bags, 3 plaid aqua bags, 2 mirrored beige bags, 2 wavy magenta bags. +faded gray bags contain 2 dull cyan bags, 3 light lime bags, 3 bright lavender bags, 5 wavy plum bags. +striped teal bags contain 4 drab maroon bags. +clear lavender bags contain 3 clear coral bags, 5 bright crimson bags, 5 drab brown bags, 2 dim indigo bags. +mirrored maroon bags contain 1 clear gray bag, 3 shiny salmon bags, 3 mirrored violet bags. +muted turquoise bags contain 2 drab teal bags, 2 plaid plum bags, 4 plaid coral bags, 2 wavy chartreuse bags. +dark white bags contain 4 bright fuchsia bags, 1 dull white bag, 3 shiny indigo bags, 3 dim white bags. +drab red bags contain 3 dotted teal bags, 2 striped purple bags. +muted teal bags contain 3 dark violet bags, 4 plaid chartreuse bags, 2 pale crimson bags. +wavy red bags contain 2 clear crimson bags. +striped olive bags contain 2 mirrored lavender bags. +dull teal bags contain 4 pale teal bags, 5 pale violet bags, 2 drab white bags. +light black bags contain 1 dark red bag, 2 plaid tan bags. +clear orange bags contain 5 bright cyan bags. +pale yellow bags contain 2 bright lavender bags. +posh cyan bags contain 4 clear coral bags. +drab tomato bags contain 4 vibrant blue bags, 5 faded beige bags, 3 clear coral bags, 2 mirrored white bags. +pale orange bags contain 2 light aqua bags. +dull tomato bags contain 5 plaid aqua bags, 2 posh magenta bags, 3 vibrant aqua bags. +pale turquoise bags contain 1 pale coral bag, 3 dim teal bags. +plaid maroon bags contain 5 posh maroon bags. +vibrant beige bags contain 5 dull coral bags. +bright purple bags contain 2 vibrant salmon bags, 5 dotted purple bags, 5 clear silver bags. +dull coral bags contain 4 vibrant aqua bags, 3 dotted brown bags, 4 shiny coral bags. +drab gray bags contain 4 vibrant lavender bags. +dull lavender bags contain 3 vibrant lavender bags, 1 posh red bag, 4 drab tan bags, 3 light purple bags. +striped maroon bags contain 3 bright silver bags. +mirrored silver bags contain 5 clear blue bags, 3 posh magenta bags, 2 bright brown bags. +faded yellow bags contain 2 muted maroon bags. +striped purple bags contain 2 dotted yellow bags, 1 clear cyan bag, 2 dark teal bags. +clear gray bags contain 5 dim black bags, 1 faded green bag, 5 muted crimson bags. +plaid cyan bags contain 2 dark teal bags, 1 pale lime bag, 1 wavy beige bag. +bright orange bags contain 5 mirrored brown bags, 2 dotted gold bags. +dotted turquoise bags contain 3 plaid gray bags, 3 clear chartreuse bags. +vibrant turquoise bags contain 1 muted brown bag, 3 dim purple bags, 1 posh gray bag, 5 pale bronze bags. +striped lime bags contain 1 shiny gold bag. +light violet bags contain 4 mirrored purple bags, 5 clear blue bags. +striped orange bags contain 3 light gold bags, 3 light olive bags, 3 muted crimson bags, 2 pale cyan bags. +drab turquoise bags contain 3 dim magenta bags, 4 pale black bags. +pale salmon bags contain 2 mirrored cyan bags, 4 vibrant blue bags. +shiny yellow bags contain 5 vibrant tomato bags, 3 muted salmon bags, 5 wavy tomato bags. +plaid lime bags contain 2 pale yellow bags, 2 shiny red bags, 3 muted crimson bags, 4 dull green bags. +muted cyan bags contain 4 bright green bags, 5 striped bronze bags, 1 vibrant lavender bag, 4 posh violet bags. +dull cyan bags contain 5 dark lavender bags, 5 drab green bags, 1 bright crimson bag, 4 mirrored silver bags. +pale beige bags contain 3 posh coral bags. +shiny chartreuse bags contain 4 mirrored silver bags. +dark silver bags contain 2 dull turquoise bags, 1 muted maroon bag, 5 vibrant magenta bags. +mirrored violet bags contain 4 dark brown bags. +clear aqua bags contain 2 striped beige bags, 1 dotted indigo bag, 5 faded violet bags, 5 vibrant violet bags. +plaid teal bags contain 3 mirrored lavender bags, 4 posh gray bags. +wavy olive bags contain 3 dull blue bags, 5 bright salmon bags, 5 shiny purple bags. +pale lavender bags contain 4 light purple bags, 2 dotted gray bags, 2 pale plum bags, 3 shiny silver bags. +shiny blue bags contain 2 vibrant white bags, 3 light gold bags, 3 mirrored lavender bags, 1 drab plum bag. +light coral bags contain 4 light teal bags, 1 striped chartreuse bag, 5 dotted chartreuse bags. +pale brown bags contain 2 dim gold bags, 2 clear turquoise bags, 3 bright cyan bags, 4 clear maroon bags. +vibrant tomato bags contain 3 dark brown bags, 1 vibrant blue bag. +dull olive bags contain 5 mirrored yellow bags, 2 shiny cyan bags. +light chartreuse bags contain 2 dull aqua bags, 4 dull brown bags, 1 clear fuchsia bag, 4 bright yellow bags. +posh gray bags contain 4 posh green bags, 1 mirrored gray bag. +bright yellow bags contain 4 pale aqua bags. +bright gold bags contain 3 pale indigo bags, 3 dull crimson bags. +dotted red bags contain 4 pale turquoise bags, 4 muted blue bags, 1 bright bronze bag, 2 light blue bags. +clear brown bags contain 1 mirrored yellow bag. +light plum bags contain 2 bright violet bags. +dim purple bags contain 3 faded chartreuse bags, 5 light teal bags. +dull yellow bags contain 5 muted aqua bags, 3 dotted coral bags, 2 drab maroon bags. +shiny gold bags contain 4 pale black bags, 4 dim violet bags, 3 muted yellow bags. +mirrored crimson bags contain 1 striped teal bag, 5 mirrored cyan bags. +shiny lavender bags contain 4 bright brown bags, 3 bright tan bags, 5 dotted crimson bags, 4 pale black bags. +vibrant cyan bags contain 1 dim yellow bag, 5 bright tan bags. +wavy gold bags contain 2 dark brown bags, 1 dull yellow bag. +dark cyan bags contain 4 dim white bags, 2 mirrored indigo bags, 4 muted white bags, 2 bright white bags. +posh lime bags contain 4 shiny plum bags, 3 plaid fuchsia bags. +posh purple bags contain 3 muted salmon bags. +pale magenta bags contain 1 drab gold bag, 1 dark white bag, 3 posh silver bags. +dim plum bags contain 4 dark chartreuse bags, 4 mirrored lavender bags. +plaid indigo bags contain 2 clear lime bags, 5 dull tomato bags. +dark blue bags contain 1 bright olive bag, 1 dull bronze bag, 1 shiny gold bag. +dull red bags contain 2 wavy teal bags, 3 wavy crimson bags, 1 faded olive bag. +striped yellow bags contain 4 drab salmon bags. +vibrant magenta bags contain 4 light beige bags, 2 dark red bags, 1 plaid magenta bag, 5 dim magenta bags. +plaid red bags contain 2 striped red bags, 4 light plum bags, 3 mirrored silver bags. +wavy orange bags contain 5 vibrant white bags, 1 posh coral bag, 5 muted purple bags, 2 light coral bags. +pale green bags contain 5 pale aqua bags, 1 clear gray bag. +dotted chartreuse bags contain 4 muted violet bags, 5 striped teal bags. +light turquoise bags contain 5 dull turquoise bags, 2 dark aqua bags, 1 dull teal bag. +shiny violet bags contain 2 pale indigo bags. +light white bags contain 3 mirrored indigo bags, 1 faded blue bag, 1 plaid white bag, 1 posh plum bag. +muted beige bags contain 4 drab gold bags. +faded silver bags contain 2 drab white bags, 5 pale white bags, 3 clear lime bags. +faded red bags contain 1 bright turquoise bag, 5 faded coral bags, 2 drab purple bags, 5 bright olive bags. +shiny bronze bags contain 4 plaid purple bags, 5 bright red bags, 1 muted white bag, 2 dull fuchsia bags. +dull gold bags contain 1 dotted orange bag. +muted olive bags contain 1 clear coral bag, 1 posh magenta bag, 2 bright violet bags, 1 wavy chartreuse bag. +dotted bronze bags contain 1 plaid beige bag, 3 clear olive bags, 2 light lime bags, 5 dull beige bags. +shiny orange bags contain 5 pale brown bags, 5 clear tomato bags. +wavy salmon bags contain 2 shiny maroon bags. +wavy crimson bags contain 5 bright violet bags, 3 plaid violet bags. +bright coral bags contain 1 dull bronze bag, 5 dotted gold bags, 1 posh gray bag. +dotted crimson bags contain 2 posh magenta bags, 4 mirrored white bags. +bright violet bags contain no other bags. +drab blue bags contain 5 shiny gold bags, 1 shiny brown bag, 4 dark silver bags. +posh salmon bags contain 4 dim purple bags, 1 striped lime bag, 1 muted gray bag, 2 drab gold bags. +dim coral bags contain 3 dark red bags, 2 faded crimson bags. +dark aqua bags contain 3 dotted salmon bags, 4 pale olive bags, 1 vibrant aqua bag, 5 dull lavender bags. +dark orange bags contain 4 mirrored teal bags, 5 clear salmon bags. +vibrant red bags contain 3 vibrant blue bags. +muted lime bags contain 1 dull silver bag. +clear tan bags contain 2 striped beige bags, 1 posh coral bag, 1 wavy teal bag, 2 faded plum bags. +vibrant coral bags contain 2 faded blue bags, 4 bright turquoise bags. +dark olive bags contain 2 dark indigo bags. +dotted blue bags contain 5 faded cyan bags, 4 striped aqua bags, 4 dotted gold bags. +bright maroon bags contain 1 dark bronze bag, 3 vibrant aqua bags, 4 dim magenta bags, 3 clear crimson bags. +bright cyan bags contain 2 wavy tomato bags. +plaid olive bags contain 3 striped indigo bags, 5 dim purple bags, 3 striped bronze bags, 2 light teal bags. +plaid chartreuse bags contain 3 plaid yellow bags, 1 faded brown bag, 1 vibrant tan bag, 4 wavy fuchsia bags. +dull maroon bags contain 3 muted yellow bags. +light fuchsia bags contain 5 drab maroon bags, 5 muted silver bags. +dull orange bags contain 4 dim indigo bags, 4 posh beige bags, 1 bright red bag. +dull blue bags contain 5 wavy yellow bags, 4 posh gray bags. +plaid yellow bags contain 1 bright fuchsia bag, 1 faded beige bag, 1 wavy beige bag, 4 light green bags. +clear black bags contain 1 dull tomato bag. +muted coral bags contain 5 drab indigo bags. +plaid magenta bags contain 3 posh salmon bags. +clear tomato bags contain 5 dotted brown bags, 3 dim tomato bags, 3 drab brown bags. +clear yellow bags contain 3 clear black bags, 2 mirrored black bags. +dark gray bags contain 5 light bronze bags, 4 dotted coral bags, 4 dim chartreuse bags. +light magenta bags contain 4 wavy turquoise bags, 1 mirrored green bag, 2 plaid chartreuse bags. +shiny indigo bags contain 1 bright silver bag, 2 pale tomato bags, 4 light teal bags, 4 posh coral bags. +muted gray bags contain 3 faded beige bags, 1 dark teal bag, 3 muted violet bags, 3 muted white bags. +wavy lavender bags contain 1 clear chartreuse bag, 2 clear maroon bags, 5 dull plum bags. +faded olive bags contain 4 mirrored yellow bags, 4 vibrant tomato bags, 5 muted olive bags. +muted crimson bags contain 1 mirrored gray bag, 4 dim violet bags. +drab chartreuse bags contain 1 pale olive bag, 1 vibrant plum bag. +wavy cyan bags contain 2 mirrored coral bags. +mirrored plum bags contain 3 bright turquoise bags, 3 dark beige bags, 4 mirrored beige bags. +plaid lavender bags contain 1 drab white bag. +muted gold bags contain 1 clear black bag, 2 light orange bags, 4 dotted red bags, 4 dull silver bags. +faded bronze bags contain 4 posh plum bags. +clear turquoise bags contain 1 light gold bag, 1 clear beige bag, 2 striped chartreuse bags. +vibrant gray bags contain 1 plaid white bag. +bright tan bags contain 3 drab silver bags, 2 faded yellow bags, 2 bright green bags. +pale bronze bags contain 5 posh coral bags, 4 clear coral bags, 1 dotted orange bag, 4 wavy chartreuse bags. +clear plum bags contain 1 dim plum bag, 4 light gold bags. +posh turquoise bags contain 3 wavy bronze bags, 4 shiny purple bags. +posh teal bags contain 2 striped magenta bags, 3 dark magenta bags, 5 faded silver bags, 5 mirrored chartreuse bags. +dim yellow bags contain 4 pale bronze bags, 3 shiny tan bags. +faded lavender bags contain 3 dull white bags, 3 striped teal bags. +wavy magenta bags contain 2 pale aqua bags, 4 shiny indigo bags. +dim brown bags contain 2 bright brown bags, 3 striped chartreuse bags, 5 dull purple bags, 1 light cyan bag. +light lime bags contain 5 clear crimson bags, 4 plaid indigo bags, 1 pale silver bag. +striped silver bags contain 3 posh green bags, 3 muted violet bags, 1 drab green bag. +bright brown bags contain no other bags. +vibrant fuchsia bags contain 4 dull olive bags, 2 mirrored gold bags, 3 mirrored bronze bags, 1 posh crimson bag. +plaid purple bags contain 3 faded beige bags, 1 drab green bag, 2 striped chartreuse bags. +wavy violet bags contain 2 vibrant gray bags, 5 wavy fuchsia bags. +dark maroon bags contain 5 pale chartreuse bags, 5 striped brown bags. +pale coral bags contain 3 vibrant plum bags. +dark black bags contain 4 striped salmon bags, 4 dim bronze bags. +plaid bronze bags contain 2 mirrored black bags, 1 drab bronze bag, 4 plaid purple bags, 5 dull tomato bags. +faded orange bags contain 5 plaid indigo bags. +light lavender bags contain 2 shiny magenta bags, 5 dim lavender bags, 1 dotted crimson bag. +dull chartreuse bags contain 4 clear lime bags. +dark gold bags contain 4 light magenta bags. +dim black bags contain 4 shiny silver bags, 1 dull tomato bag. +plaid salmon bags contain 3 light magenta bags, 4 dull fuchsia bags, 2 striped salmon bags. +vibrant bronze bags contain 5 mirrored white bags, 1 dull coral bag. +wavy brown bags contain 1 light gold bag, 4 drab purple bags, 3 muted violet bags, 4 muted fuchsia bags. +dotted lavender bags contain 4 dotted indigo bags, 2 dull lavender bags. +dotted gold bags contain 1 posh magenta bag, 2 posh yellow bags. +faded brown bags contain 4 muted blue bags, 3 wavy teal bags. +light yellow bags contain 3 clear black bags, 1 dotted crimson bag. +striped salmon bags contain 1 dull yellow bag, 5 mirrored gray bags, 5 light lavender bags, 5 mirrored brown bags. +light blue bags contain 5 mirrored purple bags, 3 dim violet bags, 2 pale tomato bags. +faded gold bags contain 3 plaid gray bags. +shiny aqua bags contain 1 striped crimson bag, 5 pale black bags. +shiny lime bags contain 4 dark green bags. +vibrant tan bags contain 3 clear silver bags, 3 pale white bags. +vibrant aqua bags contain no other bags. +vibrant teal bags contain 3 wavy tan bags. +light maroon bags contain 3 vibrant silver bags. +faded crimson bags contain 3 plaid red bags. +light teal bags contain 2 dark teal bags, 1 faded beige bag, 4 dull cyan bags. +mirrored coral bags contain 2 vibrant plum bags. +muted black bags contain 2 drab magenta bags, 1 mirrored gray bag, 4 drab tan bags, 1 dim indigo bag. +striped gold bags contain 1 dark lavender bag, 4 drab brown bags, 2 bright silver bags, 2 striped teal bags. +light purple bags contain 3 posh gray bags. +dull silver bags contain 2 clear chartreuse bags, 3 plaid silver bags, 1 drab salmon bag, 2 wavy teal bags. +clear bronze bags contain 4 dull red bags. +wavy yellow bags contain 3 dull tomato bags, 2 posh green bags, 4 plaid aqua bags, 2 faded purple bags. +muted purple bags contain 5 pale black bags, 2 muted salmon bags, 2 muted yellow bags. +plaid aqua bags contain no other bags. +drab plum bags contain 3 drab turquoise bags. +muted orange bags contain 1 faded blue bag, 5 plaid brown bags, 4 mirrored chartreuse bags. +dim silver bags contain 4 dark fuchsia bags, 2 clear cyan bags, 2 dark green bags, 4 dotted silver bags. +pale tan bags contain 5 shiny silver bags, 5 drab indigo bags. +wavy tomato bags contain 4 clear black bags, 4 plaid gray bags. +posh bronze bags contain 4 drab green bags. +clear blue bags contain 3 bright brown bags, 5 dull tomato bags, 1 clear black bag, 5 bright violet bags. +striped plum bags contain 4 plaid yellow bags, 3 dark teal bags, 2 mirrored lavender bags, 1 dotted salmon bag. +muted salmon bags contain 1 dull cyan bag, 2 clear coral bags, 1 posh coral bag. +light aqua bags contain 4 clear maroon bags, 4 striped black bags. +bright blue bags contain 4 drab violet bags, 4 light indigo bags, 3 muted indigo bags. +light brown bags contain 5 striped lavender bags. +light salmon bags contain 1 drab beige bag, 5 faded orange bags, 4 plaid coral bags, 5 light chartreuse bags. +posh beige bags contain 1 shiny red bag. +dotted orange bags contain 2 dotted brown bags, 3 mirrored silver bags, 1 dull tomato bag. +wavy purple bags contain 1 mirrored green bag, 1 clear maroon bag. +dark coral bags contain 5 bright chartreuse bags, 4 clear lime bags. +dim lime bags contain 3 bright olive bags, 3 dull gold bags. +pale plum bags contain 1 light orange bag, 3 drab orange bags, 5 mirrored purple bags. +dim beige bags contain 5 pale fuchsia bags, 4 mirrored fuchsia bags, 4 plaid teal bags, 1 shiny orange bag. +drab tan bags contain 5 plaid silver bags, 3 muted crimson bags, 1 clear salmon bag. +posh blue bags contain 4 plaid aqua bags, 2 drab salmon bags, 4 pale teal bags, 2 drab gold bags. +drab violet bags contain 3 shiny white bags. +shiny plum bags contain 3 mirrored green bags, 2 dark yellow bags, 3 pale salmon bags. +pale fuchsia bags contain 5 faded violet bags. +clear fuchsia bags contain 2 dark lavender bags, 3 posh green bags. +mirrored lime bags contain 3 light bronze bags. +plaid white bags contain 1 dim lavender bag, 4 dim olive bags, 3 clear yellow bags. +striped violet bags contain 4 plaid plum bags, 3 plaid black bags, 4 pale teal bags, 5 wavy magenta bags. +dark purple bags contain 2 shiny gold bags, 3 faded blue bags. +mirrored blue bags contain 1 drab fuchsia bag, 4 posh white bags, 3 wavy red bags. +pale black bags contain 2 dim olive bags, 5 bright brown bags. +dark brown bags contain 5 dotted purple bags, 2 striped silver bags. +muted lavender bags contain 3 posh brown bags, 2 clear yellow bags, 3 posh coral bags, 1 shiny tan bag. +muted bronze bags contain 1 drab teal bag, 5 drab tomato bags, 1 drab magenta bag, 5 posh maroon bags. +posh violet bags contain 5 bright white bags, 5 vibrant tan bags. +clear green bags contain 3 mirrored silver bags, 2 dotted orange bags. +dotted plum bags contain 3 plaid yellow bags, 1 wavy yellow bag, 1 drab cyan bag. +drab olive bags contain 1 shiny indigo bag. +wavy turquoise bags contain 3 muted yellow bags. +dark violet bags contain 2 bright crimson bags, 4 bright fuchsia bags, 2 dull blue bags. +posh gold bags contain 3 drab teal bags. +dim cyan bags contain 5 clear olive bags, 4 bright turquoise bags, 1 pale gray bag. +posh red bags contain 1 bright salmon bag. +dull tan bags contain 4 plaid cyan bags. +faded indigo bags contain 3 light gold bags, 5 dotted brown bags, 3 dotted cyan bags, 2 drab teal bags. +clear violet bags contain 1 wavy turquoise bag, 1 vibrant chartreuse bag, 1 dark violet bag, 3 bright bronze bags. +clear indigo bags contain 1 mirrored tan bag, 4 faded indigo bags. +bright turquoise bags contain 1 drab teal bag, 4 dull salmon bags, 4 pale olive bags, 2 faded chartreuse bags. +muted tomato bags contain 1 dark purple bag, 3 striped tan bags. +posh silver bags contain 4 muted gray bags. +mirrored olive bags contain 5 bright lavender bags, 2 clear blue bags, 5 dotted crimson bags, 5 pale black bags. +shiny tomato bags contain 1 mirrored purple bag, 4 posh gold bags, 3 vibrant plum bags. +striped coral bags contain 5 clear orange bags, 3 muted coral bags, 4 bright green bags, 1 clear chartreuse bag. +mirrored chartreuse bags contain 4 clear blue bags. +pale maroon bags contain 1 muted indigo bag. +striped black bags contain 3 striped gray bags, 1 striped lime bag, 4 bright cyan bags, 4 light orange bags. +dim maroon bags contain 4 dull cyan bags. +bright beige bags contain 2 pale fuchsia bags, 5 vibrant beige bags, 1 light lavender bag. +shiny gray bags contain 2 striped lime bags, 1 pale black bag, 4 wavy tomato bags, 2 vibrant brown bags. +drab lime bags contain 5 muted bronze bags, 2 posh indigo bags. +dull gray bags contain 2 dull plum bags, 4 dim white bags, 2 shiny purple bags. +light olive bags contain 4 clear salmon bags, 1 dim indigo bag. +vibrant violet bags contain 5 striped tan bags, 1 pale lime bag, 4 posh plum bags, 4 mirrored black bags. +posh lavender bags contain 4 pale tomato bags. +plaid coral bags contain 3 mirrored olive bags, 2 muted black bags, 3 light plum bags. +vibrant blue bags contain 4 mirrored silver bags. +dim aqua bags contain 5 dim maroon bags. +wavy bronze bags contain 5 wavy plum bags, 1 bright cyan bag, 2 drab chartreuse bags. +muted plum bags contain 3 plaid silver bags, 5 faded black bags, 3 drab maroon bags. +dull turquoise bags contain 4 plaid silver bags. +plaid blue bags contain 3 plaid purple bags. +dotted tan bags contain 5 plaid chartreuse bags, 4 dotted coral bags, 4 posh green bags, 1 striped turquoise bag. +plaid black bags contain 2 drab salmon bags, 5 posh maroon bags. +light cyan bags contain 2 dotted orange bags, 5 drab green bags, 1 bright lavender bag. +dull fuchsia bags contain 2 posh red bags, 4 mirrored beige bags, 2 dull salmon bags, 4 striped purple bags. +dark turquoise bags contain 4 drab tomato bags, 3 dotted chartreuse bags, 5 muted salmon bags, 4 posh magenta bags. +vibrant silver bags contain 3 dark brown bags, 2 wavy beige bags, 5 dull turquoise bags, 2 drab tan bags. +dotted tomato bags contain 3 drab tan bags, 2 striped magenta bags, 5 dim violet bags, 4 wavy tomato bags. +vibrant white bags contain 5 bright crimson bags, 2 mirrored white bags, 5 mirrored indigo bags, 4 wavy teal bags. +shiny fuchsia bags contain 1 pale lime bag. +wavy fuchsia bags contain 4 clear cyan bags. +dotted gray bags contain 3 striped chartreuse bags, 1 dark fuchsia bag. +bright tomato bags contain 4 wavy orange bags, 2 dotted salmon bags, 1 striped gray bag, 3 pale tomato bags. +clear chartreuse bags contain 3 clear purple bags. +dim teal bags contain 3 faded silver bags, 5 vibrant silver bags, 2 wavy fuchsia bags. +dotted yellow bags contain 5 bright bronze bags, 4 drab teal bags. +dark indigo bags contain 5 plaid red bags, 5 dim purple bags. +wavy black bags contain 5 shiny tomato bags, 2 clear gray bags, 4 dim lavender bags, 3 clear blue bags. +striped green bags contain 3 light crimson bags, 5 mirrored cyan bags, 2 mirrored maroon bags, 2 faded yellow bags. +dull lime bags contain 3 pale yellow bags. +faded chartreuse bags contain 2 wavy teal bags, 3 dim olive bags, 2 dull purple bags, 5 vibrant plum bags. +dark yellow bags contain 2 muted brown bags. +plaid beige bags contain 3 pale green bags, 3 bright purple bags, 5 faded black bags, 1 drab brown bag. +faded maroon bags contain 5 drab tomato bags. +muted silver bags contain 3 striped lime bags, 3 dim orange bags, 3 muted aqua bags, 1 plaid black bag. +pale violet bags contain 1 mirrored gray bag, 1 dull gold bag, 1 wavy crimson bag, 1 pale magenta bag. +dim olive bags contain no other bags. +mirrored bronze bags contain 2 drab white bags. +dull green bags contain 1 striped silver bag, 2 bright orange bags, 4 dull yellow bags, 4 dotted chartreuse bags. +bright gray bags contain 1 striped gray bag, 5 dull teal bags, 4 light beige bags, 2 vibrant orange bags. +light indigo bags contain 1 dim maroon bag, 4 dark indigo bags, 1 dark brown bag, 2 muted beige bags. +bright magenta bags contain 2 muted lime bags. +posh crimson bags contain 4 pale indigo bags, 2 faded green bags. +vibrant plum bags contain 1 posh gray bag, 3 mirrored silver bags, 4 bright brown bags, 2 posh magenta bags. +wavy lime bags contain 4 wavy black bags, 4 shiny cyan bags, 5 striped aqua bags, 4 plaid gray bags. +shiny silver bags contain 5 dotted crimson bags, 2 wavy turquoise bags, 1 shiny coral bag. +dark tan bags contain 5 clear silver bags. +mirrored brown bags contain 1 dotted brown bag, 2 plaid gray bags, 5 dull tomato bags, 5 clear black bags. +muted brown bags contain 3 drab magenta bags, 4 plaid aqua bags, 5 dim black bags. +posh black bags contain 2 bright turquoise bags, 3 mirrored maroon bags, 1 dull white bag. +wavy aqua bags contain 3 drab green bags, 3 clear magenta bags. +vibrant chartreuse bags contain 3 muted violet bags. +wavy silver bags contain 2 muted yellow bags, 4 plaid violet bags. +shiny salmon bags contain 1 clear yellow bag. +clear purple bags contain 2 posh green bags, 2 muted gray bags. +clear cyan bags contain 5 posh gray bags, 5 plaid aqua bags, 1 wavy tomato bag, 1 dim lavender bag. +wavy coral bags contain 5 dim yellow bags, 3 clear yellow bags. +wavy green bags contain 4 plaid bronze bags, 4 dull coral bags. +mirrored gold bags contain 5 bright lavender bags. +muted fuchsia bags contain 1 dotted purple bag. +clear maroon bags contain 3 muted gray bags, 2 bright chartreuse bags, 3 dotted gold bags. +faded salmon bags contain 5 clear green bags. +striped aqua bags contain 5 pale yellow bags, 1 dotted salmon bag, 1 wavy teal bag, 1 muted yellow bag. +plaid fuchsia bags contain 2 dim olive bags. +pale chartreuse bags contain 3 posh magenta bags, 3 mirrored yellow bags. +shiny beige bags contain 1 mirrored indigo bag. +posh aqua bags contain 3 pale silver bags, 3 shiny tan bags, 5 striped blue bags, 5 dull salmon bags. +dull magenta bags contain 5 dotted lime bags, 4 bright plum bags, 5 vibrant turquoise bags. +posh tomato bags contain 5 shiny tan bags, 1 wavy salmon bag. +clear red bags contain 5 clear black bags. +dotted aqua bags contain 1 clear black bag. +clear olive bags contain 1 plaid gray bag, 3 clear cyan bags. +dotted green bags contain 3 light red bags. +clear teal bags contain 5 faded coral bags, 3 wavy plum bags, 5 bright orange bags, 1 clear purple bag. +plaid orange bags contain 4 pale chartreuse bags, 1 dark silver bag, 2 drab tomato bags. +pale teal bags contain 1 drab black bag. +posh chartreuse bags contain 1 dotted gold bag, 4 bright salmon bags. +pale red bags contain 2 vibrant plum bags, 4 wavy cyan bags, 2 dotted white bags, 1 posh silver bag. +faded violet bags contain 1 mirrored white bag, 4 muted green bags, 5 mirrored olive bags, 1 dim brown bag. +faded fuchsia bags contain 2 dark brown bags. +dotted brown bags contain 4 clear blue bags. +dark teal bags contain 5 dull cyan bags. +bright salmon bags contain 2 pale black bags, 5 dotted chartreuse bags, 2 striped chartreuse bags. +pale blue bags contain 4 shiny gold bags, 2 clear white bags, 1 dotted coral bag. +dim tan bags contain 3 plaid yellow bags, 5 clear blue bags, 2 clear cyan bags. +dull beige bags contain 5 shiny maroon bags, 4 mirrored bronze bags, 4 dark plum bags. +clear magenta bags contain 5 dim bronze bags, 5 wavy olive bags. +bright black bags contain 2 bright bronze bags, 5 mirrored gold bags, 4 dark yellow bags. +muted aqua bags contain 2 dark teal bags. +faded blue bags contain 4 clear salmon bags, 1 light cyan bag, 5 wavy tomato bags. +dotted indigo bags contain 2 shiny maroon bags, 2 wavy tan bags, 4 dim tomato bags, 1 posh plum bag. +striped chartreuse bags contain 2 dotted orange bags, 3 bright lavender bags. +dim indigo bags contain 4 shiny coral bags, 4 mirrored olive bags. +dotted purple bags contain 4 mirrored white bags, 1 posh yellow bag, 5 drab maroon bags. +muted chartreuse bags contain 5 bright silver bags, 2 bright brown bags. +shiny purple bags contain 3 dim maroon bags, 2 mirrored lime bags, 2 light lavender bags, 3 dotted salmon bags. +faded white bags contain 3 vibrant white bags, 5 muted gray bags. +muted red bags contain 3 posh coral bags. +mirrored tan bags contain 1 dotted gold bag, 2 dark coral bags, 3 light purple bags. +dim blue bags contain 3 dull blue bags, 4 posh plum bags. +bright indigo bags contain 1 muted white bag, 1 wavy fuchsia bag. +striped crimson bags contain 3 dotted coral bags. +light orange bags contain 3 striped chartreuse bags, 4 bright silver bags, 5 clear cyan bags. +posh yellow bags contain 3 bright brown bags. +dotted beige bags contain 1 plaid red bag. +faded aqua bags contain 3 drab tan bags. +shiny red bags contain 3 striped lime bags, 5 wavy teal bags, 2 muted olive bags, 1 shiny chartreuse bag. +light tomato bags contain 4 muted green bags. +bright olive bags contain 4 shiny maroon bags, 1 striped tan bag, 2 drab teal bags, 3 mirrored chartreuse bags. +mirrored white bags contain 4 vibrant aqua bags, 4 clear blue bags, 4 bright violet bags, 1 muted olive bag. +posh olive bags contain 2 shiny maroon bags, 3 faded coral bags, 1 dark turquoise bag. +vibrant lime bags contain 1 light lime bag, 5 bright lime bags, 4 vibrant olive bags. +striped brown bags contain 3 clear chartreuse bags, 4 drab magenta bags. +striped lavender bags contain 1 wavy plum bag. +wavy white bags contain 4 dotted red bags. +dark bronze bags contain 2 posh green bags, 1 dotted crimson bag, 5 bright lavender bags, 1 shiny coral bag. +mirrored black bags contain 3 muted salmon bags. +shiny magenta bags contain 4 dotted orange bags, 4 bright silver bags, 3 posh coral bags. +light bronze bags contain 3 dotted coral bags. +mirrored gray bags contain 1 muted olive bag, 1 bright violet bag. +bright lavender bags contain 1 dull tomato bag, 2 clear blue bags. +drab yellow bags contain 3 dim tomato bags, 3 striped green bags. +dark chartreuse bags contain 5 vibrant violet bags, 4 shiny tan bags, 4 dark orange bags, 1 dull tan bag. +vibrant indigo bags contain 3 mirrored violet bags, 3 light teal bags, 2 dim red bags. +plaid green bags contain 3 wavy blue bags, 4 wavy yellow bags, 1 dull lavender bag. +mirrored purple bags contain 5 vibrant silver bags. +vibrant yellow bags contain 4 plaid brown bags, 3 drab bronze bags, 5 posh bronze bags, 3 mirrored lime bags. +pale gold bags contain 4 shiny indigo bags, 4 clear maroon bags. +shiny cyan bags contain 3 dim olive bags. +dim salmon bags contain 5 faded beige bags, 2 faded orange bags, 2 shiny purple bags. +dark crimson bags contain 3 dull aqua bags, 1 wavy olive bag, 3 posh plum bags, 3 bright brown bags. +vibrant gold bags contain 3 wavy gray bags, 4 clear white bags, 1 faded salmon bag, 3 drab aqua bags. +faded magenta bags contain 5 plaid aqua bags, 4 faded purple bags, 5 wavy bronze bags. +drab black bags contain 3 pale aqua bags, 2 clear coral bags, 2 mirrored silver bags, 5 dark cyan bags. +bright green bags contain 1 shiny aqua bag, 5 drab salmon bags, 5 wavy tomato bags, 4 faded beige bags. +bright aqua bags contain 2 vibrant magenta bags, 3 dim indigo bags, 5 dark fuchsia bags. +pale olive bags contain 1 dotted brown bag. +mirrored fuchsia bags contain 1 dull brown bag, 3 light cyan bags. +mirrored red bags contain 3 plaid lavender bags. +wavy blue bags contain 5 wavy turquoise bags, 3 light green bags, 4 dim indigo bags, 3 posh coral bags. +clear silver bags contain 4 plaid gray bags. +muted white bags contain 2 dotted salmon bags, 4 mirrored white bags, 3 clear cyan bags, 2 muted chartreuse bags. +dim tomato bags contain 3 drab white bags, 1 posh gray bag, 3 dark cyan bags, 5 posh green bags. +drab beige bags contain 1 light orange bag, 3 bright salmon bags, 3 pale silver bags. +clear gold bags contain 2 vibrant white bags, 2 plaid yellow bags. +vibrant orange bags contain 5 muted chartreuse bags. +striped tan bags contain 1 wavy gold bag, 3 mirrored black bags, 1 shiny aqua bag, 5 vibrant red bags. +bright lime bags contain 4 dim indigo bags, 3 dull tomato bags. +bright red bags contain 5 drab magenta bags, 1 clear salmon bag. +vibrant green bags contain 4 plaid tomato bags. +light tan bags contain 5 muted green bags. +striped white bags contain 1 faded silver bag, 2 vibrant red bags. +dull violet bags contain 5 dull turquoise bags. +drab salmon bags contain 3 posh magenta bags, 1 dark teal bag. +mirrored cyan bags contain 2 dim violet bags, 1 plaid aqua bag, 1 vibrant blue bag, 1 posh magenta bag. +wavy teal bags contain 1 bright crimson bag, 2 light cyan bags, 4 striped silver bags. +vibrant purple bags contain 5 shiny magenta bags, 1 dotted orange bag, 2 wavy teal bags. +faded beige bags contain 1 posh green bag, 5 clear coral bags. +faded lime bags contain 1 wavy gray bag, 1 light orange bag, 5 clear bronze bags. +mirrored green bags contain 5 drab bronze bags, 3 muted violet bags, 1 clear blue bag. +light green bags contain 5 mirrored lavender bags, 3 drab gold bags. +pale crimson bags contain 3 pale chartreuse bags. +mirrored aqua bags contain 4 drab plum bags. +dull crimson bags contain 2 bright white bags, 5 drab olive bags, 5 pale salmon bags. +dull purple bags contain 1 posh magenta bag, 3 mirrored brown bags. +bright white bags contain 4 vibrant blue bags, 3 dull brown bags, 4 drab green bags. +drab indigo bags contain 2 bright salmon bags, 2 muted maroon bags, 2 clear gray bags. +striped fuchsia bags contain 2 drab gold bags, 4 mirrored white bags, 3 muted black bags, 1 dark teal bag. +dark tomato bags contain 3 muted fuchsia bags, 1 dotted lavender bag, 4 drab turquoise bags. +mirrored tomato bags contain 5 dark olive bags, 4 light black bags, 4 dark magenta bags. +dark plum bags contain 4 wavy yellow bags, 4 shiny salmon bags. +dark salmon bags contain 1 dim bronze bag, 4 pale indigo bags, 5 dotted chartreuse bags. +dotted lime bags contain 1 shiny brown bag, 3 faded lavender bags. +dark red bags contain 3 posh green bags, 1 vibrant bronze bag, 2 dull maroon bags. +dim lavender bags contain 2 dark turquoise bags. +striped cyan bags contain 1 clear chartreuse bag. +dull indigo bags contain 5 shiny brown bags. +faded green bags contain 1 drab maroon bag. +drab fuchsia bags contain 2 clear olive bags, 1 bright cyan bag. +drab gold bags contain 2 dull turquoise bags, 5 dim lavender bags, 4 light teal bags. +dotted violet bags contain 3 drab tomato bags, 5 dark lavender bags, 4 bright fuchsia bags. +shiny turquoise bags contain 4 light black bags. +muted green bags contain 3 vibrant bronze bags, 4 dim olive bags, 2 posh yellow bags, 2 dull cyan bags. +pale purple bags contain 2 drab yellow bags, 3 bright crimson bags. +posh fuchsia bags contain 1 dull tan bag, 2 dim orange bags. +drab teal bags contain 1 dim violet bag, 2 drab green bags, 5 mirrored lavender bags, 2 faded purple bags. +mirrored teal bags contain 4 vibrant aqua bags, 2 dull turquoise bags, 4 vibrant bronze bags, 3 mirrored olive bags. +muted violet bags contain 3 wavy chartreuse bags. +mirrored salmon bags contain 3 clear cyan bags, 5 posh plum bags, 1 shiny coral bag. +vibrant crimson bags contain 4 dotted chartreuse bags, 2 wavy yellow bags, 3 drab green bags. +dotted teal bags contain 3 clear black bags, 1 faded blue bag, 1 clear beige bag, 4 striped brown bags. +posh orange bags contain 1 dim olive bag. +striped bronze bags contain 1 dull salmon bag, 4 wavy teal bags, 1 pale salmon bag, 2 dim aqua bags. +clear lime bags contain 1 dim lavender bag, 1 drab magenta bag. +muted magenta bags contain 1 shiny indigo bag, 4 mirrored cyan bags, 4 shiny cyan bags, 2 posh bronze bags. +bright chartreuse bags contain 5 drab white bags, 3 dotted purple bags. +dim magenta bags contain 2 dull turquoise bags, 1 dull coral bag, 3 dark violet bags, 4 muted crimson bags. +pale cyan bags contain 5 dotted coral bags, 4 drab chartreuse bags, 4 dull plum bags. +shiny white bags contain 2 drab salmon bags, 3 shiny silver bags. +faded tan bags contain 4 posh magenta bags, 1 pale teal bag. diff --git a/2020/day8.cpp b/2020/day8.cpp new file mode 100644 index 0000000..ad82b0f --- /dev/null +++ b/2020/day8.cpp @@ -0,0 +1,113 @@ +/******************************************************************************* + * + * Copyright (c) 2020 Gnarwhal + * + * ----------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files(the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *******************************************************************************/ + +#include +#include +#include +#include + +#include "types.hpp" + +enum OpCode { Acc, Jmp, Nop }; +struct Op{ OpCode code; i32 num; }; +auto extract_op(const std::string & string) -> Op { + auto op = Op{ Nop, 0 }; + auto op_code_str = string.substr(0, 3); + if (string.substr(0, 3) == "acc") { op.code = Acc; } + else if (string.substr(0, 3) == "jmp") { op.code = Jmp; } + else if (string.substr(0, 3) == "nop") { op.code = Nop; } + + op.num = std::stoi(string.substr(4, string.size() - 4)); + + return op; +} + +struct State{ u32 isp; i32 acc; }; + +auto execute(State & state, const std::vector & ops) -> void { + switch (ops[state.isp].code) { + case Acc: state.acc += ops[state.isp].num; ++state.isp; break; + case Jmp: state.isp += ops[state.isp].num; break; + case Nop: ++state.isp; break; + } +} + +auto attempt_swap(State & state, std::vector & ops) -> bool { + if (ops[state.isp].code == Jmp) { + ops[state.isp].code = Nop; + } else if (ops[state.isp].code == Nop) { + ops[state.isp].code = Jmp; + } else { + return false; + } + + auto local_state = state; + auto executed = std::vector(ops.size()); + while (local_state.isp < ops.size() && !executed[local_state.isp]) { + executed[local_state.isp] = true; + execute(local_state, ops); + } + if (local_state.isp >= ops.size()) { + state = local_state; + return true; + } else if (ops[state.isp].code == Jmp) { + ops[state.isp].code = Nop; + } else if (ops[state.isp].code == Nop) { + ops[state.isp].code = Jmp; + } + + return false; +} + +auto main(i32 argc, char * argv[]) -> i32 { + auto ops = std::vector(); + { + auto line = std::string(); + auto file = std::ifstream("day8.input"); + while (getline(file, line)) { + ops.push_back(extract_op(line)); + } + } + + auto state = State{ 0, 0 }; + auto executed = std::vector(ops.size()); + while (!executed[state.isp]) { + executed[state.isp] = true; + execute(state, ops); + } + std::cout << state.acc << std::endl; + + state = State{ 0, 0 }; + while (state.isp < ops.size()) { + if (attempt_swap(state, ops)) { + std::cout << state.acc << std::endl; + break; + } + execute(state, ops); + } + + return 0; +} diff --git a/2020/day8.input b/2020/day8.input new file mode 100644 index 0000000..a348b44 --- /dev/null +++ b/2020/day8.input @@ -0,0 +1,610 @@ +acc +0 +jmp +516 +acc -16 +nop +326 +jmp +366 +jmp +400 +jmp +494 +acc -5 +jmp +475 +acc +29 +nop +24 +jmp +186 +jmp -5 +acc +50 +acc +49 +acc +49 +nop +507 +jmp +236 +acc -4 +acc +50 +acc +48 +jmp +293 +jmp +461 +acc +48 +acc +2 +jmp +241 +acc +38 +jmp +544 +jmp +1 +jmp +382 +acc -4 +acc -10 +acc +44 +jmp +444 +jmp +1 +acc +20 +acc -1 +acc +25 +jmp +332 +acc +18 +jmp +184 +acc +1 +acc +20 +acc -7 +acc -12 +jmp +84 +acc +30 +jmp -19 +nop +491 +acc +37 +acc +44 +jmp +220 +acc +3 +acc +19 +jmp +485 +jmp +222 +nop +264 +acc +4 +jmp +151 +nop -36 +acc +48 +jmp +356 +acc +28 +acc +29 +nop +397 +jmp +168 +nop +115 +acc -13 +acc -11 +jmp +470 +jmp +201 +acc +48 +acc -6 +acc -18 +acc -13 +jmp +442 +jmp +266 +acc +10 +acc +30 +acc -7 +acc -8 +jmp +380 +acc +1 +nop +106 +acc +9 +acc -11 +jmp -79 +jmp +166 +acc -9 +jmp +300 +acc +39 +acc +1 +acc +27 +acc +26 +jmp +367 +jmp +291 +acc +18 +jmp +100 +acc +25 +acc +43 +acc -8 +acc -12 +jmp +475 +acc +15 +jmp +492 +acc -5 +acc -12 +acc +35 +acc +25 +jmp +360 +nop +301 +acc +32 +acc -1 +jmp +436 +acc +21 +jmp +109 +acc +1 +nop +230 +jmp -113 +acc +24 +acc +12 +acc +13 +acc +27 +jmp -52 +jmp +476 +acc +15 +acc -18 +acc -13 +jmp +323 +acc -10 +acc +35 +acc -6 +nop +377 +jmp +8 +jmp +430 +nop +50 +acc +33 +acc -1 +jmp -72 +acc -19 +jmp -92 +jmp +1 +jmp -87 +nop -120 +nop -34 +jmp +159 +jmp +183 +jmp +1 +acc -4 +acc +49 +acc -4 +jmp +73 +acc -18 +acc +34 +acc -8 +jmp +403 +acc +32 +acc +0 +acc +0 +jmp +390 +acc +19 +jmp +305 +acc -15 +jmp +176 +acc +3 +jmp +36 +acc +29 +acc +21 +jmp +1 +acc -17 +jmp +144 +acc +16 +acc +4 +acc +49 +acc -7 +jmp -65 +acc +28 +acc +2 +acc +23 +acc +46 +jmp +278 +jmp +424 +acc +45 +acc +7 +jmp -49 +jmp -50 +acc -11 +nop -121 +jmp -140 +jmp +1 +acc -8 +jmp +206 +acc -7 +jmp +1 +acc +20 +acc +30 +jmp +375 +nop +312 +jmp +111 +acc +23 +jmp -15 +acc +27 +acc +46 +acc +36 +jmp +360 +acc +1 +acc +25 +acc +29 +jmp -137 +jmp +177 +acc +15 +acc -13 +acc +48 +acc +29 +jmp +76 +nop -174 +acc +27 +jmp +214 +acc +4 +jmp +120 +nop -165 +acc -16 +jmp +2 +jmp +238 +jmp +224 +jmp -154 +acc +12 +jmp +162 +acc +31 +acc +26 +acc -13 +acc +18 +jmp +173 +acc +38 +jmp +1 +jmp +199 +jmp -202 +jmp +127 +acc -12 +jmp -42 +acc -12 +acc +36 +acc -4 +acc +24 +jmp +343 +acc -17 +nop +277 +acc +13 +jmp +56 +jmp +41 +nop +92 +acc +32 +jmp +182 +nop +111 +acc +0 +acc +29 +jmp +219 +nop -234 +acc +0 +acc +31 +acc +49 +jmp +216 +jmp +247 +acc +24 +acc -10 +jmp +218 +acc +14 +acc -19 +acc +14 +jmp +11 +jmp +82 +acc +5 +acc +28 +acc +35 +jmp -93 +acc +24 +jmp -210 +acc +39 +jmp -107 +jmp -150 +acc -7 +jmp -185 +acc +25 +acc -15 +jmp +63 +acc +14 +acc +50 +jmp -7 +acc +13 +jmp +298 +nop +69 +jmp -268 +acc -5 +jmp +66 +jmp +48 +nop -1 +acc +38 +acc +3 +acc +46 +jmp +259 +nop +235 +acc +4 +jmp -186 +jmp +94 +acc -16 +acc +6 +jmp +287 +acc -19 +jmp -221 +jmp -69 +acc +8 +nop -102 +acc +31 +jmp +204 +jmp -81 +acc +12 +acc +21 +acc -8 +nop +151 +jmp -155 +acc +50 +nop +145 +acc -6 +acc +0 +jmp -296 +acc +16 +acc +30 +acc +11 +jmp +254 +acc +0 +acc -8 +nop +162 +acc -17 +jmp -144 +acc +6 +acc +2 +acc +32 +acc -5 +jmp +21 +jmp -77 +acc +38 +jmp +117 +acc +27 +acc -11 +nop -203 +jmp +201 +jmp -305 +acc +40 +nop -330 +acc -7 +jmp -279 +jmp +60 +nop -163 +jmp -53 +nop +115 +acc +24 +jmp +1 +acc +45 +jmp -92 +acc +0 +acc +13 +jmp -302 +acc +25 +jmp +208 +nop -293 +jmp +5 +jmp +1 +acc -13 +nop -272 +jmp +62 +acc -4 +acc +32 +acc +49 +jmp -124 +acc -19 +nop -246 +jmp -353 +nop -349 +acc +13 +acc +21 +jmp -165 +acc +14 +acc +37 +nop +28 +acc +7 +jmp -308 +acc +11 +jmp +71 +jmp -139 +nop -19 +acc -7 +acc -3 +jmp -302 +acc -2 +acc +1 +nop -43 +jmp -280 +acc +10 +acc +9 +jmp -358 +acc +39 +acc +16 +acc -11 +jmp +1 +jmp +142 +acc -15 +acc -17 +acc +9 +acc +11 +jmp -172 +jmp -90 +nop +135 +acc -1 +jmp -379 +acc +39 +acc -13 +jmp -57 +acc -3 +acc -7 +jmp +1 +jmp +80 +acc +7 +acc +11 +acc +30 +nop +69 +jmp -140 +acc +11 +acc +7 +acc +3 +jmp -417 +jmp -314 +acc -6 +jmp -6 +jmp -224 +acc +0 +jmp -131 +acc +7 +acc +33 +jmp +20 +acc +32 +acc -14 +nop -375 +jmp -394 +acc +8 +acc +47 +acc +29 +acc -6 +jmp -381 +acc -8 +jmp -353 +jmp -108 +acc -16 +acc +21 +jmp -329 +acc +13 +acc +0 +acc +0 +jmp -402 +acc -8 +jmp -307 +jmp -308 +jmp -358 +acc +38 +acc -19 +acc +33 +jmp -276 +jmp -114 +acc -6 +jmp +55 +acc +16 +jmp -244 +nop +22 +acc -7 +acc +19 +jmp -154 +jmp +18 +jmp -50 +acc +31 +acc +50 +acc +2 +jmp -260 +acc -16 +jmp -135 +acc +50 +acc -9 +acc +50 +acc +27 +jmp -323 +acc +26 +nop -249 +acc +46 +acc +3 +jmp -474 +acc +50 +acc -7 +jmp -78 +jmp +1 +acc -6 +acc +6 +jmp +94 +acc +47 +acc -3 +acc +13 +jmp -485 +nop -499 +acc +35 +acc +35 +acc -1 +jmp -259 +nop -486 +acc +48 +acc -4 +jmp +23 +acc +33 +acc +37 +acc +10 +jmp +61 +acc -1 +jmp +1 +jmp +1 +acc -8 +jmp +61 +jmp -237 +jmp -164 +acc +39 +acc +38 +nop -302 +jmp -468 +acc -15 +jmp -6 +acc -9 +acc +1 +acc +41 +acc +48 +jmp -285 +acc +1 +acc +24 +jmp -111 +jmp -90 +acc +46 +acc +21 +acc +43 +jmp -103 +acc -9 +nop -5 +jmp -274 +acc -13 +jmp -262 +jmp -39 +acc +43 +nop -463 +acc +15 +acc +23 +jmp -176 +nop -305 +acc +2 +acc +28 +jmp -198 +acc +15 +acc -18 +jmp -473 +acc -13 +acc +9 +jmp -46 +acc +1 +acc +43 +acc +6 +jmp +10 +acc +24 +acc -3 +jmp -424 +acc -1 +acc +47 +jmp +1 +acc +20 +jmp -17 +jmp -59 +nop -19 +acc +42 +acc +47 +jmp -9 +jmp -576 +nop -148 +acc +0 +jmp +12 +acc -15 +jmp -209 +acc +13 +jmp -442 +nop -548 +nop -62 +acc +22 +jmp -92 +jmp -516 +acc +8 +jmp -301 +acc +1 +jmp -146 +acc -15 +jmp -366 +jmp -440 +acc +17 +acc +25 +acc +28 +jmp -240 +acc -2 +acc +25 +nop -68 +acc +14 +jmp +1