aoc

Advent of Code Solutions
git clone git://git.alexkarle.com.com/aoc
Log | Files | Refs | README | LICENSE

commit 51ce80223a14f9e928abc2280f81dbd326208683 (patch)
parent d7d8534a79c2ebc76fdeb16cc12c60b89900eda4
Author: Alex Karle <alex@alexkarle.com>
Date:   Sat,  3 Dec 2022 12:54:33 -0500

Add 2020 solutions

These were tracked in a different non-public repo. Might as well
consolidate them and own up to the fact I wrote a good bit of Perl :)

Diffstat:
A2020/01/input | 200+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A2020/01/sol1.pl | 18++++++++++++++++++
A2020/01/sol2.pl | 31+++++++++++++++++++++++++++++++
A2020/02/input | 1000+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A2020/02/sol1.pl | 15+++++++++++++++
A2020/02/sol2.pl | 13+++++++++++++
A2020/03/input | 323+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A2020/03/sol1.pl | 16++++++++++++++++
A2020/03/sol2.pl | 40++++++++++++++++++++++++++++++++++++++++
A2020/04/input | 989+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A2020/04/sol1.pl | 26++++++++++++++++++++++++++
A2020/04/sol2.pl | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A2020/05/input | 965+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A2020/05/sol1.pl | 42++++++++++++++++++++++++++++++++++++++++++
A2020/05/sol2.pl | 50++++++++++++++++++++++++++++++++++++++++++++++++++
A2020/06/input | 2232+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A2020/06/sol1.pl | 23+++++++++++++++++++++++
A2020/06/sol2.pl | 25+++++++++++++++++++++++++
A2020/07/input | 594+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A2020/07/sol1.pl | 43+++++++++++++++++++++++++++++++++++++++++++
A2020/07/sol2.pl | 41+++++++++++++++++++++++++++++++++++++++++
A2020/08/input | 625+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A2020/08/sol1.pl | 33+++++++++++++++++++++++++++++++++
A2020/08/sol2.pl | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
A2020/09/input | 1000+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A2020/09/sol1.pl | 40++++++++++++++++++++++++++++++++++++++++
A2020/09/sol2.pl | 46++++++++++++++++++++++++++++++++++++++++++++++
A2020/10/input | 100+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A2020/10/sol1.pl | 27+++++++++++++++++++++++++++
A2020/10/sol2.pl | 36++++++++++++++++++++++++++++++++++++
A2020/11/input | 99+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A2020/11/sol1.pl | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A2020/11/sol2.pl | 99+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MREADME.md | 4++++
34 files changed, 8980 insertions(+), 0 deletions(-)

diff --git a/2020/01/input b/2020/01/input @@ -0,0 +1,200 @@ +2004 +1671 +1678 +1304 +1242 +1882 +1605 +1034 +1883 +1589 +1881 +1546 +1713 +1218 +1982 +1395 +1277 +1417 +1497 +1499 +1847 +1989 +1172 +1684 +1243 +1843 +1661 +1662 +1421 +1790 +1344 +1458 +1074 +1809 +1990 +1369 +1386 +1736 +1972 +1634 +1229 +1123 +1870 +1595 +1934 +1399 +1732 +1545 +1208 +368 +1907 +1143 +443 +1929 +1965 +1872 +1738 +1967 +997 +1473 +1041 +1991 +1868 +1180 +1409 +1379 +1568 +1163 +1869 +1391 +1956 +1249 +1505 +351 +2001 +462 +1219 +1731 +1802 +1798 +1626 +1438 +1099 +1477 +1980 +1708 +1666 +1066 +1121 +1359 +1426 +1734 +1768 +1836 +1453 +923 +1660 +1878 +1522 +1024 +1429 +232 +1952 +1730 +1763 +1981 +1388 +1337 +1317 +1922 +1044 +1999 +1341 +1178 +1524 +1185 +1257 +1256 +1061 +1262 +1022 +1778 +1917 +1205 +1272 +1842 +1533 +1194 +1746 +1691 +1617 +1667 +1940 +1171 +1792 +1773 +1411 +1902 +1859 +1978 +1764 +1482 +1276 +735 +1716 +1915 +1675 +1126 +1830 +1227 +1299 +1535 +1700 +1658 +1771 +1823 +1055 +1602 +1590 +1983 +1885 +1735 +103 +1766 +14 +1486 +1939 +1525 +1916 +1279 +544 +1406 +1674 +1948 +1971 +1651 +1715 +1943 +1784 +2008 +1800 +1720 +1557 +1467 +1371 +1637 +1345 +1924 +1565 +1976 +1827 +1890 +1848 +1465 +1573 +1231 +1310 +1754 +1569 +1532 diff --git a/2020/01/sol1.pl b/2020/01/sol1.pl @@ -0,0 +1,18 @@ +#!/usr/bin/env perl +# idea: +# HAS to be O(N) because have to check each item in worst case +use strict; +use warnings; + +my %seen; +while (<>) { + chomp; + my $comp = 2020 - $_; + if (exists $seen{$comp}) { + print $_ * $comp . "\n"; + exit(0); + } else { + $seen{$_} = 1; + } +} +exit(1); diff --git a/2020/01/sol2.pl b/2020/01/sol2.pl @@ -0,0 +1,31 @@ +#!/usr/bin/env perl +# idea: +# HAS to be O(N) because have to check each item in worst case +use strict; +use warnings; + +# first read the whole file in +my @all; + +open(my $fh, '<', 'input') or die "$!"; +for (<$fh>) { + chomp; + push @all, $_; +} + +for (my $i = 0; $i < scalar @all; $i++) { + my $cand = shift @all; + my $magic = 2020 - $cand; + my %seen; + for (@all) { + my $targ = $magic - $_; + if (exists $seen{$targ}) { + print $targ * $_ * $cand . "\n"; + exit(0); + } else { + $seen{$_} = 1; + } + } + push @all, $cand; +} +exit(1); diff --git a/2020/02/input b/2020/02/input @@ -0,0 +1,1000 @@ +16-18 h: hhhhhhhhhhhhhhhhhh +17-18 d: ddddddddddddddddzn +15-18 c: cccccccccccccczcczc +3-9 r: pplzctdrc +4-14 d: lxdmddfddddddd +8-14 v: pvxlknfvplgktv +11-13 h: hphhhhhhhfhshhhhh +1-4 l: hbljb +1-2 x: wxqzlvt +1-5 g: dxggdggb +5-13 f: lfgdplfffxffswck +6-7 z: zzzzgzzzz +1-7 c: cccclcchrkctfhc +3-7 c: ccjccqzcc +15-16 x: rxxchpvgxxhxkxxw +3-5 h: hbxjg +3-7 q: sffnxxqvdfsnqlhqpq +8-11 h: hhhhhhhlhhh +7-8 w: bxwzdlwr +4-5 x: xxxxp +4-7 x: xxxxxxxx +2-18 l: lllllllllllllllllrll +6-10 n: nnnnnngnznn +12-13 c: ccccccccccchc +2-6 g: ggqngxgbggc +4-5 k: xdztx +4-9 m: txskmsnxvqjhlp +9-11 w: wwtxmsjwjwlw +12-16 g: cgggpkhggqkgrjcbx +9-11 s: sxsssmssvszs +17-18 c: cccccccccclccsccchcc +7-8 z: stpgzwlqm +9-19 q: qqqqqqqqqqqqqqqqqqqq +4-5 p: hpvtpfgwp +8-9 m: mmmmmmqmm +11-12 s: ssswsssssspts +2-4 j: jjdr +17-18 k: kvkkmlkkkkkkfklkkkkk +1-4 b: bbbwb +2-12 c: cccccccccccccc +14-15 l: llllllllllplllllllll +7-10 c: czcccsvnrbccc +11-12 d: nfmvdlxbfwzq +8-10 t: tvtttttzts +5-6 g: wggghg +11-16 d: ztfdkggclvzmvsxd +16-17 v: vvvvvvbvvpvxvvvhv +3-7 w: vrswklnfnjzkm +1-18 s: bsssssssssssssssshss +8-10 g: vdzldttzgm +19-20 n: nnnnnnnnnnnnnnnnnnrb +1-4 x: xxxqxxxxx +11-13 m: xmmxmmmmgmwmmm +4-5 j: pzfjjsjjmcm +1-7 j: jsjsmjj +7-8 j: nqkkljhbj +4-5 w: wmsbqhmwdjns +4-7 j: jbjjcjcf +2-7 f: jhsxldwf +3-4 f: vmff +5-7 z: fscmzjqs +2-10 g: ggtfwzpbkgqqlzwmbm +5-6 j: jjwbdjj +13-15 b: bbbbbbbbkbbbvbbbb +4-6 t: qdthtt +1-8 m: kmmmmmmvmmmmm +4-8 g: gbgqgtcglvgggcg +3-4 h: ghjn +3-8 b: mgbzbjvbkbpbd +11-17 k: kkkktskgkkkfgzkkk +1-6 f: ftnvfgtrlcs +3-13 r: hrrzrfrfpvdlrnrcrcs +3-8 l: gzljpllvl +3-11 h: hchjhhnhhnhvhhhhx +9-16 s: srssssssssskpldsqss +4-10 n: nnbnnnwnnwnnnxnn +3-4 n: nnnp +11-19 z: nznpcdnxkwznzlpvcwzj +4-7 w: wwwrwtwncwvwwwwx +3-4 s: bkgs +2-16 z: nzlcmlvqdcmmcnphb +1-15 z: zzzzzzzzzzzzzzzzzz +9-10 t: tmgttdtqtttttwbgttt +1-2 h: hhhhhmhmkgxhnhw +4-5 h: hlhhh +9-15 h: xhhhhhchhhznphh +5-8 w: jwphwwwj +4-5 z: lztsz +10-11 c: mhtdcdhggccgfck +3-8 t: ccttgcktz +1-12 m: smmmmxmmmgmx +1-12 r: srrrrrrrrrrlrrrrr +2-5 h: khhzhrqr +3-4 m: mmztmm +2-5 f: fbffqf +1-11 p: zpppppppnphppx +5-12 z: pqrzlwztvzjfzbt +8-12 b: bbbbbbbdbbbcb +3-4 g: ghqg +7-10 m: mmmmmmmmmmmm +5-14 q: jblkqbqpmqwsqt +6-8 r: rrrtrlzltfrrrgrr +9-14 r: rrrrrzrrjrrrgmr +9-10 m: tmshdggksmv +10-17 d: dddddddddcddddddf +6-7 f: ffffffx +9-19 j: jfjljzjcjjzjjjfjpjj +2-6 h: jhxmhh +1-7 g: wgggggzggxmggg +5-6 n: nlgnlx +4-7 t: thzttttt +4-6 x: xhnxjx +14-16 p: ppppppppppppppppp +2-4 s: ssps +7-15 k: bzfljhskslxlznwvphg +6-7 j: dkjjsgk +9-11 p: ppppppppkpmpp +5-8 t: tzcttttttt +8-11 d: dddddddgddld +3-9 w: dwwhwbwwwwwzwtwxw +2-3 x: xxwxmw +1-5 g: gdlvg +4-6 c: cccmcrccccccc +1-11 f: ffffffffffnff +10-11 l: lgqgnwlhgdlvdlv +3-7 v: cjvvvvnvjvjvgvkx +4-5 v: vvvsv +13-15 t: tttttrtttttttth +11-12 q: nccsqqhqqqqqlqqqqq +2-7 p: pspppppppp +4-6 g: gglggg +17-18 p: hwpkcxvppzxxvpjzpp +1-3 b: dlfz +11-12 p: ppppppppppfpdppp +1-2 s: ssszdss +2-15 b: nbsblthmngvbqvbh +1-6 q: sqqqqbqq +4-11 q: tgmtqqrxfsvrzhc +8-13 q: qqqqzqqqqqqmqqqjqq +9-17 n: nnnnnnnnnnnnnnnnpnnn +6-9 h: rmhrlkhskbhhq +5-6 n: qnnjnn +4-6 l: lxlllkvdltgcfl +12-15 f: fflffffpfvftffwff +13-16 t: fpwmwmvtqbvxtvtt +7-8 w: kwwwjgwmwbw +1-2 x: xxnvmbcmxhnkkgfrr +3-7 f: rpcnzvjgh +13-15 r: rrwrkrrrrrrrdrbr +11-13 h: ghnzvhhhhwhchmh +7-8 h: hhhhhhnv +5-6 l: kgllll +1-4 k: kqsjblck +6-8 c: crxxccccgc +2-13 g: fvmhpbqkgvbwqvbldb +4-7 g: ggglggmgggkggg +6-7 n: znnrnpnn +12-15 j: jjqjzjjchjmjzsgppss +4-5 k: kkkkk +12-16 r: rrrrrrrrrrrcrrznrz +10-12 w: hdwsvqpwzvtx +9-11 b: brbtbwbbjbbbbbb +6-8 q: nqkvkqdqrq +3-5 n: pjcnd +9-11 q: qqqqqqqqpqqqq +6-7 b: zdbbfpqbvbbgbnq +11-14 g: dxvgpggnpngpqgn +8-11 z: zzzzzzzczzq +8-18 z: nzczzlkcchpzdkrpvzrd +2-4 d: fwdhl +12-13 m: mmmqllmmmmhnf +6-8 b: bmbbcbbbznnbd +18-19 z: zkzzzzzzzzzzzzzzzzz +4-10 m: smkkrpqznmnfdprq +7-8 j: jjjjjjhsj +10-15 t: trpttgcttttttbtt +6-7 t: tttttltttttttt +7-13 x: bxxcxxvxknqcxsx +6-10 j: zjrrtjwxfjhhtcsktslf +3-5 m: zjmms +11-14 v: vvvvvvvkvvvvvvv +1-2 c: ccch +13-14 v: vvvsvvvvvvvvvv +9-12 g: fgkgxgggcjdg +4-6 t: ttpxtgntzwtx +10-12 g: gggggggggkgbg +1-3 l: llllw +7-12 d: nddvldndjcdpdddz +2-5 w: wwtlwwvdww +6-11 c: fcccccccdcc +12-19 s: sjsssssssssssshssss +19-20 t: ttttttttttttttttttkf +7-11 z: zpfgzczcxzmclzzz +2-7 d: sddlpvdqzzlqfkjkbb +2-7 k: dkmlkckm +4-8 w: wwwwwwswww +1-3 d: pddd +1-9 r: chrrrrrrr +17-19 t: ttttttttttttttttptvt +17-18 v: xvvvkvvvvxvsvhbvvv +6-11 j: njjjjcpjjjbjhqj +1-3 s: ssss +15-16 k: kkkckkqgkkxkkkrp +6-7 b: mgzhbbb +9-12 w: wjwxwwpxxtwvwwjnnw +2-5 x: xxlwcpzfx +4-11 j: jjjxjjjjjjcj +6-17 c: qcccsvvzfpccccfchcc +3-4 c: scbjdmjhtlcdvbq +8-9 b: fngpbvfsctl +15-16 r: rrrrrrrqrrrrrrdlt +5-10 v: tvqlvvvtrvlfkwsvlvn +6-8 q: qqsqfqqqq +8-9 m: mmmmmmmms +8-12 r: rxrrprvcrrjd +19-20 c: cncccqwnbsvccclcjkcc +2-4 b: mmjg +12-13 l: slwjlqlslllll +2-8 m: fmmppmmmmtmzmmmm +4-13 l: llllmllllllllltz +6-11 f: ffffffhtffff +1-6 g: gngfzbgx +1-5 f: fwfmfrfxf +16-17 t: ttttttttttttttttt +2-7 w: twsdwvj +6-13 m: mmksmfnmdxtmhmmxm +1-6 b: bbbjbbnbzwgrb +13-15 c: ccccccccccccccsccc +7-8 k: kskkkgkkk +6-7 g: gggmgbzg +17-18 k: mckjkfkdfqkxgtrcrch +4-5 g: xglggggs +2-4 d: ddddddd +5-7 s: nlpzsss +5-12 w: ngwpwprvlftr +15-17 p: psgjvphpbppzpprpp +1-5 m: lljdr +6-8 h: hnzhhqxh +4-7 g: mmccqwfvlqrks +12-14 l: lllllllllllllll +2-3 c: cqfc +15-16 z: zzzzzzzzzzzzzzzz +6-7 v: gkzxvvvdbvnp +7-8 z: zzzjzzvc +13-18 v: vvvvvvvvvvvvkvvvvlv +1-12 p: pppppppkppppppp +10-12 v: vvvvvvvvvtvvv +5-6 s: qkpsqz +5-6 t: tgthtlt +1-5 z: zzzzzz +6-7 j: jjjjjjhj +4-5 b: lbbqdfrbbv +4-6 n: jvmxtfwnqpdhn +2-5 r: mcmrf +8-10 s: sssssssggsss +6-9 f: ffbflgzsfftxqg +1-18 p: pppppppppppppppppp +3-13 b: bbbbdfbbbbbnbbbblcb +5-6 d: drddpk +4-5 h: jhhhdh +12-18 x: wxtsqsrxtsxxxvhxfxx +5-6 q: qmxdnz +6-16 q: qqwqfqqqzqqqqfqqq +4-10 x: xxxgxxxznx +2-3 x: xndnnb +4-5 g: hcgff +5-6 s: wsgjpgssssssdssssss +16-18 k: kkkkkkkkkkkkkkkkkk +5-6 k: kkkkpqkk +13-19 r: rrrrrrrrgrkrrrrrrrr +10-11 s: vgnbshssjcpss +3-5 f: qfhjmjkcgv +3-4 q: nrtnvbsmbwpq +8-18 j: jjjrjjdtjmjjkjwzjjk +4-14 t: tttgtttttttbtxt +5-6 q: qqqqtj +14-17 b: bbbbbhjffbbtbbbbb +9-18 x: rxxxwxxxxxxxxxxxxc +3-9 f: hgjjfkvlflhbtxpb +7-19 n: nnmndnknnlnjnnnnnnz +5-8 m: mbmlmmfpgmwmm +7-8 j: jjjjjsdkjg +3-8 p: hlpjkpjjvbrgpw +10-11 t: tttttttttptt +6-10 b: bbbbbthbbd +3-11 l: xvlknhhglhcgvk +7-17 j: mpxjmcwwqqjtprwgjj +14-17 v: vvvvvvvvsvvvvhvvvv +16-17 p: pppppppdpwpppppppp +3-4 h: hhdr +8-9 v: bvvvvvvfs +6-12 p: pdpppbppnqpxp +3-6 w: jlwwjvcwwhwjrgwzjkqw +3-4 c: zqkzcc +2-7 h: hzhhhhv +1-9 g: mgjlggdznj +3-6 x: nxjxxkxhfx +7-11 m: pmpmmmmmmmmmtmm +9-11 t: tttttttttttt +3-4 n: nnnpqnbfnnnzn +10-17 b: bbqbbbjbbhbbgbthxb +2-8 n: qfqnjhhjsvcvcnnjnnhn +3-6 n: jsgnnn +1-2 n: nntknsnsp +5-7 s: ssssssss +8-9 l: kllllllllh +4-9 k: vkkkkkkkkk +3-8 x: hxdxbxnmxx +5-8 f: pfmvlbffff +13-18 n: rnncfnnntnrgxnnsnn +1-2 d: jxdd +3-5 p: bcfdp +2-4 k: hklkk +13-17 w: wwwwxwwwwldwwwwwm +4-5 z: gzzzgczz +14-15 g: gggggggggggggqg +9-10 x: jzwnmqhgqkxhxb +3-4 z: fszz +13-14 l: nlllllllllrlflllx +1-3 r: rrrr +15-16 c: ccccccckcccccccccl +1-6 h: hhhhhhhphhhhjfhhwjh +5-7 r: gvcprfrrgtqjkgsbcb +12-14 v: vvvhvvvvvvvvvvvvv +18-19 l: llllllrllllllllllpgd +13-14 x: xxxxxxxxxxxxxxx +7-13 d: pcgbdmkhnnxqdhb +9-11 c: ccccccccjcf +14-17 m: mmmmmmmmmmmsmmmkmkm +7-16 p: jblsmjhskpmcflvzqbb +1-3 p: pqpzfpw +6-8 h: whhtglkhshhzhh +1-9 x: xxjxxxxxxxx +2-3 d: ddgwh +3-4 z: rzzz +12-13 p: ppppppppppppppkp +2-6 f: fbffjbxz +4-7 f: dmkrhsfnffg +4-6 p: ppppppppp +17-19 d: ddnwdddddddnddddndgd +4-8 n: bxchqdknggfjqzcvdwzv +3-19 z: zzzzzzzzzzzzzzzzzzpz +2-11 h: hhthvhrhpkhfrljhf +7-8 s: sssssgsg +1-3 p: hpsp +4-5 d: wdkdd +2-4 j: fjpd +2-8 l: dsvhdlpl +11-15 b: bkbbqpbqbbbbbbfbr +4-9 j: vffrxjvglzq +17-19 q: qqqqqqqqqqqqqqqqqqqq +2-9 g: sbpcvnmsghrm +3-6 r: kxwwnfbqv +9-12 w: qxwwwwdwwcww +4-8 t: tttztttxt +5-6 k: sklmkk +1-15 t: qttstmlgtxjfwthj +12-15 s: sssssssssssssssss +1-8 d: ddtddbddj +7-14 m: rmmhmmmmzvmmmkxmmmdm +5-6 n: nnnnnwn +7-8 m: mmmmmmghmm +1-3 q: qpqqgkc +3-10 q: qqqqqzqqqqqqb +1-7 p: ppppppqp +3-5 c: nbkfmcccpkjccv +14-15 q: qqqqxqqqqqqqqqq +8-9 p: plgpblsfp +10-13 w: wwtwwwwwwwwvwww +8-15 k: kkwjkkkknkdkkkkk +6-7 l: lllllmkl +8-9 l: lllllllxgl +10-12 p: gpmpppppppvpvpqpx +4-7 x: rxbxxxzqx +1-10 h: dhhhhhhhhxh +12-18 v: vnwvgvprbfgvvgnvvv +4-17 n: xbdnmnrrcfmczhjxndr +8-9 k: kkkkkckqskkk +9-12 l: rblxmkxmlfflnfpg +6-11 q: vqlqqqqqqqqqqqqnq +8-10 j: lxpjjjjjwjglcjhjjj +4-6 x: xtxxjx +1-2 w: wwwww +5-8 h: hhhhkhjhhwh +7-10 s: stjsssdssdl +2-12 p: xwnzxpzwnxzc +4-5 v: vkvvvvk +1-6 k: ksgmxkkdcfqgxcxm +16-17 g: ggggggggggggggggg +9-10 g: ggggggggmcg +9-12 m: mmmmjzmpmmmx +2-3 r: lrrlrtmbcl +2-3 s: sqss +9-11 k: kkkkkkkkdknkdpkbkkk +13-15 t: tttttttttttttttt +3-5 p: ppkfkn +4-5 d: dddtk +9-13 b: hbmtbzspcqtwqfkbbbdb +5-7 d: dddtddhdddddddmddddd +6-7 q: qqqqqsl +8-9 k: kkkkkkkkk +3-7 d: gdcwjglkw +6-8 s: srtgjdsn +8-9 r: fxrgqrsrs +5-10 x: xxxxlqxxxxxxxxx +2-3 s: ssskpmzhqpp +2-10 q: qqqqqqqqqqq +5-12 r: srnqrrhkgrjr +1-3 s: fsmsssss +1-2 f: ptbtfm +9-10 b: lbbgrbqhnhbcnmb +1-3 x: xxnx +1-3 w: gjfh +3-8 q: qwqtdvqql +3-5 f: zfmcgpdlp +6-8 h: vhhhhhbh +4-12 c: lkbcvnztjnpxvlcf +4-6 w: wwwwwwwpwwd +10-15 v: vvwvvvdvvzslhvz +4-7 c: jpvmlffcgdkmcl +6-7 l: llllwlll +8-9 m: mmlmlmmnmmm +14-15 m: mmmmmmmmmjnmmmmkz +3-6 t: thttttt +3-14 t: kvltjtmkbvhtbt +6-7 j: jjjjvjjj +5-6 m: dmnmmmknqwmmmkm +8-12 s: ssksssssssssr +2-6 r: srvrqrdwxnprrvpqhd +6-11 l: lhllkdxlllln +2-4 t: qmmd +3-12 s: sssssssssssrs +17-18 t: ttttttttttttttttqf +2-5 r: qcbrr +14-16 h: hhghppchchfhhhlhm +15-17 g: nprhksgfwwjgggkkc +7-8 g: gggggggn +5-15 g: drgkscpgchvzmjs +1-3 l: fsztllllll +4-5 p: ptftp +5-6 j: jjjjjj +1-4 f: ffjfhz +9-10 q: qqtqwslqqg +6-20 h: hgklqhcmhfmxvcnxvxch +7-8 c: jcwbrvcc +8-10 m: mwmmmmmsmvmsf +8-9 v: cfvrvbvzvvvgvpk +14-17 s: srkhgbthtssxszqvsbsx +4-7 b: sbpffpbxv +9-11 z: zzzzzzzzzzzfztz +9-12 v: hmvvvvvvgvhkvvcvvvb +1-6 c: fkcjcwqccs +13-15 r: rrrrrrrrrrrrrrrrrnr +3-4 g: ghgg +6-7 b: wbbbbbbbbbb +7-8 t: trttdtttjbktt +3-4 t: wtttct +2-4 c: xccc +5-7 s: ssspvlrslxn +1-3 s: lsss +4-6 h: hjhjhghh +11-17 s: ssjrsscslskssqssn +1-4 j: rzjjjv +7-8 f: tvssgbrkqdtc +5-8 w: wrjklbblzwdclwnwjwx +4-8 r: srrrrrrr +1-7 g: ggggggg +7-9 m: msmcmmmbwgxkmmnmm +7-10 w: wrwwwvwwww +7-11 g: rgkzgdgpldgc +11-16 p: pppdpzvzpppqrwppv +3-5 n: hnnnnn +10-12 n: nnnnqnnnnmnwnn +6-9 k: spdbkgkxzlqkkkkk +2-5 j: jjjjjjjj +2-4 n: njnzn +7-8 c: cclmcchjcbc +13-16 k: jkrxkmtxfkxfccdklk +8-9 f: fffffffjkfffnpffvfff +8-10 x: xgmdzfxxsc +7-12 k: fknkjrklsrkkkhqknkv +10-12 l: lslzlpllblllll +3-4 f: fffvfff +16-19 j: jjfjjjjjjhjjjjjjjjj +1-3 h: hhhhhhhhhhhhhhw +8-11 n: nnntnpdnvkqt +9-10 n: nnnmnnnnnnnnnn +3-5 c: qbcccchvccf +8-9 s: sssssjsmqj +4-5 w: zwwrxwwfwpwwz +7-9 m: mmmmmmvmf +5-9 w: wwwvtwwwm +11-13 j: zjjjjjjjjjjljjjcjjj +2-9 c: zblcmvmcfc +16-17 g: gggggggggggggggqk +12-15 p: pfcpppsgppxbjvqppppp +4-6 l: ssldtlc +5-8 h: shtphhdhhhhm +17-20 n: nnnnnnnnmnnnnnhnsnnp +12-17 s: sscsrsssdsssssrssss +2-9 j: tjlffpwkjmnj +1-6 p: cpxfpdvjb +10-14 b: bbbbbbbbbhbnbbsbb +3-4 h: hhhnh +1-3 j: rkgjvqkgs +16-17 w: wjwzdwwwwwsxbtlfs +9-11 r: rrrrrrrrrrrr +1-5 d: dtzqdd +5-7 p: pprpppp +6-7 n: nnnnnnn +1-10 k: kkgcklpqzkk +2-4 n: lvxnntjnpwhrsxlnhn +3-6 h: hlhhhxhzh +6-7 c: zccccccc +1-4 z: ztczzzzzzzznzztnlkjz +5-6 c: cccnccshkcpgjhn +3-4 h: hhbh +1-4 m: gmtm +13-18 d: tldhjsdhdthhldzfgjxg +4-5 d: dddddd +1-3 r: rrrr +7-8 b: bbbbbbbt +12-14 z: zzqzbhzzzzzzzz +5-7 v: vqblwrw +8-9 c: tccccdcrccccqc +9-11 m: mmhmmmnmqmtm +3-10 n: dnwzhrfnqt +3-4 t: xnkfpcqtcqkctxrrm +2-7 l: lllllllll +2-7 g: rdnskwgwcgnrzncqtnp +11-13 s: ssssssssssqsw +10-12 m: mmmmmmmmmcmqqmmpmm +4-8 n: gnqnptxnhgpnnnn +6-7 t: tttttcct +2-3 s: sssssss +9-10 h: hhhhhphrms +3-6 d: vdxdddddd +8-15 k: kkkbkkckkkkkkzgkkk +4-10 n: ncntnnnnnnn +3-9 r: snrkcrrcvrx +7-11 s: sssssgwsshks +1-4 h: hfch +10-18 l: llllxllllflllfllsnll +13-16 x: xpwcxpxxxxfqxnxx +2-3 m: mvmmm +3-5 l: ljlzs +8-13 t: tgttttmmrfthttwt +2-9 t: vttjddjxtfrlw +3-5 r: frrrr +4-5 s: pssnm +4-5 h: jcphhsnrm +2-3 d: pjdd +2-3 g: gdgk +10-13 v: svtvvvvvxwvvwv +4-5 l: lqlll +13-14 s: sffbffsmssscss +2-3 j: fkkfmzqjnfvdjr +16-18 z: zmqzzgzkzzzglhzzlzj +3-4 h: hhfh +11-13 s: sssssnsspshswhsssss +7-9 g: gvgggrmgzr +1-5 p: hppxnlkgcpppppppp +1-13 q: qqqqqqqqqlgqqqqqn +3-5 x: xxzxpx +3-15 x: xcndrhtnpbqwgsxtzqn +9-13 d: nrhbddvslmwbs +8-10 g: grggggxggxgg +10-11 h: hrfprqnhbhh +2-3 r: rpzr +14-15 d: ddddddddrdddddd +7-8 b: zbbbbgbbbbpbbv +12-18 v: vvvvvvvvvvvfvvvvvvv +7-13 r: snkkjtnkrntjfd +1-7 g: ngdndgg +1-10 h: hhzhhhhrhhhhhhhh +6-7 x: dxrxxzs +6-7 x: xxxxxxxxxx +8-11 v: vcvvvvxvvkcvlvvvvvv +3-4 n: nrzh +8-12 x: xxxpvxxttxxfmnx +9-10 r: rrrrgrrrzr +2-8 v: lbtvvvzqvzsg +3-5 d: dkfbwlrg +13-14 k: kkkkkkkkkkkkkk +6-8 x: xqgbwxxxppgxz +1-4 n: pnnr +6-9 l: hglpllcnl +1-4 x: xxxx +3-5 n: lnzwmhjnndjdmknnqtnc +8-13 t: tttttttnttttjttt +7-11 s: ssssssssssvbn +1-5 l: lllllll +2-6 v: rvvzvvzcgv +6-8 c: tccckcrc +2-3 q: wnqq +2-3 p: pplpp +3-4 f: kxfwcfsk +1-6 m: mmmmmm +3-4 n: zgnnprvnns +17-18 z: zzzzzzzzzzzzzzzzwhz +3-11 w: wflwwwvwwhrgwwrwwwww +9-13 g: ggggggggpggggg +2-6 r: trvcwrr +5-7 p: prtjptws +7-10 b: bfbjwjlkbsbbwgk +3-5 z: zzzzzzzzwhzzzdznz +4-7 p: lphppppppp +4-5 n: nvnnnsnn +7-9 b: znbhbtgbw +1-11 w: jwwwwwwwwwgw +10-13 w: lwwwwwbwmwwfqwwr +5-12 p: ppppqppppppt +1-10 j: jjpjjjjjjjjjjjjjjj +6-9 g: gxgfgjmggggg +7-12 c: cdccccgcccgc +7-15 m: mmmmmmmmmmmmmmmmmmv +4-7 n: ndwjpvgnh +5-9 s: cszftmnqmssfqs +1-11 m: zmmmcdcmfmdbmltmf +16-17 s: zrshsssxssssssxfs +6-17 m: kphrlmrcmpskjcmmmg +3-4 j: jxjj +2-3 f: ffbfs +4-7 v: vvvvvvvv +1-7 f: fffffffff +1-17 d: dtdftddsdddddddsdd +8-10 c: ccrccccccsc +2-8 m: hqmmmmmpm +2-5 j: jjnjjjj +7-8 s: vsszssssss +3-18 g: ngpggmgggggggggggfgg +14-16 r: rrrkrqrlrrrjrrrpwtr +2-3 h: hshs +10-16 r: mrxdnzxmvrplhmrr +6-7 q: hwqmqqqqqql +3-6 z: rgtqkw +1-13 k: lkkkkkkkkkkkckkk +3-5 t: ttxtt +3-9 s: ljsvzbfwshssrc +6-7 z: zbwzjgw +1-11 n: ptnqltlkrxv +8-9 l: lsllllllhl +2-8 v: vvvvvvvzvvv +5-8 s: ssslnsssssssssl +7-8 k: kpkkkkkchlk +15-18 v: vtvvvvwvvvvvvmvvvb +11-13 m: mqmpjsmmlkvnmnfmwqmq +14-15 k: kkkkkkkkkkkkkljk +13-14 t: tffbtznjgtcnts +5-6 z: kkkpzzctq +4-5 h: jhbhzr +5-7 v: vqvvgxv +6-10 d: dddddpdddtdd +11-12 g: ggggggggggvggg +13-18 f: ffvfffxhrfhrcffpgnff +6-10 x: nsxgwsjxfthhxxgxg +2-5 w: wfvpmwtwg +9-10 l: lljwlllfxcll +2-5 b: rbbbmbbbbbbbbbvbbb +5-13 p: jjffpmbpppmtpf +1-5 r: rrzrrrrkrr +1-2 m: mmmmmgmm +16-18 z: zzzzzzzzzzzgzdzqzz +6-7 l: llwfxll +6-9 j: jjzhjjjjjjj +4-7 k: hwskvkk +2-3 d: dddddq +4-6 b: bbbbbbhbbbbbbbbbbbbb +7-14 l: lnhmlwzxlsldlx +2-4 m: msmmh +4-10 z: vhkrzzcbzzrzdcq +4-7 p: dnppppwp +5-7 z: mzzzzzzz +5-7 b: bbbbbbb +1-5 t: rrbtt +7-11 x: bjxqxtxzlfxpmkpqtnd +7-9 k: kkkkkkkkkk +8-9 d: dhfddpndbhqdtdwdtn +18-19 k: tnkzkdkkkgkkbckkkkk +8-11 f: cfnqkzffgxf +2-4 x: xxwxxsx +8-11 m: mmmkmpcmmvgxmmmcmm +13-14 z: wfzlzzzzzrdxzlzz +2-4 n: frns +4-5 q: qhqqqq +12-18 w: fwwwwdxxzvzzgwpwlk +12-13 n: nnjnnnnnwnnxgnn +8-11 c: tcjcbcwctkccr +4-6 m: jvmhtq +1-2 b: bbbbb +11-12 q: vqfqvqdnsxqq +7-9 m: mgmjmtmmzmmhrm +9-10 t: ktvnttttxl +8-10 r: rcrrdrrdgsrr +7-8 m: bvlmhxfxnlmfbz +3-5 c: bhczc +1-3 w: nwwnwwxww +3-5 l: jcllld +1-10 b: bbtbqbtbbbbtbbbbbbb +5-7 x: vsxxxxxx +3-4 k: gdkv +8-10 k: kpkkwzkrkjkkkm +3-6 l: hhlmll +16-17 x: xxxxxxxxxxxxxtxmx +1-4 w: wrkw +1-4 t: gzpkttttt +2-3 z: zzzq +13-14 q: qqqqqqqqqqqqqq +2-19 d: vdwfzsfqtqbglgrfdvd +4-6 x: dxtnxzx +3-5 g: ggggg +6-7 m: mmmmmjj +15-16 t: tvtttttvbttttttt +5-6 k: kdztgkx +1-3 d: dddd +5-14 h: hhptkkcpqphhdgw +13-14 j: hvmrjdcjhjjfgbmw +10-14 h: hhbhchhhhwhhnhhhthh +2-3 f: jcstlgbdf +3-4 w: kwww +2-12 b: bbbbbbbbbbbfbbbbbbbb +2-4 x: xxxs +10-11 c: qmrtcpztvcc +7-12 l: llptfltlllllzllzl +14-16 m: mmmmmmmmqmmmmtmr +10-18 m: mgmmmnmmbbvmmmmmmgmm +4-18 q: kqlrkhrqljbgwpmpnq +3-4 c: czcdc +2-13 k: jnmzxwvgfldnz +11-12 b: bbbbbbrbbbbb +6-11 p: psfpzrpfpqkzpvppt +9-11 p: mpspjjxcpqpdppppph +4-17 t: tdtftttttttlttdtttwq +12-15 r: krrrrrmrrrrdrrmp +2-3 x: xczx +1-7 j: mjjgjjdjj +2-8 x: jmlxxxxxxxrxxxx +6-7 l: qntxbml +7-12 k: kkkkkkvkkkkfkk +2-7 z: nsgtlfdrsp +7-9 m: mvmmgmjmm +3-7 t: ttttttt +2-9 b: gbczjbbbblbbb +8-12 j: jjjjjjjljjjsj +9-11 h: dmrjmzdwhhhqz +6-10 j: jjjjjjvvjfcp +1-6 t: tqsznxwnnrnmjt +5-8 f: rpffhjnlkxplffhm +8-9 d: fddddddddddcdndddrdd +4-5 k: jkkfckkk +3-5 l: llglkqllll +3-5 k: zkzknkkk +5-7 d: nddddnq +9-10 j: vjgjlfcjjjfxjjmjrzwk +2-4 m: fdxm +5-7 c: cvqgkhvtbccc +7-20 j: rscsdsjzflbldrwqvkjj +4-5 p: pbxpppp +3-4 h: vnhhvlbtbqshhcsxhs +4-12 k: hkdkfxkknkkkkck +4-5 g: gggvq +4-5 h: zhtch +8-12 m: tpmmxzmgmmln +9-15 c: ccckfccjznpclnccxc +9-12 p: pppppppptcpfpppppppp +15-17 g: ttdlnvrknskcgvrgnm +7-12 r: rrrrtrtrrrrjlrrr +4-5 c: rccclxc +3-5 d: hbgzddt +4-5 x: cxxxx +3-4 k: kkpc +8-9 j: jjjjjjjrhv +5-6 p: ppcppp +14-15 h: hqhhhhhghhhhhlrhh +5-10 z: zzzzzzzzzzzzz +6-7 m: mhdmmzpmmmp +1-2 j: knjj +2-7 m: mmqnmjmtkz +2-3 j: jzjjjjj +12-15 g: gggggggggggngggg +6-9 h: hrtllxbqgcrf +3-4 c: ccccc +7-11 g: jclgcjgngkzggg +6-9 s: qwnvpsvbsmwqpqrst +17-18 k: kpdkzkkkkkkkkkfkksk +1-3 v: svnv +4-6 k: kkndkkkkk +12-15 z: zzzzzzzzzzzdzzzz +3-9 z: zzzzzzzzr +7-10 w: vgwwwcwwww +10-15 n: vgxnnnqnnnhwsbnxpnnk +2-4 v: fxhvh +11-12 h: hhjhhhnchhhhhhhh +3-9 z: vzzczzzkzbh +5-8 k: kskkkkktkk +3-7 s: sswssxt +4-7 g: rggdggg +4-7 c: zccpcccc +6-11 z: mzlrssckpzvzslcwzzzz +8-9 v: vvvvvvvvvvvvvv +1-4 f: fffffffffffffffff +8-10 f: tjfffmgrfl +3-5 k: kfwnp +6-7 t: pvtstmq +3-7 x: cvxkwxxgpjxskkvsxp +1-7 c: cctcckccccxc +1-3 g: vfxvfxmhpgg +13-16 m: fmjplfbgzzkrmcmv +3-6 l: llmllc +17-19 j: hjzjrbpjzjdjjvbzjjv +7-12 q: qqqqqqqqqqqq +9-13 n: nnnnnnnnqnnnxnnv +17-18 n: nnnnnnnnnnnnsnnnzh +6-15 f: rswffffffkfffkxfjf +3-6 v: vvvvvvv +9-11 d: ddddddddmdf +19-20 k: kkkkkkkkkkkkhkkkkktg +9-11 f: ffffqfffnfl +6-9 r: rrrrvrrrr +5-6 g: kgdfggggng +17-18 w: wwwwwwwwwwwwwwwwrm +5-14 t: tttttttttttttqtt +13-15 n: nnnbnnnnnnnntnn +4-13 g: rlhgcffsgshcg +4-12 z: mbfztgsbkscpqwl +18-20 p: mmflppmwzscjcgsxdddd +1-6 k: kkkkkkkk +18-19 n: qxkljbmdgsfsnknfhjb +1-2 h: nxnhh +2-11 f: fxffffffffxffffkffff +4-11 k: mqvktsksvkkwjbtvg +13-14 m: kmtmzqmmjmmmmmmwkm +3-5 t: ttswxtt +11-12 b: bbbbbbhbbblbbbb +9-10 w: lkhccgmwvd +2-3 t: thttl +12-13 b: bbbbbbbbbbblb +8-9 w: wdwwjbwblwww +4-5 h: hqphz +9-14 h: hhhhhxhhzhhhhht +9-10 x: xxxxxxxxxxx +4-7 m: dgltmmrdvmfmd +9-10 h: vltrhtgblsmlmnbvml +6-10 p: gkpppbppspp +8-9 c: scjdvbpwn +4-15 f: fpfnffffffffffhn +10-14 s: sssscswsssssss +4-10 j: jxdjfscnmgj +6-12 w: ksjdxwckwwwwwfzwsgz +1-8 j: jjjjjjjtj +1-3 d: kgpvfv +2-12 w: wwwtwwwvwwwwrwwwwww +4-6 f: fkbdftxqtxjwfvf +7-8 p: pppppppk +12-14 g: gmgvgffnggjkgggg +3-4 x: wxkgxxxx +3-7 n: nnnddmcjcrtnnfhnx +4-5 k: kkbmxkk +12-13 b: bbbkxbbbbbnbbtbbgb +9-11 h: hhhhhhhhhhhh +4-6 q: lmgvsfqxmqhvzqqt +13-15 t: ttttvtttttttfhm +1-3 x: hxlw +9-14 v: gjrvgrmvvvdcvv +5-15 z: zzzzczzzzzzzzzzzz +1-8 s: tssssssss +10-15 h: vhvhxthvhhhchhshfh +1-9 l: lllpllqklmlk +12-14 z: zjzzzzzzzhzkzz +3-8 w: wlzzflnmflwdnp +5-7 s: sgsdssss +5-13 h: hnhshhnklhqbhh +4-6 b: xsbbbxbbpbbbbb +14-16 c: cccjgccccccccmvc +5-11 r: nrrrrrrsdjrrk +6-12 s: gssjtjssfhjsssssss +5-6 j: jjjjrs +14-15 d: dddddddddddddddd +10-11 z: zczzzzzzzzzczzzzzz +2-4 q: qqqj +7-13 f: fffffhfffffff +13-14 q: qqqqqqqqqqqqjfqqq +8-9 w: wwwtcwqjw +5-6 x: xcrfxx +13-19 r: rdwfrghfrcnjcdjxtrmr +6-9 h: hhdhhhmlg +7-11 p: ppgpppgppdq +5-6 m: msmrtxm +14-15 j: kjkzrslzdzgrfjjjj +14-15 f: fqjfffwsffzhmff +15-16 d: ddddddddddddddvmdd +10-11 w: wslwwcwkzrvkg +1-3 v: kvvvv +6-12 q: qqqqqbqqqqqzqqqqqq +15-17 m: mmmmmmmmbmmmmmfmxd +1-10 t: sttttttttvt +8-9 q: qqqqqbqwq +14-15 t: ftgtttgftxttwtt +5-9 p: bzkpxnfnj +2-9 h: hhngqknrhd +10-11 h: hhhhbhvhqhhhh +5-8 v: dvstzxwtp +3-5 q: qmzpbmmwsqwzr +7-8 r: rrcrrrrr +3-4 w: wwwt +1-2 l: pzzl +4-13 h: trpbbrhnxnkbrkmgdk +4-5 v: fgxmv +5-11 d: dddgddxrdbmsddj +7-8 s: ssssssss +5-7 m: dfmksgsdmcbjrmk +4-7 s: tsqcssrzs +4-5 j: jjjjjjl +6-10 s: vkwshtpqjxslssxm +3-4 z: zzdfzz +1-5 m: fkhmw +6-11 f: twtfbvwbbsfff +2-9 f: fzwfjljxfxfkjfl +1-2 d: ssddd +5-9 k: kkzkscklbqtkkk +6-16 v: vjfbmnplzwtkxlvdqwn +5-8 g: ggnlkgdh +11-12 s: qbswtxnplqss +3-6 r: rrrrrr +10-11 w: wmhwswwwwfwww +3-9 c: tcncldghxp +3-8 q: wqtqgbpz +17-20 b: bbhblqlbggtsqcbcbbkt +7-15 f: fftffcxgfzttffmbrff +11-12 v: vvvlvrvvwvvqskvvxv +9-11 h: hdjcxnkhxhkqhh +5-12 l: llllqllllllnl +17-18 z: zbzzbzzzzzzzzzzptc +2-6 c: cgmrpjdhkcp +4-10 x: xxxjxtxvxxvx +11-15 s: sspsvsjsssskzbsss +2-4 z: rsfd +4-16 r: rrrrrrlkrrrrrrrrr +10-11 x: xxxxxxxxxpxxxxx +1-10 j: tjjsvjmxcb +4-5 t: tttbbtvttptttsthw +7-11 m: xmxzrnmksbm +2-6 t: vxdspsgtftlptvqft +6-10 k: kkkkmmdkkl +3-5 l: sssglkvfvdskkghdhkxs +4-6 m: mljkmwmnmm +4-7 l: lllllrh +5-11 x: bsmxjxxcmcxxx +1-2 t: tttt +9-11 p: xpppppppcppd +15-16 w: wxzxtwzjrmvkwzdwjt +13-15 l: pnhkxsqfrldsltltcf +4-10 v: vvvrvvvvvvv +6-11 m: qpbmsmbsxpmzg +1-7 m: tmmmlmcmmm +10-14 s: ssshsssscxssszs +1-7 q: tdqxmqkxgkt +2-4 m: bcmq +3-4 d: ddjd +13-17 r: rrrrrrrrvprrrrsrx +3-8 p: fjwbkcdt +1-6 k: gskwbl +7-8 z: wzgzhlzs +5-6 v: xvvvlmvvsvbsv +1-18 f: ffjcfbvrtftffxvfff +3-8 l: lbtjlllqc +4-7 v: vnvvdsvl +15-18 d: ddddpdddddddddcgdrdd +3-9 f: fffffffff +1-5 v: svvjvvlpvwmvvgc +13-14 z: zzzzzzzzzzzzmz +6-8 p: zcwptpgppfpppc +8-14 j: cjrzvhjjmdpzjjqs +16-19 s: sszsssssssssssssssss +7-9 r: rrrkrrrrrnrrmj +2-4 l: ldln +3-5 p: pppvprp +1-5 k: kkkkkk +1-4 g: ggxz +2-4 x: xwsgv +15-16 v: vvvvjvqvfsktgvlvvvv +17-19 x: xxxxxxxxxxxxxxxxcxx +1-8 m: mmmmmhmpmms +2-6 f: lffzdfsf +2-3 p: jphqlvzfmpnmt +2-11 g: ggrjthgdmggkgssq +5-6 r: rwgrrr +4-7 t: tttptmlthlfst +5-7 v: bhhdvhhv +8-11 n: nnnnnnnmnnnnn +7-20 r: rxrqlrwrnrsrrvbvtrrm +9-13 s: pfslddbsshsssrsrssls +3-10 q: vwbwhvdfqqvghjzf +9-14 b: bbbbbbbbbbbbbvb +2-3 f: pfff +3-9 r: trhrrrrrgrrn +7-11 z: zzzzzzzzzzzz +4-6 s: xwssttdqtc +7-9 t: ttzmqqdtqtt +6-19 g: gggggggggggggggggggg diff --git a/2020/02/sol1.pl b/2020/02/sol1.pl @@ -0,0 +1,15 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +open(my $fh, '<', 'input') or die "$!"; +my $n; +for my $line (<$fh>) { + chomp $line; + my ($min, $max, $goal, $pass) = $line =~ m{^(\d+)-(\d+) ([a-z]): ([a-z]+)}; + my $count = () = $pass =~ /$goal/g; + if ($count <= $max && $count >= $min) { + $n++; + } +} +print "$n\n"; diff --git a/2020/02/sol2.pl b/2020/02/sol2.pl @@ -0,0 +1,13 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +open(my $fh, '<', 'input') or die "$!"; +my $n; +for my $line (<$fh>) { + my ($A, $B, $goal, $pass) = $line =~ m{^(\d+)-(\d+) ([a-z]): ([a-z]+)}; + if ((substr($pass, $A-1, 1) eq $goal) xor (substr($pass, $B-1, 1) eq $goal)) { + $n++; + } +} +print "$n\n"; diff --git a/2020/03/input b/2020/03/input @@ -0,0 +1,323 @@ +.#.#....###..#.#..............# +#......#####..##.##.#.......#.# +.###.....#..#.#..#..#.#......#. +.........##.#.....#.#.......... +........##....#.......#.#..#..# +#.#..####...#.....#.#.#...#.... +#....#...#.........#.....#..#.# +.#..........#..#.............#. +...##..##..#...####.#.#.#.#.... +.#...####............##....#... +..##.....#.#......#......#.#.#. +..##......#..##.....#.#.....#.# +..#...#....#.#.........##...... +#..##..##..#..##....#....##.#.# +..###.#....#.#.#...#......#.#.# +....#...#...#.........#.....##. +.#..#.#..........#.##.....#.#.. +.#...#...###..#..#..####.#...#. +##..............#..#.#...###..# +.#..#.#.#...#..#...#..#........ +..#.#......#.#..##...#.#..#.... +...#.#.....#.##..#...#..#...... +...#...##....##..#....#..#...#. +#......##.#.......#...#..#.#... +.#..#......####...#............ +...#..##.#...#....#.#.#.#...... +....##...........##.#.#...##... +#.##.###........#..###.#..##... +....#......#....##...##.#...... +#.............#...#.........#.. +..##.......#.......#.#...#...#. +...#....####...#...#....#.###.. +...##......#...###.#...#....#.. +...#.............#...#.......#. +...#..#.##.##.#..#.##.#..#....# +..####.....#..#............#... +##....##..#.#.#.#..#..#.....#.. +......##...##......#.#......... +#.#............#.#.#..#......#. +...#.#.#.....#..#..#.#..##..... +.#.#.............###..#....##.. +....#.###..#..#.....#..#.##.... +..#.#....#.......#.......##..#. +.#.##.#.#..#..##.........##.... +...#...###.##....#####.......#. +......#.....##...##...#....#.#. +###.......##..#.....#......#.#. +...#..#..#....#.#.....##..#...# +..#....##.......#....#......... +#....##.........##......#.#..#. +#.....#.#.#..##..#.#.....##.... +......#....#...#...#.###....##. +#...####...###.##..#.#.#..##... +......###....###..##......#..## +.#.####.###..#.....#...#..#...# +.###.#.....#..#.#..#.....##..## +...##...#.####....#......###... +...##.......#.#..#......#.#.... +......##....#......#.........#. +............#....#............# +..#.#..........#......#..#..... +.#...#.#.#......#..##..#....##. +..##.#.#.#..#...###..#.#.##.#.. +..#......#.........#.......#... +...#...##.#.##......#.....#.... +..#.....#..##....#..##..#.#.##. +....##....#.#...#..##.##.##.... +..#.............#...#......#... +.#.#.#.##..#.#..##...#......... +.##...........#..#.#........#.. +.#..##.....#....#...#...#...... +#.#.....##.#..#...######....#.. +....#..#...##...#.........###.. +..##.#...##..#......#.##..#...# +##..##...........#.......#.#... +.......##..##...###.##.......#. +.#.##...#.##...............#... +.......#.............#.......## +......#...........#...#..##.... +.#..#..#....#..........#......# +...........#..#.....#....##.... +###....#....##..#..##.....##... +#........#........#...#.##.##.. +##.#.#........#..#.#..#.......# +.##.#.....#............#....... +.....#........#..##......##.... +.#.####.#.##..................# +#...##.......#...#....#.#.##... +#.#.##...#.#......#.....#....#. +.........#....#...#....#.....#. +...#..#..#.#..#.##........##.#. +..#.##.#...#...#....#....##..#. +.#..#...####..........#.......# +....#...#...#...##.#.##......#. +.#....#...#.#..##..##.#.....#.. +.....#....#......#.#####...###. +..#...##..#......#.#....#.....# +.##....##..###.#.....##.##.##.. +#...#.#.........#....#....#.... +...#.........#.##....##.#.#.#.. +...#...#.#....#..#.#.......#.#. +#......#..#....##....#......... +...........#......#......###..# +#..#...#..##..#....#.....#.#.#. +#.#.....##..#..........###..#.. +#...#.....#.......#..##...#.... +...#....##.....#..##..#....#... +#...#.#......#..#...#........#. +.#....#...#...#.........##....# +..##...#.........#.......##..#. +......#.......#.....##....#..#. +.....##..#...#............#.#.# +...#....#.##..#...#.#....#..... +...#...........#.##....#..##.## +##......##....##...........#.#. +..##..##......#...#.##.##..#... +.#..##.#...##...#......###.##.# +###.#....##..#..#.##..##...##.. +..#........##.#...#.......#.... +.....##....##.#.###.....#....#. +#.##....#....##.....#..#.#..... +#.........#..##...##.......##.. +.#....#......#.#...##.......... +##..##.....##....###..#...#.#.# +..##.#.#..#......#.#....###..#. +.#.##.....##.......##.#.##..#.. +..##...#........#.#.#.##.#..### +........#.......#...##....#.#.. +...#..#...#.##..#...#.#.###.##. +..#.#....#..#...#..##.........# +#....#..##..##....#.........#.. +.......#.......#....#....#.#... +...#.##...#...#..#....#.###.##. +##.##...#..........#....#...... +#.##.#.....#..#............##.# +.##...#.#.#.##...........#..##. +.#...#....#.......##...##...#.# +.#......#..#...#...#....#.#.... +...#..#..#...#..##..##.....#..# +.#.##..#.#...#..#.#...#...#...# +#.##..........#.##..#....#..... +##....#.#..........#..#....#... +..#..##.#.......#...#.##......# +....##......#......#.#.#.##.... +###......#...##..#..........### +##.#.##.....###.#..#.#......#.. +#.#.#........#..........#....#. +...#.#..#.......#......##.#.... +......#.....#.#.#....###..#...# +.........#...#..#####..#.#..#.. +..........#.#.#####.#..#.....#. +....#.......#.#....#.....##..#. +#...##.#..#.#........#.#..#..## +#......#..#.#.....##......#.##. +.##...#....#.##..#.....###..#.. +#....#.#..##....##..#.#####.... +.......##..........#......#.... +......#.#...#............#..... +.......###.....##.#..#.#....#.# +...#...#..........#....##...##. +.#..#.#.#....#.#.....##..#.#..# +......#.#..#....#..#...#....... +##.#####............#.#.####.#. +#.....###.#.......##...###....# +......#.##..##.........#.#..... +.#.#......#..#.##......#......# +.#.#.#..#.#...##.....#..#.#..#. +.#.#....#...................... +#.#..###...#...####.##.#....#.# +.....#............#....#..#.##. +#..#...#.#....#....#..#..#...#. +...#.......#..#.#....#.......#. +.#..#.#...#.#.####..#...#....## +....#..#..............####....# +.....#.#.###....#.#.#.#...#.... +..####..#.#.##.##.##....#..#... +.#.#.#.###..#.##..............# +..#.#..#...#.....#.......#.##.. +.#.#..#.....##...###.....#..#.. +..#..#......#.##..#......##..#. +.....#.#.#..##..###.#.......... +.##......#...#.##.......#..#..# +.......#...#.....###.##...##... +..##..#.#.......#.............. +#.....#......#.#..#..#..#...... +..###.......##...#.##....#..... +.....##...........##.....#...## +.#.#.####....###.#.......#...## +#.#..##.#.#.....#.#....#....... +.........#.#..#...............# +..##.#..#..#####.###.........#. +.#........#...#...#...#.##.#..# +.#.##..........#..##....#.#.#.. +.##......#....#.#....##.#.#.#.. +.......##.####..#..#.#..#.#...# +...#.....#..##..###.#..##...#.. +#.......##..#####....#.......#. +#.#.##.................#...###. +................####........... +.#..#......#...###............. +......#.#.##.##.....#.......... +.......#..#.#............##.... +#........#..#....#......#.####. +...#.#....##..#..#............. +..#.#......#...#.#..#.......... +###...###...........#......#... +#.###..###........###...#..###. +.#.....#...#.#...........##.... +....#..##.....#..#......#...... +#.###.#........#.#.##.......... +#.#.#.#.#..#.#...#...##.#...... +..###.......###..#.#.#.#.#..... +...#........#.......#.###..##.. +.#........#...#.#........#..##. +#.......###..#....##.###...#..# +.##....###..##...........##...# +#...#..........#.....#..##..#.. +#..##..#..##.#.........##...... +..#.#..###..###.....#.......#.. +#...#...........##.#.#.###..... +...#....#.....#.....#.##.#.##.# +...........##.......####...#..# +#.#...#..##..#.#..#..........#. +..#...#.##........#.#.......... +.##.....#.#.#....#.#.......#.#. +.......#.##...#.##....#.#...#.. +......#...##...###...#.....###. +##......#.##.####.##...##...... +..#....#.#..###.#..##....#..#.. +...##..###.....###.....#....... +...#.....#.#........#..#..##.#. +.....................#.....#.#. +.#...#...##.#..#..........#...# +#.....#..#....#..#.......####.. +.##.......##......###.#..#...## +.#.##..#...#..........##....... +...##...........##..##......#.. +#....##.##...#......##.#.##.##. +..##.##.#.#.#....#........#.#.. +....#......#......##..##.#.#... +.............#.##...#..#...#... +.#..#...#.........#...........# +....#.....#..................#. +........##............#...#..## +.###.....##...#...#.##.....##.. +...##.#.........##.#.#..#...... +#...........##.#..#........#..# +....#....#..##.#..##..#..#..#.# +#..##..#............#...#.#.#.. +#......#..##......#...##..#...# +....#.#..##.#.#...####...#..... +.##..#..##....#...#....#...##.# +##.....#.#........#....#.#.#... +......#.#...##....#.###.....#.# +..#..#............###.###.##.#. +#..#.##.##.##..#...#.#.##..#... +....#..#.#...#......#..###..... +.#........#...###.....#...#.... +....##.##....#..#...#.#####.#.# +...#..#...#.#.....#....#...###. +..........####...##............ +.....#....##...##......#..#...# +..#...#.####......#...#..#..### +.#.....#....#..#...###..#.#.... +..#..#......#.#...#.....##....# +.....##....#....#...#.....##... +#............##.#....#.#.#..#.. +#......#......#....#.#..##.#... +#.#......##.....#.#..##.#.#.... +.#.###..#.#......##...........# +#.#.........##..#.#.##......#.. +##....####...##...........#.... +....###.#..##.#.#.##...##.....# +..###.......##.......#......#.. +..#.###.##.#................... +...#.#...#..#..#..##.###...#.#. +#...#..#...#..#....#..#...#.... +....#........#.#.#.##.##.#..#.# +...#....#.#...#..#....#.#.#.... +..#...#..##.#....##...###...##. +#......#.....#.....#....####.#. +...##.#..#.#.....#..#..##.#.... +.####.#..#...#.#......#......#. +..#.#....#..#..##.#......##.... +....#...#.#..#...#...##........ +##..#.#....#..#.........#..##.. +...#.......#....#..##...###..## +#......##.#..#..#..#..###.#.### +.#..##.#...##...#.............# +###.........#...###.#.#..#....# +.#.....#..#........#.#.......#. +#..#.#.....#.........###..#.... +#..##.....#.#....#.###.....#..# +....#..#.......##..#.#..##....# +##.##..#....#..#.#.###......... +..##....#........#..#..#.##.#.# +.#....#...##..#.#.....#..##..#. +#..#.......#......#...#...#.##. +...##.#......#.#..#......#..... +......#...#.##.#....#...#.##.#. +#.....#..#.#.#...##...#........ +....#.#..#.#.....#....#.#..#... +....#.#...###............#..... +.#.#...##.......#....#.##...#.# +.....#.##......#.#..#...#....#. +.###....#...#........#......... +..#.....#..#.#.#..##...#..#.... +...###..#....#.....#.........## +#....#....###...#.#............ +.#..##.....#...........#.#..#.. +..#.#.#.......##..#.#.......... +.#...#...####.#...#####.....#.# +..#....##.....#..#...#......... +#.#......#.##.........#......## +..#.#...#.##..#....#....#.##... +#....#......##.#..#......#.#.#. +#.#.............##..#.#........ +..#.###.......##.....##.#..##.# +.........#........#...#..#....# +.........##.#.#..#..#....#....# +##..#..#.#.....##.........#.#.# +..##.##..#.##..........##.#..#. +...#..#####.......#.........#.. diff --git a/2020/03/sol1.pl b/2020/03/sol1.pl @@ -0,0 +1,16 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +open (my $fh, '<', 'input') or die "$!"; + +my $n; +my $i = 0; +for my $l (<$fh>) { + chomp $l; + if (substr($l, (3 * $i) % length($l), 1) eq '#') { + $n++; + } + $i++; +} +print "$n\n"; diff --git a/2020/03/sol2.pl b/2020/03/sol2.pl @@ -0,0 +1,40 @@ +#!/usr/bin/env perl +use strict; +use warnings; + + +# Read it all in +open (my $fh, '<', 'input') or die "$!"; +my $i = 0; +my @M = (); +for my $l (<$fh>) { + chomp $l; + $M[$i] = [split('', $l)]; + $i++; +} + +# Do work on the matrix +my @slopes = ( + [1,1], + [3,1], + [5,1], + [7,1], + [1,2], +); + +my @N; +for (my $k = 0; $k < scalar @slopes; $k++) { + my ($r, $d) = @{$slopes[$k]}; + my $j = 0; + for (my $i = 0; $i < scalar @M; $i += $d) { + if ($M[$i]->[$j] eq '#') { + $N[$k]++; + } + $j = ($j + $r) % scalar @{$M[0]}; + } +} + +print join(",", @N) . "\n"; +my $total = 1; +$total *= $_ for @N; +print "$total\n"; diff --git a/2020/04/input b/2020/04/input @@ -0,0 +1,989 @@ +hgt:176cm +iyr:2013 +hcl:#fffffd ecl:amb +byr:2000 +eyr:2034 +cid:89 pid:934693255 + +hcl:#b5c3db ecl:grn hgt:155cm pid:#baec97 iyr:2017 +byr:1939 +eyr:2020 + +pid:526669252 eyr:1972 +hgt:152cm ecl:dne byr:1960 hcl:z iyr:2023 + +eyr:2028 hcl:#c0946f hgt:73in byr:1926 ecl:#473aaf iyr:2016 pid:565318180 + +pid:472686027 ecl:oth iyr:2019 +cid:277 byr:1940 +eyr:2030 hgt:170cm +hcl:#62e117 + +ecl:oth +iyr:2017 +pid:938461813 hcl:#733820 byr:1959 hgt:159cm eyr:2022 + +iyr:2011 eyr:2021 hcl:z +ecl:hzl byr:2002 pid:17324328 cid:140 +hgt:186cm + +byr:2022 pid:3164234967 iyr:1984 +hgt:76cm hcl:6b3837 +ecl:#fa362b +eyr:2037 + +hcl:z eyr:1945 +pid:9247286687 hgt:75cm +iyr:1934 cid:326 ecl:zzz +byr:2005 + +byr:2005 +ecl:lzr +eyr:2021 pid:152cm +cid:254 iyr:2020 hcl:z hgt:157cm + +iyr:2020 eyr:2020 hcl:#18171d ecl:gry pid:914128753 hgt:168cm +byr:2002 + +hcl:#7d3b0c hgt:160cm eyr:2020 iyr:2015 +pid:054067854 ecl:brn byr:2023 + +hcl:#cfa07d hgt:157cm +byr:1994 eyr:2027 pid:344443856 +iyr:2016 + +pid:762423097 +iyr:2014 hcl:#a97842 ecl:brn hgt:180cm byr:1927 eyr:2021 + +pid:6645616064 hcl:#ceb3a1 byr:2030 +eyr:2032 hgt:158cm iyr:2012 +ecl:#e9619e + +eyr:2022 +ecl:brn +byr:1986 +hgt:161cm cid:99 pid:288726584 hcl:#6b5442 iyr:2019 + +cid:75 +pid:117771843 +hgt:184cm byr:1937 ecl:brn +hcl:#d88fd9 +iyr:2015 eyr:2027 + +iyr:2016 hcl:#fffffd hgt:170cm eyr:2022 ecl:oth pid:629454113 +byr:1952 + +hcl:#c0946f iyr:2018 hgt:189cm +byr:1971 ecl:oth eyr:2029 +pid:800207810 + +eyr:2022 hcl:#7d3b0c pid:969986413 +byr:1978 iyr:2020 hgt:186cm +ecl:gry + +hgt:171cm byr:1949 hcl:#341e13 +ecl:amb eyr:2030 pid:359107274 iyr:2013 + +pid:839751525 eyr:2024 byr:1921 +iyr:2012 ecl:amb hcl:#b0ed6f hgt:154cm + +pid:32592758 +byr:2009 +hgt:107 iyr:2019 hcl:#866857 +eyr:2036 ecl:amb + +eyr:2040 hcl:#733820 cid:199 +byr:2027 +pid:7791792988 ecl:blu iyr:2026 +hgt:63cm + +iyr:2011 cid:119 pid:344693475 +ecl:grn hgt:160cm eyr:2029 hcl:#346973 byr:1996 + +hgt:161in byr:2025 cid:167 iyr:2024 eyr:2040 pid:034804648 +hcl:#efcc98 ecl:oth + +ecl:#ba14f0 iyr:1935 +hgt:60cm +byr:2003 eyr:1987 +hcl:8e509b pid:161cm + +iyr:2018 pid:620508652 ecl:amb eyr:2023 hgt:183cm hcl:#a97842 +byr:1967 cid:117 + +eyr:2022 ecl:amb +pid:476049089 iyr:2012 +hgt:165cm +byr:1955 hcl:#602927 + +byr:2014 hcl:z iyr:2029 cid:279 pid:28914607 hgt:75cm ecl:xry + +hgt:156cm eyr:2023 iyr:2011 ecl:oth hcl:#7d3b0c pid:561313217 byr:1952 + +iyr:2011 byr:1935 +hcl:#cfa07d ecl:oth pid:830614209 +eyr:2028 hgt:173cm + +iyr:2012 cid:210 eyr:2022 +pid:652810130 hcl:#18171d ecl:grn byr:1960 hgt:152cm + +eyr:2026 pid:815848563 hgt:75in iyr:2019 ecl:gry byr:1947 +hcl:#cfa07d + +cid:181 iyr:2012 +eyr:2024 byr:1934 hcl:#c0946f +hgt:165cm ecl:oth pid:232944581 + +cid:135 iyr:2020 +byr:1971 hcl:#733820 pid:531877857 hgt:179cm eyr:2027 ecl:amb + +byr:1987 hcl:936807 eyr:2032 ecl:#4bec4a pid:605628619 cid:180 hgt:150in +iyr:2015 + +hcl:b62ef0 ecl:#092141 +pid:876635399 byr:1944 hgt:158cm iyr:2017 eyr:1924 + +iyr:2016 pid:7039815301 byr:2014 hgt:150 eyr:2032 ecl:blu hcl:z + +byr:1979 eyr:2030 iyr:1978 hgt:63 pid:1554613758 hcl:z ecl:amb + +hgt:70cm hcl:e45897 iyr:2020 eyr:1977 ecl:dne pid:2878189427 byr:1973 + +iyr:2003 +hcl:#cfa07d +pid:260517078 +byr:2030 hgt:175cm eyr:2020 +ecl:brn + +pid:460604681 eyr:2022 +cid:138 iyr:2016 hgt:163cm +byr:1922 +hcl:#ceb3a1 ecl:oth + +hgt:167cm byr:2009 eyr:1975 cid:295 pid:174cm iyr:2029 +hcl:z + +hgt:67in ecl:grn +eyr:2023 +cid:122 pid:281246917 byr:1990 iyr:2011 hcl:#866857 + +ecl:#ed7ddc byr:1922 cid:234 hcl:e61b1e iyr:1932 eyr:1996 pid:31344005 hgt:62cm + +byr:1949 +cid:275 iyr:2017 ecl:grn +hgt:164cm eyr:2027 hcl:#18171d +pid:751342937 + +ecl:blu hgt:162cm +pid:432600613 byr:1923 eyr:2029 iyr:2011 hcl:#623a2f cid:315 + +iyr:2020 +hcl:#b2bb11 pid:055891584 ecl:grn +hgt:67in +eyr:2029 byr:1937 + +iyr:2012 +hcl:#a97842 pid:325640714 ecl:blu hgt:185cm eyr:2024 byr:1971 + +hcl:#b6652a pid:485327267 +ecl:brn hgt:155cm eyr:2028 +iyr:2019 + +pid:902164867 hgt:77 cid:283 eyr:2027 +iyr:2020 ecl:hzl byr:1935 hcl:#efcc98 + +ecl:grn +hcl:#ceb3a1 byr:1977 hgt:165cm +pid:850700221 eyr:2030 +iyr:2012 + +byr:1989 ecl:brn eyr:2026 pid:919138357 iyr:2016 +hcl:#623a2f cid:319 hgt:161cm + +iyr:2017 +byr:1973 pid:293382118 hcl:#341e13 cid:143 ecl:hzl +hgt:166cm eyr:2022 + +pid:517102798 +hcl:f9d9dd +eyr:1933 iyr:2019 hgt:164cm +byr:2017 ecl:utc + +eyr:2023 pid:757868802 hcl:#18171d cid:244 +hgt:156cm +ecl:blu iyr:2015 byr:1926 + +eyr:2022 +iyr:2020 +hgt:158cm ecl:grn +byr:1988 +pid:979194751 hcl:#888785 + +eyr:2039 +pid:3867868142 byr:1936 ecl:dne iyr:2022 hcl:4b43b8 +hgt:115 cid:241 + +iyr:2015 eyr:2026 +hcl:#ceb3a1 pid:539099924 +cid:234 +ecl:brn +byr:1920 hgt:163cm + +cid:259 iyr:2020 +pid:949453818 eyr:2022 hgt:181cm +byr:1997 ecl:blu hcl:#18171d + +byr:2016 +iyr:2012 +ecl:utc +hgt:68in eyr:1993 +pid:1542134802 hcl:486699 +cid:239 + +iyr:2018 +hgt:154cm ecl:brn byr:1970 +eyr:2021 pid:581775861 hcl:#888785 + +iyr:2012 +eyr:2027 hgt:67cm hcl:#efcc98 ecl:zzz pid:312104916 byr:2020 + +hcl:#b6652a ecl:hzl eyr:2023 iyr:2012 pid:513268492 +hgt:159cm + +hgt:162in hcl:z +byr:2029 +eyr:2023 ecl:#e2e7ab iyr:2016 pid:65979982 + +cid:84 hgt:71in ecl:blu pid:982719716 +eyr:2020 iyr:2014 + +eyr:2028 hgt:181cm +ecl:hzl pid:255796693 hcl:#341e13 byr:1994 iyr:2011 cid:218 + +ecl:blu +byr:2029 iyr:2017 pid:468504566 eyr:2020 hcl:z hgt:163cm + +hgt:158cm +eyr:2025 ecl:hzl cid:295 pid:601339484 +hcl:#7d3b0c byr:1991 iyr:2013 + +eyr:2028 +iyr:2018 pid:2236240873 +hgt:172cm +ecl:#0e337e hcl:#b6652a cid:108 byr:1930 + +ecl:gry hcl:#888785 +eyr:2020 pid:442479017 iyr:2016 + +iyr:2014 ecl:grn +cid:313 eyr:2023 +hgt:183cm +byr:1976 +pid:499580308 hcl:#53efe6 + +eyr:2034 +cid:235 hcl:8f3cf5 +byr:2027 +hgt:161in pid:3259965094 ecl:xry iyr:2026 + +eyr:1978 byr:1925 iyr:2018 hgt:170cm ecl:#0c94e8 +pid:562699017 hcl:#816949 + +eyr:2023 hcl:#866857 hgt:179cm +pid:785862442 iyr:2014 cid:165 ecl:amb byr:1939 + +hgt:187cm +pid:64469711 ecl:gry eyr:2023 cid:225 hcl:#341e13 iyr:2011 byr:1958 + +hgt:162cm byr:2028 ecl:#37e345 +eyr:2037 hcl:19fb3d +iyr:2021 +pid:#87921a + +eyr:2027 hcl:#18171d +byr:2002 ecl:gry iyr:2014 +pid:561506850 hgt:177cm + +hgt:64cm pid:#a92686 +eyr:2029 cid:122 +byr:2026 +iyr:2017 hcl:z ecl:grn + +eyr:2028 byr:2007 hgt:155cm ecl:#86fa1b hcl:#733820 pid:562889497 +iyr:2019 + +pid:880698787 +byr:1992 +hcl:#7d3b0c hgt:163cm ecl:hzl +iyr:2011 eyr:2021 + +eyr:2020 byr:1994 iyr:2011 hgt:186cm pid:841855425 hcl:#cfa07d ecl:gry + +byr:1923 iyr:2015 ecl:amb pid:414655744 +hcl:#b6652a +hgt:159cm +eyr:2026 + +hgt:171cm ecl:amb pid:363065723 iyr:2020 +cid:66 hcl:#b6652a eyr:2021 +byr:1960 + +eyr:2002 +hcl:2627b2 ecl:#1bf21d pid:168cm byr:2024 iyr:2020 +hgt:186in + +iyr:2011 byr:1924 eyr:2024 +hcl:#b6652a ecl:brn +pid:794477411 hgt:162in + +hcl:z hgt:67cm +byr:2025 +pid:582569979 +iyr:2013 +ecl:oth eyr:2025 + +cid:50 hcl:931e2c +hgt:172in eyr:1994 iyr:2023 +ecl:#cd2204 +byr:2015 +pid:157cm + +hgt:173cm eyr:2028 +ecl:amb pid:569607283 +byr:1942 +iyr:2019 +cid:228 +hcl:#866857 + +cid:109 +ecl:oth eyr:1933 byr:1982 pid:173cm hcl:#b6652a hgt:174cm +iyr:2023 + +cid:69 hcl:#9ad05b pid:341135641 +byr:1968 ecl:brn +iyr:2012 hgt:156cm +eyr:2020 + +hgt:176cm +byr:1954 ecl:blu +eyr:2020 +pid:478462637 iyr:2019 +hcl:#888785 + +iyr:2026 hgt:193in +byr:2018 pid:162cm hcl:605e7f eyr:1948 ecl:utc + +byr:1962 +eyr:2022 pid:445346117 iyr:2019 hgt:158cm hcl:#623a2f ecl:hzl + +cid:278 hgt:187cm eyr:2024 iyr:2016 byr:1964 +ecl:grn pid:450739552 hcl:#733820 + +ecl:grn byr:2000 eyr:2023 +pid:344489911 hcl:#7d3b0c iyr:2011 hgt:177cm + +iyr:2015 hgt:180cm cid:190 hcl:#a97842 pid:359774842 eyr:2029 byr:2002 ecl:amb + +eyr:2027 iyr:2015 ecl:hzl +pid:082733109 +byr:1975 hgt:191cm cid:251 hcl:#888785 + +hcl:#c0946f iyr:2015 +hgt:167cm byr:1990 ecl:amb pid:168cm eyr:2023 + +ecl:gry eyr:2028 +byr:1934 iyr:2013 hcl:#6b5442 +pid:424412120 hgt:173cm + +pid:273352568 +eyr:2024 +iyr:2013 byr:1926 hcl:#602927 +ecl:brn hgt:180cm + +hcl:#7d3b0c hgt:70in ecl:amb iyr:2019 +byr:1937 +eyr:2030 pid:309011548 + +ecl:grn +hgt:64in pid:796889811 hcl:#18171d +byr:1929 eyr:2027 + +ecl:amb hcl:#888785 +pid:412449028 cid:316 byr:1982 +iyr:2019 eyr:2030 hgt:193cm + +eyr:1927 +hcl:z hgt:158cm byr:1930 +ecl:lzr iyr:2018 +cid:197 +pid:0906120002 + +ecl:grn byr:1970 hgt:181cm +pid:376212702 eyr:2030 iyr:2017 cid:266 hcl:#f8b0f5 + +iyr:2018 hgt:73in pid:652356158 hcl:#c0946f +ecl:grn byr:1973 + +cid:170 hcl:#b6652a byr:2011 +ecl:gry iyr:2025 pid:#b6e567 hgt:67cm eyr:2016 + +hgt:192cm ecl:amb eyr:2026 pid:201824712 hcl:#888785 byr:1966 iyr:2019 + +iyr:2013 byr:1995 eyr:2028 hcl:#b6652a ecl:brn cid:53 pid:705606447 hgt:176cm + +hcl:#341e13 byr:1951 +hgt:161cm pid:231973770 iyr:2015 ecl:hzl +eyr:2030 + +cid:210 ecl:brn iyr:2017 eyr:2030 +hgt:176cm hcl:#efcc98 +byr:1965 + +eyr:2020 hcl:#7d3b0c +pid:872088079 ecl:oth iyr:2017 byr:1920 +hgt:180cm + +hcl:#0b540c iyr:2019 +byr:1938 +hgt:153cm ecl:gry pid:236785988 +eyr:2020 + +eyr:2020 hgt:184cm iyr:2019 +pid:673186642 ecl:oth byr:1977 hcl:#866857 + +eyr:2025 +ecl:gry hcl:#341e13 byr:1970 iyr:2010 pid:972122542 hgt:184cm + +ecl:grn byr:1992 hgt:71in +iyr:2014 cid:254 hcl:#fffffd pid:749733013 +eyr:2026 + +cid:98 ecl:amb eyr:2022 +hgt:169cm pid:022677680 +byr:1937 iyr:2014 hcl:#e62c71 + +hgt:192cm +iyr:2015 +eyr:2028 ecl:oth pid:6000619833 hcl:#c0946f +byr:1930 + +byr:1938 hcl:#efcc98 hgt:178cm iyr:1953 eyr:2038 +ecl:brn pid:#cdc55a + +hgt:66in byr:1951 iyr:2016 hcl:#18171d +eyr:2027 +ecl:lzr pid:834188980 + +iyr:2012 eyr:2025 +hcl:#7d3b0c pid:330325803 cid:166 hgt:186cm byr:1938 +ecl:amb + +iyr:2015 hcl:#602927 cid:268 eyr:2021 +ecl:amb hgt:186cm pid:318676962 + +hcl:#3d6f3c iyr:2014 pid:665730784 cid:191 hgt:150cm byr:1981 ecl:oth eyr:2024 + +ecl:grn hcl:#733820 +eyr:2028 iyr:2010 +hgt:162cm byr:1944 pid:872962499 + +eyr:2028 byr:1974 +ecl:brn +iyr:2010 hcl:#18171d hgt:160cm + +hcl:#602927 +byr:1959 eyr:2027 iyr:2016 ecl:brn hgt:169cm pid:078503025 + +hcl:#623a2f pid:326300051 hgt:153cm +byr:1973 iyr:2012 +ecl:gry eyr:2026 + +hgt:151cm +byr:1966 eyr:2029 pid:026952622 hcl:#18171d ecl:gry iyr:2010 + +hcl:#7d3b0c byr:1974 pid:444713591 iyr:2017 eyr:2030 +hgt:165cm ecl:oth + +iyr:2026 pid:184cm +ecl:gmt hcl:z hgt:71cm +eyr:2029 + +cid:310 hcl:#fffffd byr:1998 +pid:450705840 iyr:2015 +ecl:grn eyr:2021 hgt:165cm + +byr:1939 hcl:#623a2f ecl:gry hgt:69in pid:539812641 eyr:2027 iyr:2013 + +pid:207645014 +iyr:2015 +cid:314 ecl:oth +byr:1942 +eyr:2027 hgt:186cm hcl:#fffffd + +ecl:#fb7e3d eyr:2031 iyr:1956 +hgt:188 pid:160cm hcl:z byr:2027 + +byr:1972 iyr:2020 eyr:2026 hcl:#b6652a pid:289088329 hgt:65in ecl:gry + +eyr:2027 +hgt:59cm +byr:2022 +pid:938063769 ecl:zzz iyr:2028 hcl:23c762 + +byr:2004 hgt:74 iyr:2017 +eyr:2040 ecl:blu pid:4611117799 cid:73 hcl:z + +ecl:brn byr:1962 cid:321 +iyr:2019 eyr:2026 +hgt:159cm +hcl:#667310 pid:439864945 + +iyr:2026 eyr:2039 pid:633263851 cid:321 ecl:lzr hgt:166cm +byr:2023 hcl:fc3c63 + +byr:1961 iyr:2010 ecl:blu +eyr:2023 pid:245858010 + +hgt:193cm pid:821303249 eyr:2020 hcl:#6b5442 cid:130 byr:1946 + +eyr:2026 ecl:brn +hcl:#733820 byr:1983 hgt:182cm pid:727380954 cid:188 iyr:2015 + +hgt:152cm cid:206 iyr:2012 byr:1947 hcl:#888785 ecl:gry +pid:720312394 eyr:2023 + +hgt:150cm ecl:gry pid:863712648 +iyr:2019 cid:349 byr:1976 hcl:#602927 eyr:2022 + +hgt:164in pid:953500867 +eyr:2021 +iyr:2014 +hcl:z cid:343 ecl:amb + +byr:1981 pid:529710230 iyr:2013 eyr:2023 +hcl:#c0946f ecl:amb +hgt:151cm + +pid:706204190 hgt:154cm cid:317 +hcl:#602927 byr:1949 ecl:blu iyr:2010 eyr:2028 + +iyr:2019 hcl:#0219e6 +pid:850093151 ecl:gry +eyr:2030 +byr:1938 hgt:177cm + +ecl:brn hcl:#efcc98 eyr:2029 byr:1963 +hgt:185cm pid:611279647 iyr:2011 + +ecl:blu eyr:2022 byr:1941 hgt:167cm +iyr:2012 hcl:#7d3b0c pid:415739564 +cid:193 + +eyr:2027 ecl:blu byr:1968 pid:479994566 +hcl:#733820 hgt:151cm +iyr:2011 + +pid:263729839 hgt:189cm eyr:2030 ecl:gry byr:2001 hcl:#602927 + +byr:1985 +ecl:amb pid:672663977 cid:139 +hgt:159cm hcl:#733820 iyr:2018 eyr:2020 + +byr:1998 +hcl:#cfa07d eyr:2023 pid:255046063 iyr:2011 ecl:blu hgt:177cm + +ecl:oth +byr:1980 pid:253747166 eyr:2029 +hcl:#6b5442 hgt:186cm + +eyr:2030 hcl:#866857 +hgt:165cm +ecl:amb +iyr:2017 pid:241240220 cid:164 byr:2001 + +byr:1994 hcl:#b6652a iyr:2015 +pid:753831241 +hgt:175cm +eyr:2027 ecl:blu + +hcl:#b6652a pid:471594512 +byr:1961 ecl:hzl hgt:175cm +iyr:2020 eyr:2025 + +byr:1987 pid:112366159 +eyr:2028 hcl:22b2d7 +hgt:64in cid:222 +ecl:#b40dca iyr:2019 + +iyr:2015 hcl:e1ed55 hgt:160in ecl:utc byr:2015 eyr:2036 + +byr:1935 +hcl:#7d3b0c hgt:152cm ecl:gry +pid:160090332 iyr:2020 eyr:2020 + +pid:552779024 byr:1998 hgt:185cm ecl:gry eyr:2026 iyr:2013 hcl:#d46cd6 + +ecl:oth pid:311860969 +cid:57 +hgt:60in +eyr:2026 +hcl:#ceb3a1 +byr:1961 iyr:2011 + +eyr:2021 hgt:162cm cid:240 +pid:259997995 +hcl:#efcc98 +ecl:gry byr:1962 iyr:2017 + +hcl:#866857 +iyr:2016 +eyr:2029 +ecl:blu byr:1927 cid:249 pid:665324615 hgt:65in + +byr:1931 +cid:331 +hgt:66in +ecl:grn iyr:2020 hcl:#efcc98 eyr:2025 pid:175780921 + +hgt:98 +eyr:2040 ecl:blu byr:2029 +iyr:1967 hcl:0d76e9 +pid:#c9053a cid:296 + +pid:370918950 +hcl:#602927 +byr:1938 +hgt:178cm iyr:2018 eyr:2030 +ecl:oth + +hgt:185cm +eyr:1984 ecl:oth pid:851080398 +hcl:z byr:2027 iyr:2017 + +pid:095078224 byr:1957 hcl:#45bcf4 ecl:#f643f9 hgt:63cm eyr:2036 iyr:1978 + +hcl:z +eyr:2023 ecl:oth hgt:162cm +iyr:2016 byr:1938 pid:#fdcddf + +hcl:#341e13 iyr:2013 hgt:189cm +pid:982271041 ecl:brn +byr:1930 eyr:2030 + +eyr:2026 +iyr:2012 hcl:#cfa07d cid:59 pid:105862717 ecl:blu +hgt:159cm byr:1943 + +ecl:hzl +pid:604172804 iyr:2016 hgt:174cm cid:79 eyr:2025 +hcl:#733820 byr:1994 + +iyr:2011 pid:452628771 ecl:gry hgt:182cm hcl:#623a2f +eyr:2023 +byr:1986 + +hcl:#341e13 iyr:2010 byr:1946 eyr:2021 +cid:350 pid:049684494 hgt:180cm +ecl:grn + +iyr:2020 +hgt:173cm pid:384503937 +byr:1986 +hcl:#341e13 +cid:113 +eyr:2025 ecl:amb + +hgt:180cm byr:1949 +hcl:#733820 iyr:2010 eyr:2030 +cid:123 pid:065609606 ecl:oth + +iyr:2010 eyr:2028 +pid:231750173 +hgt:63in ecl:brn +byr:1948 hcl:#18171d + +iyr:2020 hcl:#623a2f +ecl:gry +byr:1922 pid:961213634 eyr:2022 hgt:177cm + +hcl:#18171d eyr:2020 iyr:2014 byr:1983 +pid:183568344 hgt:72in +ecl:gry + +eyr:2023 pid:102781246 ecl:brn +hcl:#888785 byr:1929 hgt:167cm iyr:2010 + +pid:362873066 byr:1994 hcl:#de545f iyr:2018 hgt:177cm ecl:blu cid:86 +eyr:2024 + +hcl:842f2d iyr:1983 +byr:1954 eyr:2037 +ecl:lzr pid:3915492573 hgt:166cm + +ecl:grn +hcl:#fffffd iyr:2014 +hgt:173cm +byr:1939 +pid:930650489 +eyr:2025 + +eyr:2028 ecl:brn hcl:#7d3b0c hgt:166cm byr:1938 pid:992958531 iyr:2011 + +pid:101149939 eyr:2024 iyr:2018 hgt:165cm +ecl:hzl +hcl:#ceb3a1 cid:176 + +cid:62 +pid:651390352 hcl:#efcc98 +iyr:2018 +eyr:2027 +ecl:brn +hgt:66in byr:1953 + +hcl:#623a2f byr:1978 +iyr:2013 +hgt:180cm eyr:2027 ecl:amb pid:836425641 + +pid:557464096 hgt:155cm ecl:blu cid:142 byr:1936 iyr:2010 +hcl:#cfa07d eyr:2027 + +ecl:gry iyr:2024 hcl:#341e13 pid:442593279 cid:314 hgt:186cm byr:1960 +eyr:2022 + +cid:123 iyr:2014 +byr:2000 +pid:878733390 eyr:2021 ecl:hzl hgt:162cm + +byr:1959 cid:259 +pid:722895016 +ecl:brn iyr:2018 eyr:2027 hgt:185cm + +pid:163697814 ecl:hzl +iyr:2013 byr:1932 +hgt:68in cid:286 eyr:2025 hcl:#efcc98 + +byr:1927 +hgt:72cm ecl:oth +eyr:2021 hcl:#99e959 +pid:669724466 iyr:2010 + +byr:1943 iyr:2011 eyr:2024 pid:384419879 ecl:hzl hcl:#7d3b0c hgt:170cm + +pid:137944386 ecl:gry +byr:1953 hcl:#733820 iyr:2013 eyr:2025 hgt:184cm + +iyr:2017 eyr:2023 pid:288078785 +hgt:179cm +byr:1993 hcl:#602927 ecl:hzl + +ecl:brn +hgt:187cm eyr:2024 byr:1971 iyr:2020 hcl:#b6652a pid:622975646 +cid:290 + +pid:371817422 ecl:blu byr:1964 +iyr:2018 +eyr:2021 cid:176 +hgt:153cm hcl:#888785 + +byr:2002 +cid:256 iyr:2014 eyr:2024 ecl:blu hcl:#18171d hgt:187cm +pid:050022911 + +hgt:178cm pid:211144001 eyr:2027 iyr:2013 +byr:1947 +hcl:#7d3b0c ecl:grn + +eyr:2025 ecl:blu pid:046417901 byr:1950 +iyr:2015 hgt:165cm +hcl:#7d3b0c cid:128 + +ecl:hzl eyr:2029 +iyr:2015 +hgt:171cm hcl:#341e13 +pid:561680375 byr:1997 + +byr:1948 iyr:2023 pid:17288381 hcl:6a34a3 ecl:#671ece eyr:2001 +cid:152 + +eyr:2036 hgt:141 iyr:1957 byr:1987 hcl:z +pid:86986187 ecl:utc + +eyr:2024 hcl:#b6652a iyr:2017 ecl:blu byr:1988 cid:348 hgt:152cm pid:068684272 + +iyr:2011 pid:989825275 +cid:78 hcl:#341e13 byr:1983 ecl:blu hgt:158cm eyr:2020 + +ecl:grn hgt:187cm eyr:2027 iyr:2015 +hcl:#866857 pid:240650427 +byr:1940 +cid:91 + +hcl:#888785 cid:185 byr:1925 +hgt:155cm iyr:2015 ecl:blu eyr:2027 pid:851697441 + +iyr:2016 ecl:oth pid:056439470 byr:1985 eyr:2026 +hgt:154cm hcl:#282539 + +ecl:hzl hcl:#a97842 +iyr:1944 +pid:118846711 eyr:2026 byr:1922 hgt:185cm + +iyr:2020 hcl:#733820 +pid:854531642 hgt:165cm +ecl:hzl eyr:2022 + +iyr:2014 +byr:1957 hcl:#7fa674 hgt:189cm +eyr:2023 pid:740871941 ecl:brn + +ecl:amb cid:349 hgt:170cm +byr:1952 hcl:#ceb3a1 iyr:2020 +eyr:2026 +pid:730499325 + +eyr:2027 ecl:amb +byr:1975 pid:985687961 +hcl:z hgt:157cm +iyr:2013 +cid:133 + +ecl:blu +hgt:193cm iyr:2015 hcl:#10f2ba byr:1989 pid:939704495 eyr:2021 + +ecl:oth eyr:2025 hgt:69in iyr:2014 cid:258 pid:477970733 byr:1984 hcl:#b6652a + +hcl:z byr:2013 +ecl:zzz +pid:1904741884 hgt:180 cid:138 eyr:1985 iyr:1935 + +eyr:2025 +iyr:2026 hgt:190in pid:#43ca33 +ecl:#3e1ef1 hcl:#7d3b0c byr:2030 + +eyr:2029 hgt:191cm +byr:1986 hcl:#ceb3a1 cid:327 pid:795060714 iyr:2012 ecl:hzl + +eyr:2025 iyr:2017 ecl:grn +hcl:z +pid:8886398 hgt:174cm byr:2016 + +hcl:#a97842 +eyr:2021 ecl:grn iyr:2013 pid:565234133 byr:1998 +hgt:161cm + +eyr:2029 hgt:163cm byr:1933 cid:86 iyr:2011 +ecl:grn +hcl:#fffffd +pid:818769307 + +hgt:190cm eyr:2030 hcl:#af5b5d iyr:2011 ecl:brn pid:359524299 byr:1969 + +ecl:amb iyr:2011 eyr:2022 +cid:141 +byr:1978 hgt:69in hcl:#fffffd pid:013006109 + +ecl:blu hgt:164cm iyr:2019 eyr:2027 pid:899103430 hcl:#cfa07d +byr:1976 + +eyr:1938 +ecl:#a03c41 pid:708735698 +iyr:2030 +hgt:184cm hcl:#b6652a byr:2013 + +ecl:hzl byr:1997 hcl:#a97842 cid:60 pid:172cm +eyr:2023 hgt:161in iyr:1936 + +ecl:hzl +byr:1938 pid:094889181 +hgt:162cm iyr:2020 +eyr:2028 +hcl:#623a2f + +hgt:162cm cid:86 +hcl:#623a2f pid:738174580 ecl:brn byr:1980 eyr:2028 iyr:2014 + +byr:2007 hgt:150in hcl:z +eyr:2032 +ecl:#114f3b +iyr:2030 pid:5129772 + +ecl:hzl iyr:2017 +hcl:#18171d +pid:696283412 byr:1976 hgt:168cm +eyr:2028 + +eyr:1922 ecl:#84b0d4 byr:2013 hcl:#ceb3a1 pid:150cm iyr:2030 +hgt:71cm + +hgt:164cm byr:1949 ecl:gry eyr:2026 +hcl:#623a2f + +ecl:oth +iyr:2013 hgt:166cm hcl:#50e385 +pid:478852286 +eyr:2030 byr:1930 + +cid:129 +iyr:2020 byr:1978 pid:907580992 eyr:1955 +hcl:#602927 +ecl:grn hgt:165cm + +ecl:blu iyr:2018 byr:1953 +hgt:177cm pid:126681706 eyr:2025 hcl:#c0946f + +byr:1984 pid:275799917 +ecl:oth hcl:#623a2f cid:348 iyr:2020 +hgt:189cm eyr:2024 + +iyr:2016 +ecl:hzl byr:1954 +hcl:#623a2f pid:810508839 eyr:2026 +hgt:185cm + +byr:1967 +eyr:2021 hcl:#ceb3a1 +pid:406634908 hgt:158cm iyr:2018 ecl:hzl + +iyr:2019 eyr:2030 pid:995681076 hcl:#341e13 +cid:101 hgt:162cm ecl:blu byr:1925 + +eyr:2026 pid:272513479 hcl:#b6652a byr:1973 iyr:2016 ecl:amb hgt:182cm + +pid:298704871 eyr:2024 hcl:#efcc98 byr:1959 +iyr:2014 hgt:191cm ecl:grn + +hgt:193cm pid:750729809 ecl:oth +cid:324 +iyr:2011 hcl:#efcc98 byr:1954 eyr:2020 + +byr:1966 iyr:2019 eyr:2025 ecl:#2df4b6 +hgt:184cm pid:#fc17f4 cid:161 hcl:#602927 + +byr:1955 hcl:299464 ecl:amb +hgt:157cm iyr:2017 eyr:2021 +pid:239450987 + +hgt:172cm +ecl:hzl +pid:839804598 +hcl:#341e13 eyr:2030 byr:1964 iyr:2013 + +iyr:2018 hgt:152cm byr:1948 hcl:#623a2f pid:400121515 +ecl:blu +eyr:2020 + +cid:296 +ecl:grn +byr:1960 iyr:2028 pid:#1f4b95 eyr:2033 hcl:#602927 +hgt:66cm + +iyr:1933 ecl:#232e20 pid:#d03ca7 +eyr:2030 hcl:598ed6 hgt:154in byr:2011 + +cid:247 ecl:grn iyr:2014 +hgt:178cm +byr:1992 hcl:#602927 eyr:2021 +pid:678964478 + +iyr:2010 pid:623705680 +ecl:hzl hgt:181cm byr:1980 hcl:#341e13 eyr:2028 diff --git a/2020/04/sol1.pl b/2020/04/sol1.pl @@ -0,0 +1,26 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +open(my $fh, '<', 'input') or die "$!"; +# slurp +my $content; +{ + local $/; + $content = <$fh>; +} + +my @recs = split("\n\n", $content); +my $n; +my @required = qw(byr iyr eyr hgt hcl ecl pid); +REC: +for my $r (@recs) { + + my @fields = split(/\s+/, $r); + my %has = map { $_ => 1 } map { $_ =~ s/:.*//r } @fields; + for my $req (@required) { + next REC if !exists $has{$req}; + } + $n++; +} +print "$n\n"; diff --git a/2020/04/sol2.pl b/2020/04/sol2.pl @@ -0,0 +1,62 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +open(my $fh, '<', 'input') or die "$!"; +# slurp +my $content; +{ + local $/; + $content = <$fh>; +} + +my @recs = split("\n\n", $content); +my $n = 0; +my %required = ( + byr => sub { $_[0] =~ /^\d\d\d\d$/ && $_[0] >= 1920 && $_[0] <= 2002 }, + iyr => sub { $_[0] =~ /^\d\d\d\d$/ && $_[0] >= 2010 && $_[0] <= 2020 }, + eyr => sub { $_[0] =~ /^\d\d\d\d$/ && $_[0] >= 2020 && $_[0] <= 2030 }, + hgt => sub { + my $v = $_[0]; + if ($v =~ /^(\d\d+)(cm|in)$/) { + if ($2 eq 'cm') { + return ($1 >= 150 && $1 <= 193); + } else { + return ($1 >= 59 && $1 <= 76); + } + } else { + return 0; + } + }, + hcl => sub { $_[0] =~ /^#[0-9a-f]{6}$/ }, + ecl => sub { $_[0] =~ /^(amb|blu|brn|gry|grn|hzl|oth)$/ }, + pid => sub { $_[0] =~ /^\d{9}$/ }, +); +REC: +for my $r (@recs) { + my @fields = split(/\s+/, $r); + + # parse the fields, validate as you go + my %has; + for my $f (@fields) { + my ($k, $v) = split(':', $f); + $has{$k} = $v; + if (!exists $required{$k}) { + next if $k eq 'cid'; #ok + + print "unknown key: $k\n"; + next REC; + } + if (!$required{$k}->($v)) { + # print "bad key/val: $k:$v\n"; + next REC; + } + } + + # check they all exist + for my $req (keys %required) { + next REC if !exists $has{$req}; + } + $n++; +} +print "$n\n"; diff --git a/2020/05/input b/2020/05/input @@ -0,0 +1,965 @@ +FBFBBBFRLR +FBBFBBBLLR +FFFFFBBRRL +BBBFFFBRRL +BFFBFBFLRL +FBFFBFFLLR +FBFBBBBRLR +FBFBFBFRLL +BFFBFFBRLR +FBBFFFBLRR +FBFBBBFRRR +BFFBBFBRLR +BFFBFBFRRL +FFFFBBBLRL +FBBFBFFRLL +BBFBBFBRLR +BFFFFBBLLR +FBFFFFFRRR +BFBFFBFLRR +BBFBFFBLLL +BFBFFFFLLR +FBBFBBBRLL +BBBBFFFRRL +FFBBBFFRLR +FFFBFFFRRL +FFFBBBBLRL +BFBBFBFRRL +BFFBBFBLLL +FBFBBFFLRL +BFFBBBBLRL +FFBBBFFLRL +F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BFBBBBFLLL +FFBBFFFRLR +FFBFBFFLRL diff --git a/2020/05/sol1.pl b/2020/05/sol1.pl @@ -0,0 +1,42 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +open (my $fh, '<', 'input') or die "$!"; + +my @items; +{ + local $/; + my $content = <$fh>; + @items = split("\n", $content); +} + +# HACK: don't have to compute ID for all of them--sort then compute ID +# +# BUT: we'll brute force it... +my @ids = map { id($_) } @items; +@ids = sort { $b <=> $a } @ids; +print $ids[0] . "\n"; + + +sub id { + my ($v) = @_; + my $id; + # row + for (my $i = 0; $i < 7; $i++) { + if (substr($v, $i, 1) eq 'B') { + $id += (2 ** (6 - $i)) * 8; + } else { + # F -- lower bound stays same, no addition + } + } + # col + for (my $i = 7; $i < 10; $i++) { + if (substr($v, $i, 1) eq 'R') { + $id += 2 ** (9 - $i); + } else { + # R + } + } + return $id; +} diff --git a/2020/05/sol2.pl b/2020/05/sol2.pl @@ -0,0 +1,50 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +open (my $fh, '<', 'input') or die "$!"; + +my @items; +{ + local $/; + my $content = <$fh>; + @items = split("\n", $content); +} + +# HACK: don't have to compute ID for all of them--sort then compute ID +# +# BUT: we'll brute force it... +my @ids = map { id($_) } @items; +@ids = sort { $b <=> $a } @ids; + +# NOTE: not first or last +for (my $i = 1; $i < $#ids; $i++ ) { + if ($ids[$i-1] - $ids[$i] > 1) { + print $ids[$i] + 1 . "\n"; # 2 seat gap, print middle + exit(0); + } +} +exit(1); + + +sub id { + my ($v) = @_; + my $id; + # row + for (my $i = 0; $i < 7; $i++) { + if (substr($v, $i, 1) eq 'B') { + $id += (2 ** (6 - $i)) * 8; + } else { + # F -- lower bound stays same, no addition + } + } + # col + for (my $i = 7; $i < 10; $i++) { + if (substr($v, $i, 1) eq 'R') { + $id += 2 ** (9 - $i); + } else { + # R + } + } + return $id; +} diff --git a/2020/06/input b/2020/06/input @@ -0,0 +1,2232 @@ +bahmtpujokxdqlyi +efqksvrctzhmngw + +zfyhxoeuljmp +wrpjeymoxhfzul +ouxmhyjzpfle +zfouaelhxmynvptj +zlfojexmyhup + +wgfjlotnrx +xntjogrwfl +wrxgotnjfla + +qjtgski +bfysrculx +vwzdtpsq + +ahsp +saph +pihazus +hzptgacs +dpahksq + +ksvhn +kns + +urswemgxfn +uvgbwjli +yuczthgwp +kbuowg + +egnsbduqwtjpivxoyc +ugiwvsnjobyeqdtcxp +wqtvxseibgjupdcnoy +gecyvoniudwtbjpqsx + +jvtzcy +tzyecu +zvtmyc +ycktzm + +fvlrjwdnyq +nyfvwdjql +dqlyvfwjn +dlfyvxjwnq + +nmvjcdaywoxpbliqteskgr +wjgqutiepyaslbdomxkrvn + +ozv +qsukd + +wnizjvlrxhfpcysgae +bczhtmauekyisoxqv + +ylutpecbv +uylvptbec +ctbveuypl + +cbfwjalevion +nbojqefwcvaigu +nvebcfijoaw +ocjvnfiebaw + +hvpticezgxynwdubsjfmqkr +hwplmrgdvzueatsqnojk + +pe +kpes + +a +a +a +tv + +xudq +dq +qdw +wqvd + +kxuvbd +fiv +kv + +s +b +tif + +qljrage +aqel +qlea +aqelw +elqa + +qjgsamukhebcfo +bmlga +bmag +aivmnbg +mbngai + +kqeifuvcshrplzmj +epfykhvuzqirclms +msvekqzlfchriup +qlpzrfmbivkushcde +zvcqmeiulkhfpsr + +zrgmwqofx +vyltnpxdb + +pvgbidjysfco +jvzdgfpwscbio + +jgratmhklvoxspcef +thoampsijefvkglxc +nslqtmhyejacvkpfxgwo +dlmvpjihfoxgtascke + +wijpaqlbemut +aikhlupztgqbfcmvx +twbieparqnudml + +agn +ansp + +qdgh +oiyuqw + +fgwluhptemdynoivqjx +fgdyphuevzltmjxnoiqw +gwxftqnijohpymlubvedr +xvdeptiqoylfmwgnjuh +wnplvxyufosdijhqmteg + +teocudvi +dzuecotv +ouvectdz +ejdkutvco + +cqzr +sd + +cjrdeiw +q + +rhd +dr +dr + +xtforqiwydpl +ywitfxgopqzd +yioqtxwdgpf + +mej +bmj + +ugkbe +xqa + +imodpvys + +wj +d +y + +szojy +zylgerocjuf +ojytknzh +zqfrojsbey + +axl +dmvbhct + +xnjzefc +juwbz +vjgsoahp + +c +c +xc +khfnc +txc + +nefwt +fcunew +hefcwub +lqpdmxef + +ngbl +gnkl +lamwognj + +hyjlwuvdqfrntko +fjdhlkpcrytvmoqwnxi +jltrhbognsfykawv +rzkwflxnhyojvt + +rdbtkpxaz +yeojqhcm +xtgusirv + +r +r +r +r + +onauykid +ukoaydrnmi +daykuoin +taudikyonj +uidhoynkal + +ieoykzm +gjqxoewibktamr + +p +p + +l +l +l +kpl +l + +xhwdvceitfapro +rhafiptxvwdec +idcftqarphwvemx + +olmj +lmj +lmj +lmj +htmjlc + +zawfukbgp +kygvprw +wgkyt +hcwnokslqxdgie + +dqwpjonvuiembxayc +lfxwyoajbvdumcqpnie +jvwiymopnaucxqbed +duejmownrqabvpicxy +pwcyamvxdosqeujbiln + +kqshcv +uzdt +d + +qdvjtnekczia +jzkfhqeicatxvd +ticadkevjzq +takcjzevdpiq +tlejimqadzvkcu + +glmjdnetfhuy +lumtifngdyjqh +cfsungdmytwplkbhxj +vnltgmodyfhjzu +jfngltyudmh + +ne +xt +n + +qzhcyaflojvukmbsep +aqyvhcklpfjzusbome +lucqpoyhfazmsbkejv +euofsjzympbvklahcq + +ignmejhydvoaxrfcp +goiyvhrqmpnxcejd + +jop +jp +pja +jpo +nbphrji + +cmohreztnbjk +nrchxbeqywdsziua +zbrtnmehc + +eounjkdmztslpfivwxbqgahrcy +nxelikbqufchgwvyosjdatmpzr +yxkjgmepirtqunwsbhdfovcazl + +grjol +cwvaol +xbfpzye +jnt + +sxnrhqubzfdwlmpgy +yqlumgnxwhf +mlufqenxgywh +nfyxqughwvmlc +yquhxngmfwl + +mahnygokcfqisduxtz +ditfxqgaumosyzhkc + +wmuy +ymuw +wumy +uwmy + +my +myhc + +nq +bq +uq + +tehdqinmcv +vimcntehd +ntgvedicmh + +aghtbjvwuf +fhclwutjmgv +ruvfwjhdgi + +jvsmqfbpzndaiwc +zbdamvfcjqstniw +dnimsczgaqfvjbw + +rmd +e +e +y +e + +jgrcvikbaqhx +pfzrkouvldmqstewj + +fiaojcthgskyvurqeb +ediuswoavpjmgqbhy +iuyahnlsgzobveqxj + +sxlznjrvwcoidkp +scudozljrmnqwke + +nzqfsxcd +cqxsdfzn +nqzdfscx +scxnfdqz + +gdeaxvlqtnfb +eqdblnfvtg +dlqvetjbgnf +dtqbngvlef + +btiwohrj +biptgswnhrdj +whjfikbmtlvar + +bnfxzoclm +mzbfnoxlc +omcznvlxfb + +gnbwuvjmthyzr +nhmzubwjryvg +rbwunzmjgyhtv +lrdjvznbygucmhw +nzbwgjvryuhm + +nsq +qns +nqs + +epbdtgmnqrzacs +nazcgserqtpbd +rgteczqnbdaps +nepzbrstdqgca +pzcsudtqbnareg + +zudvpcsjgt +ayljdo + +lhqbfsa +hftvalwdcoq +xphqfal +hpbalqf +lqfpxha + +hplexwybavfud +icmlqntykgsze + +bodngmuwazsr +zwdunxmaorybgs +uszknodwrgmab +dubzawomsrng +zangrkudmbwso + +spvbq +bsvqp +vsqotbm +bveqcs + +meaglyscxhnkvi +ameksynzdjbivtcrhglx +hcnvilsyxmkugae +phioxaelgyvqcnwsmkfu + +hmwiteugrqyovxlzbjp +vcahlzmkurjeidygtwobxpq +tmxewhlypugrzqiosjbv + +maekrxispbwz +wmkdqlgaouzvjh + +xugcy +xygu +xygu + +wzixrtju +jiuwpzx +iguxjczqsw +jiuzwx + +zvbrmfane +srlygevf +refv + +r +zh +x +xk +idmvfnagw + +axcup +xapc + +pymjnecwasfvtgr +gfpqtxcemjrkyn +iegocpdzytm + +pcd +pcd +pcd +pdc +dpc + +mhbaptxcgveqysonukdlfrwi +qyodfrkumpxcslhgteibavwn +lyuigxbpdkhtemnafrvswcoq +nusbavlrchxopediqgwtmyfk + +cdk +r + +j +sj +j +s +n + +xhbmcz +cxb +cxb +bxcy +cbx + +fo +fo +of + +ewcukjogfmvqrxpbthladz +pixhfevqjkawtonrulzbmcgd +vcwdlxujpzfokhbrategmq +whfdrzoaklcgtbjxqumpve + +flkpmgq +gpqtkml + +mprkgn +npkrtmzu +gmkqzrp +adwoclpkjexfrm + +ke +e +e + +of +j +iaj +bhv + +eoxpcijm +pxjmecoa +cmopxije +jmxocpe + +bfrotcepu +ftenzuorcb +foeyucrbtm + +xlho +loh +olh +olh + +omdqx +heuyiont + +qazhxefcgtlnryudomws +tqldxuycfahmonreswzg +dbqrsguozljxmanchywfet +mnsfzuloavqekhygxtcrdw + +x +x +x +epsx + +o +o +o + +wfqogyvcslbhm +vgfhslmwcyobtq +hwbylocgmsfqv + +xzrilvynesmfu +mzeyvifslr +isrxbmvlzqfpey +ivkeyjlfamgczhort +mevziyrfl + +dhamcztn +xyduszkht +mhtdz + +vw +tvwx +wva +vbfw +vxw + +xs +bnvfakpm +o +c + +ebtou +heoutb +eutbo + +dqitrge +derqigc +ykapohqrdlesmwub +ejvrzqdg + +moafibndpvkexrlj +elikpxrnjmbfvdoa +fxbliknpdvjmorea + +jvufzme +udemvfj +umjedfvy +mujverf + +zi +zmia +iz +ziq + +rxeowpctzid +rwifctpoxdez +cdeotwripxz +cedxopwirtmz + +racvsinpgytx +slaetpxcdgry +ntsacpxyrgo +awgzxrpscnty +tyoxvgpiracs + +hbc +hcbn +cbl + +ypicgfklovnxwhj +hojykxcmfpdgbeq +uohwgkftvjzcpyrx + +odmzsbrlhfe +rmzhdolsf + +gqczivybjr +bwoivqz +bsqnlmvhaxd +tuzcqvb + +rekdt +sgw + +kalcwdinzuvjbyotf +bvwactldonzuify +lpbactswdfiovryzxn + +jkelaizpyovqmtwf +zfowivedmajqlk +evfamzwjobliur +fzolxmsinecawvj +gfqmaeyvlbhzjkwoi + +xcqbfopseavihdj +ievfbcoxdpqs + +gwpjtlvixqhr +qupwstlxv +qpvlwxt +unpqlwtxv + +bwreknof +ksdplqhmu + +kq +kq +qk +kq +qk + +hknqf +hqxymkrnpeu +khntvsibq + +ujklgexntmqzoyba +ngamlfbtojkueiyz +etymalonkszgujb +lzkabtgnyuomej + +sbizytmnqdog +wdatnumoxiyqfb + +edtakblzrihnupsv +rlstkdfubinaz +urjatmbkzidnlf +kzatilrdubn +ybdwcolguxktziqrna + +vcmzgolp +vzpcolm +plmvuqocz +pvmzloc + +wljih +kinwlho +wlih + +mpbrlizqgy +nzgtbpiaycvr +lzhbrdigyp + +vocauldtbgmnhqesjyxr +gsmoydtzcjenuhprxlqvab +xcmshnuqavgbjoertlyd + +fienpjg +pgjfnei + +yjr +rywj + +s +q +s +a +n + +ztmgncjxiwedfb +fcwbznixjgdoetm +ngbzocitewxdmfj +ciqwhjegnszfbxrtvdm + +zkqph +qphkz +pkhqz +qpkrizah +phzqk + +pjftsvdlxkcguroh +onrdpctlkujsfehz + +tghbqkwlyozmfisderv +qkfwbidlotevpg +vofjilpxgkbeatdqwc + +sopazrdufgi +lakdcroe +rdoa +jdonhrat +rmdeonax + +dvp +vdp +dvp +pdv + +jhtsp +tshjp +hstijp +hjtps + +r +rd +ls + +erjq +qejr + +oheparulijf +sjfilgrhobqecu +irowuepdvjflhn +reijlfohnu +yirflnjuheo + +fiwbgcqu +wuebcifg +wziugbcarf + +bxnaz +bkxvcnw +sdjwn +xwyavn +fniolegp + +yvpgqde +odzpymgveq +aegvdpyq + +hybklv +lkvgb +dkczvlb +kblv +blvhk + +oeabws +aslm +majpshn +eguaosxwy +tscvikfdrzqa + +ijops +osdjp +hsoupnj +fjsopd +jopsf + +qphlrmao +pcmo +qihopucm +onsptgfdym + +dlcfhoivwm +otmlxkscwihfjdb +whmcfloid +lifamocphwd + +kuy +ky +ky + +ftpwvkgjlxcbienodu +mqicztsohjvbfaryl + +i +i +i + +mbyoshxedcaw +gimxpetyswdbcah +wdqemxachoybs + +t +y +m +y + +intmofjra +rfmjta +afrjmt +amrjtf +jfrmta + +mogkvynhd +nkyodvmgh +khdmnoyvg +gnkhrmovyd +dnmohyvgk + +rdickjlmqpshz +hmdriqskjblp +igvqawdkhrlysjpm +slkjphmzfidqr + +de +ed +ed + +rfz +lrazjwbtud +kfzr + +pdr +galxof + +edsfzramctunoib +rtnxamszcuei +aunzescmriqtl + +i +alycbr + +t +t +t + +xcrtsdylbnikahpfm +zsiwocetrlbd +ldribcsgt + +rhvdngyojzmi +yidrovnj +dnyjxezvromi +vtokidybjpqcnfr +nyjdovari + +fpuvwyen +fewpnvy + +hdnybwlmsvorecpxigzk +qmdeoihrnxkybltjgwasuzv + +zjphxiyvguteqfasbmcowrl +hycqrafsmvgpjbzoxiuwte +pcryiuhzqogmwxafebtjsv +ixveptmrqbcugsjwayhzof +soxbahtfipezqucgmrvwjy + +kbptzgruasony +gbndzuprtwakyocs +aybtlzskjounpger +mrovnzsatqpkugbyifhx +tpbuonrgskyaz + +spknwfajybmlgucov +gmrynoqtpfwbuasvjzclk +lapnjhvoscwfemyguk + +dcynsw +cywnso +cysnw +yqnscw + +yavbzrfmtshuljxdpiqwg +wjzbrnivapfuqymtgsldhx +vaqdtzxjrmyhgeuplwsfbi +mqtpxygsulfahbvjzirwd +paqjxibrtwsfgdlmvhzyu + +t +t +t +t + +etzw +wdjzpvto +zwt +ztw + +egvbrzscuthifdylpmw +drwcmgvtzslhufibype +mtegulvrcdhiyzfbswp + +uenwf +enuwf +wenudyf +fnewguz + +kxgqyf +bkniwax +fbek +cogk +lrsk + +kyioclr +kcyzlmori +kymocjrli +flborikucy + +yfpuwbgmndtrivsh +bztmnpifhwlrjyue +utrmopnijbyhwf +wpfbmnulhryit + +dmit +ik + +fsmdoaw +aos +jsreuzbga +aksfoy +tsayl + +pjawkeqd +kwlqepadjv +qjkpweda +wadkjepq + +bjctaip +oyuiapstgdcj +tbaphixcj +itjcpa + +hp +hbus +bkh +jbhg +had + +qkegijrmhzfbdpsoux +oubjdehpqxmkrifz +phozmqkdiyfxaurjbe +unfehmidzroxqbjpk + +fyrbg +mtqybsvwazju + +hd +rlyh +xdh +hwx + +w +zw +e + +jqgtzikvwslxan +enasqwmbdrfxot + +pnuyvwst +pwnyvsut +bsuvtypwjan + +tabfmouhcpgre +atjrfkmcgqpuob + +vdim +iv +iv +iv +ivh + +ulqhxetamivfyr +tleqvhiarfxyu +fbvltcayeriqgxhj + +minth +iuknmvp +min + +zjfpwytesq +jvtfszqe +zqoemfij +sjzquedf + +xszhfdeuomynvbqwjiprltg +hsytwjnrdlfuqbiopzxvmeg +mgtepujxwyqbvdhiznrlfso +xonlavjhwiyftduezqgbpsrm +pswglfmznodityuqjbxverh + +sjp +jsy +jys +mzcefastxulqjn + +qaocszriptkxygmnefwlvuhb +awgtosevhufknrplbzqmyix +genislqhmubovrwptxzyafk + +xweoluafi +usfxabhwl + +zwqxpnjbhlc +zthplcwnxbd +phxolncbauzw +hpmzxwlbcekn +zcnlhpdxbw + +pxfwbregdscmi +xgdsbwmfriep +sxeprbmgdfiw +egbsripdmwxf +vswemdbgrfxpi + +lac +pla +cla +al +al + +a +i + +vag +grvoa +avg + +oldcjagpxrimusnf +nojxsfpludvmahcg + +mkxpzdhfy +gdkfahvyczsoxm +bdfzyxhkml +mkdfpxzyh +nhfzmdxkiy + +orfsmhebui +bfamvrteisz +ygirsmebofu + +hb +hskb +hfb +bh +bh + +xlzcpwmhrteusnbq +zmluehrcqpsbnvwtx + +fbrjycd +crybdj +bcjfryd +ycrdjb +cbdgtyrj + +fseljtvbymrwgphaxzkoun +vhlwsedcafpbxqjt + +jbflsxaq +ltrbnki +ehzpcduoygwvm + +aymbucz +czvua +ozcqfktgeshn + +ocljnmwkxybhuq +culwxoqhkjnmyb +ncbqwylmkxjuho +wlqyxcjhoubmnk +ojhxwcmukblnqy + +cwbfihts +fqtwibshc +wischtfb + +hdqybfu +dvcaghi + +mzpe +empjz +jmzp +mpbz + +kbgholzavfjutre +vkbflohajtgzdue +laehdtzbkjgvufo + +mksxpqw +kxdlqpwm + +jhewpxntlrvisbycqaok +ceblxiswkntpjqhyrva + +i +gi +i +i + +byceaxmljr +bcajlreym +qcvmsayeljrb +cexralmjby + +xzhdecapmbgqouvry +jrzahoeuyqmxgdcvipb + +vaxhrge +qivl + +x +x +x +o +x + +qoglswaiv +scapvgoi +iwvpagosq +giuktfoajveys + +dmfoth +ybkp +bj + +wfvmze +zefmvw + +ciw +cwsg +cwya +odcwi + +riuva +huprevai +iavur +raivu + +nqrlytspvekxiacgh +hwdvjstbfxucmzoae + +xwyihe +ihwexya +yzxiwoeh +yxfioewhzn + +jymrpqltwzo +ortjpmywqzl +pyqortzlmwj +mzbqpjyrotlcw +zwmproltyjq + +up +n +x +t +t + +vbdjgfiakcwxrntyq +urvxceigtflwqbj + +aepynl +ltenfayp +aepnly + +rskdym +z +u +fvz + +swzboecmj +ofqysr +dlso +rfsol + +bvwgndfhje +wevnbcihpgjd +kbhjuswnzyvodg +qjngblwmhdav +hiwdjfvpbgn + +bulfevqhkcnyxogzadstpr +fpqdxoblcknsevratuhzyg + +wp +pwr +wpr +wp +ypw + +umwny +mnywu +mynuw +uymwn + +zyhjm +myuhbj +jyhkm +yqnhjlxm + +brecz +zcerv +dctszxjrp + +azmkg +ngzm +femogjzhqx + +ujlo +gobszle +ralxodt +iqldo + +ipkcmsehutzngq +ksvchgpeq + +o +zxyv +caqyes +xmp +lfjthgdbink + +qtpmfhdbjgy +dtqbmjhygfp +jtyfwdhbmqp + +zjtcidfwepbvha +ujbcpqyizadrtkfs +dnxglbapmtiojfz + +rplygqnjwhfsuz +hnlaocqyudkpbirfj + +oncarbktqsdjeli +deiwumxnrbgsycktlaohpq +qsntcboridkael +rtoicjbldnvkeqas + +vogznx +eovpxng +qvonxdg +vogxn + +tfyrgliaqpw +rptiedfoycgz + +hvxstno +vixwoth + +uzhlafxegir +izghfexular +lhmieusajzfx +rxufzolhaei + +jhzbgrysnmxipqkdoltwuc +busrxgqjwpkhmdztfvnlcio +ipvqxmtulgdojzswrcknhb +zojluhprndmtgkswqcbxi +nlpcwougbtkdhjzqsmrxai + +guxsefpdcat +euaidxrmpk + +rm +am +mi + +kanjlqisd +nlqjski +kilnjsq +lnjqiks + +ofmj +oljf +fo +oif +ofl + +xsohetukdvfw +clofshvdnuex + +gbrdntxhuaos +bhdrxgatsunol +odtxgharbnsu +asuohtxrbngd + +vs +vs +vs + +difybepzm +yezbdpo +zevdgpby + +icwrnxsaovymfbjlhtzuqepgkd +vindcpwxmkbyejgtozfurhsqla +oevdyibthljamzcqrpxsfnkugw +kbjramizwvlpnxgsodtfyqcehu + +zvwshtxlpbafy +tafplbzhsvygw +kcvshbtylzwdfpa + +gpkzqnfdca +xygqkadpcfnz +nqidzcfpaxgk +nagpsxqukczdf +wqznfmlrkbgcdpa + +afnuj +jna +ju +fj +jq + +waudphkvszbqmf +kswhzumvacd +askzuhmvwd +dhwmkusazlv +kdvsuhazmwc + +xrgbhtluzdicsvjn +lstzbjhavugkyix +gxehjbvsilzut +xblmqszghvtuji +zsxbjulohgvptqiw + +segdrut +eustdjgr +shgervtdu +rgusetd +tesgurd + +arypx +rp +pr +pr +pkr + +ervlysmukiwnb +bkuvyhewrmnli + +jwx +vw +w +ncwi +wmg + +vxjlhgbqcswunpoae +sqbenjxgphwcoualv +ulokbivqwjxghcrspeazn +qousgvehtwlabfncjxp +cvuhawpgqysbolxjne + +eayjmtgdnwhbpri +dpgabyrnhiejt +egdtnjoyrbpaih + +dzrcxijobqhugelwm +lozdwgbcmujhqex +bnzdeuxwmcghqloj +yucoplsqjewmxdbhgz +eoxtdbumhcjlqzgw + +thlgnpdqzxrjmovci +qzmwfrgej +srgukazjmbyq +grmqzjb + +kqaiuy +qiukatd + +unbvhmkcw +blihfmencuw + +ilzpukbaefrcn +xaemrhbdlwkgt + +jotn +xsj + +aiefcuhd +fhdiuaec +tudifcahe +idchfuae +udhecifa + +ewihbavof +xheiodmv + +biemhqwz +ibzemwhq +bzwehimq + +pdo +hvp +jpnx + +homceuqkwtfzlsiajnxp +xwelmjhnpfckasuiqtzo +msxwkpfozinetuhjalcq +lmzkqfexiwsthcaopnju + +rhtd +hty +yth +vhcut +htd + +t +t +t +t + +klubenvtifwzosm +jathfcopmkgwvi +vmxtrwyofiqk + +hknuqsa +cernkmusjp +skanu +sakunx + +nxaodviqstkb +tikaqsfxovd +xavmyopsdqti +atsdvxiolq +iqxvjsowarzetugd + +x +y + +hpqnri +hybnxwqmp + +hxykaufsvezitgwcn +nsvxciguhp +bhvgucxnis +nhugvcxsi +uhgcnivsx + +ndlcpzg +lpczngd +czgdpnl +dglnzcp +gpzalncd + +okhjd +yaziks +xybksiev + +hwgny +fythgn + +y +npa +z + +mfothwgpecuq +epuwhgctofmq +cmhutoweqafpg + +dkeobv +ebvdk +vbkdeo +dkqvbame +kodbve + +ae +e +eq +ex + +mrixcujkpbdagsnzoefl +dojmzlesrncabfxupigk +ifnbcmxzodkpjeaslugr +lxbudepfncoagjkrszim + +t +r +t +k +y + +cetgjhowruyandsixlm +xlhwogaiscjrdm +opivlrbzcxhaqgwjsm + +crpawehus +cpuerawmdh + +vmydxksc +vmxdykscz +symkcvdx +xdysmvkc +xkyvsdcm + +nmavdr +mdvnra +dvmanr + +wehnsuti +uiwsenth +wsheutni +huswitne +usiehnwt + +zqcskloxp +pklczxs +pxcszkl +lxszpck +lpkzxsc + +wnusyg +amsnyiuw +synjmupw +dbtezqsunyof + +avjekgyidul +eivgkujyal +luqvijawykecgt +jkliyeaguv +ldvkgiayeju + +wcjxemvzohnq +cweoxnhqjvmz +hzwxqjcvoemn +voqjmcnxezhw +wxcmjnezvhoq + +sojluqwmcpybn +tinkbwmjcqslxup + +npjkeursaw +kesypranwuj +karejslnwup +rpwnskjeua + +xadl +rdlaf +alrd +dla + +jngt +jtg +jltgc + +nivy +inyv +ynvi +nyiv + +oufe +o +o +vo + +h +eh +jxm + +nswibqrletfzxoadumjky +maxefksqdjnlocztirwuyb +edriwobkmlpusnzjgqatfyx +iukzwoyfaqsljrtmedxnb + +b +b +b +kb +b + +gunvw +vnuwg +uwgnv +wvugn + +k +k +mk + +el +e +e +e + +obswpcdvkthyal +ltsbyizcxvpn +qpsytmclvb + +ktaicp +kpcawit +vptcakqwi +nhctiukp + +kuehwjgn +ukhjnwge +hungkwje +khujweng +gnukhjwe + +wruheclqy +fychwdqlu +qcyuehwlg +vcywupzinslxqho +qywhclu + +esngwivkr +swgeirkvn +vwsrenkig +ekvisrgwn +irekgwsnv + +ivrhjsugaxpeydczoqnfwbtm +hoxwtzbifdpyqvancmujgers +ujgbnsmeayqrpfcxiotzdhwv +bdtrvxfoimpcuegzhnsqajwy + +t +t + +eozdykwi +lwtm + +myiext +qi +riuqjlnp +ipko + +gbaf +gfbtsa + +jliadfuqczs +hjyvdixtngmp + +ncv +cnv +vcn + +so +os + +imkusqbevzwtanlr +aqmeunbxlivzwrtks +msibaqetznukwfvlr + +kavi +viduya + +uahvskndgwrzictfqjoy +iuptfmzxgjrwvdyboahnq +roadwcfyjhuszgqvint + +ivpmqatdsr +gzmitpdus +axtvqijpdsm + +ntuxeg +iezodns +yfcvbnlkh + +kdipzhrjgl +sprqzy +uirdbfcwzpe + +vopubjyhwgqzndexkmacftrl +zeivofqjwrmtkglxpbduahncy +ckarxmehtqwjfubolpvdzgny + +rfwtymkx +xtkwdym +mktcyswixn +ldkwtfmxayq + +of +of +of +of + +grjoqf +kefnujog +gbrofju +fjhztgo +gpjoavfx + +bu +bu +bd +bu +b + +tvnlgr +tlrgnvh +nglvtr +ngrtvl +trvlng + +tlfnpacmrzodus +ucljdqomtxzfs +cosudmxbztijlf + +tcqj +i +xgi + +dfhgkomiswlvnaqtebcuyzx +ceakvtplgudiyszmbohxqfn +zcskdtnlfjigbvoqexuayhm + +genkycqds +psdqgney +seqydngh +sldgyneq +desnyqhgb + +joryigvaehsbpuqlxcdtz +zejtdarybqcvhpulsgi +iclreapvjzbdtguhysq + +hz +zhr +czlwbhqjaos + +pdjavbqnoksgcemr +eqrtcokdvngapmsj +odljrveknqzmywscigpa +rjtepqdhngavmobskc +jgoarvspnxdkcemuq + +ncjzxeila +vpwztj +ozrjdhp +jyzv +zhjqkt + +bqjkozxyrcpgvif +vqryjgzpibckxfo + +mey +g +ixh +eo + +cshyvjlwfrzx +fjlyrcvzohsx +jcfryptdnkvlxsh + +ajrmzwqeyopinfdtvhlub +ynijdwhpqlorfbtzauemv +bwaunojvpzylqiedfrthm +ldecnzpmrjvbyfwtiohgxauq + +d +rdo + +swyfcgqmerv +eqckjrygwl + +z +z +z + +jiqmtd +medqjv +mdqij + +dc +dvbto + +wmqal +lqmaw +lawmq +lmwaq + +eskloxhvcmqidanrg +jgsqokvixcfmerhandl +eqhgyodxrnkmvcisla +hsknqliecgarxodmv + +dowujxam +xjomudwa +amuwdjox +muowxjda + +dnvkzyq +zeyqkvd +jcyedvqkz +kdbzimsqahyufv +dqvzyk + +vtxbmlre +mxrlev + +gvkzdaybmieuon +kunaiozev +inuxovakze +pcskafrzvhineuo +vuzkodinae + +y +y +y +y +uby + +ifpwdumxkasjctgoh +suoipdqckfhlmwjantx +xiscayejzhpukgwtofdm +ymspjiwvxhfokdutac +sdhcmiotaxuwkpfj + +uoqfihpzxtyrg +jfhxoduylrbetzkm +youtwfnzxsrh +prxzoyufhctn + +grcuhy +aoybvc +udlcvq +chg +mjeztsfck + +gytbdpfxejszmc +hliaxrtkc + +oiakun +anhukio +zuakino +koenqduia + +jbtgwvex +rlasxquebch + +kmhlsizfcdyvoea +kfiglaydnhsmvzep +mhvfeylxksazdi +slmaefdiyjzhuvk +ftshlkiydzvemca + +bxvmzrt +mbrxtu +btrxyqpimha +ldbvtxrfm + +uiwertlnygfmjxsdkbzoa +ztjxwbdrfmiusyoge +zybugaximtjwfrodes +uzfijsxymdbrtegow +cyoebvmqipguxjdwzsrtf + +wyhiqzl +uqlyizhw +ifhywlzq +heiwkqzvytl + +mtkiqvcawhlxgd +hwgtadkxqcvim +cixtdmvqwsaghk + +wo +to +o +oj +o + +cyzokbegi +giyeczo +geyiozc + +ejndhrgzbqsptla +jasplgbedhrntzq +jsbtzpanlrehgdq + +ndcvtbgk +ncgkdvr + +potxyvesh +bsfouxewgyv + +wkbcr +jr +r +r +r + +xqpukenjsmyzfw +efyspmkxzuqjwn +fsupyemwxqznkj + +bixsvtrwzu +ralusjgthmpfcvdny +twsvkur +tvoeiurs + +gmpedxaobntlquwsjhciyzfkvr +ijgmfetxwsoyzucvkpqahrbdln + +bzonmpgjfrciqdskv +nkscpmvqrgizodjbf +icsvjbgfnlzrkpomqd +nqorbikmsgcpfdzvj +nomzvcsifkbgpdqjr + +yoel +loye + +kspzboay +upxbvyozsjk + +pnykvmqzhtboxdaljgeirufswc +ndhcexmartsjlypfgzwbkqvou + +lui +ilu +lui +liju +ilu + +eojbguvxs +xhvzenmc + +qtfwzmuhoans +noypqgvrfljc + +pszrwk +dkrwsqp + +sheyiqcwrzbutvplfj +hxqoywagjpukzvlnrise + +kwpqa +qka +qak +kaq + +ojtvri +sbjit +ejit + +etczgwk +ctkzfew +rkdvsqjyxltmhzew +zoebwkt +obwgektz + +qjosv +jxqsov + +mebwuxynkv +byfuknpvmxwe + +qpftwxhlk +gqwifvmcxkpytrl +lqxpfwkt +nhpqzwxlftk + +nu +un +un + +aftyngmwieolzpjdvq +mintwqfdpgjezvyola +mfyvadogzitwjeqlnp +dyjrxgfqmpilenztowva + +vum +mv + +gkxybcujezdwfp +pkdbwlyjxguefc + +akicjusonfe +egkmrouphjf +ryeoufkgj +jxlkfroeuq + +lqgzhrtscypfwajvo +vqstjcyolprwafz +qyrpvjozflwtcas +jvycuptolrnfazkswq +ryazxijfstovpwecql + +wfzjtluc +fjuczlwt +ztjwfucl + +bgpqvhejoic +rcytxhzwudkln + +ueybks +bkued + +gxfbtcizvoejykl +xgycivjhprldof +jvicmoxyflgw + +hor +hro +hro +roh +hor + +ryaewmnbvqxskzg +nwqgtmdkich + +pduyifmqevl +idwqevpfy +pldfveyqi +nxgqoadpyzveifj +yvpdefqci + +tjsmluz +aozs +zgosd +sioza + +huty +okyu +pmgfxjuye +iuhyko +uyoqah + +iqmzkug +qizkmg +mgldirzkx +mikzge +gmzkit + +ov +vo +ovwq +solv +vo + +vqref +qvfre + +bvnksxythm +ztbnvhsmqy +cfstyvnomlbhr +dbhaytszunvim +mybjkhvtns + +ylxvqwrmg +lxroewygv +ahyxvnzsulkrw +mvxlrdiyw + +kpuob +dbop +dpob +pbo + +adijclzeb +eblzjaic +wfbaczjeli +blcjeiazx + +klys +lptsx +kylsw +swl + +moezgwihl +mwhzoeig +iehmdgoz + +ldnau +udl +wdltmcf + +lbdpxuvif +lnqamdcobk +tldifxbzu + +fotkdyu +chvxidoue + +ybmcivurgz +yrzumibvgc +yubczgrmjvhi +zigrvybmcu + +unw +wun + +gyu +uy +yu + +nridthojbluzev +ruhnexqyvzckfat + +wkxevsricdaobfjmgu +vrwijgadcxqbesumfk +jwecbvfikxsurdmag + +krcyexlnpmauqbvhzstfdgiwj +qfgranzpmlwtkcxvsiedyub +axdteyfqvrzulwmnspbcgki + +ya +ya +ya +ay + +ftq +m +m +h + +ysufbamev +uts +stuo +usr +tus + +vhqpgtexomabijdclwur +lmnzriyfupwsgxvjkhqebc + +yvtglrsdauwczfmexhbnk +nsbxdtigmkwcuvreyzlha +sacrwyhlkmpunzvidbxget + +hw +w +w + +ftnkzjopcd +lcqyvegub + +rz +bcl + +ypquzcndevm +xvefdlrycmpzos + +trjcni +niatrc +aticnrj +nceritp + +fkyv +nm +amd + +v +v +upm + +bncvspw +qyzaukrgctjidol + +vqg +qvg +gvq +gqv + +spqfwgejyvbctidxz +brcfnzjtuqdwsiglhyxe +oibsyjtkcgfxdqzwe +pwfzqsycebotxdgij + +ve +ovc + +enmhy +xsovube +yre +raqzem +enht + +posdnhxbacmykvfwzrqelt +kbtpvhyufazdwmncojslq +tuhoavbpqnlydcfswmzk +dsfzkcmtnwovbhpjqlya +kjqdcohmpfvybtwsnlaz + +hertdw +wtdreh +hdtiuwesjrg + +xnydqrlau +xduclranyf +vyrxuldan +xyrusadln + +lvkhfogn +jtiyzaq +rxbpwuk + +kixeqphrutyca +dvjblmosz + +hjcgypifnmtebdwv +dtivyhmgnbeuwfcpj +cbjqeiwdmytvpfgn + +nuojfltd +swkqftlmjn +zarpivltcj +tyjbslq +hlbutqj + +oakrtfhsw +fswahocrkt +hosraktfw +rohwafkst + +insvwpjxgdfryeuo +kczq +zcb + +wa +iq +rq +jq + +gvke +daewubpn +ykzeh + +obuimdwklfzrsct +ruzkwoxadmfytl +tfdzjurxeqnlgokmvw +wtymkalfzderuo +ldrptzhaxmfouwk + +qsnk +ks +ks +szk +ksy + +ypdv +pihd + +vy +osxjmwklf +achbiqyntr +ned + +dcqgyiflm +gqcfn +fcqgwnh +qpgfkhbc + +qesdpalbnfjyrzhim +xocesfutkghymvb diff --git a/2020/06/sol1.pl b/2020/06/sol1.pl @@ -0,0 +1,23 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +my @groups; +open(my $fh, '<', 'input') or die "$!"; +{ + local $/; + my $content = <$fh>; + @groups = split("\n\n", $content); +} + +# reduce each group to a bag o words, then uniq, count +my $n; +for my $g (@groups) { + my %yes; + for my $m (split("\n", $g)) { + chomp($m); + $yes{$_} = 1 for split('', $m); + } + $n += keys %yes; +} +print "$n\n"; diff --git a/2020/06/sol2.pl b/2020/06/sol2.pl @@ -0,0 +1,25 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +my @groups; +open(my $fh, '<', 'input') or die "$!"; +{ + local $/; + my $content = <$fh>; + @groups = split("\n\n", $content); +} + +# reduce each group to a bag o words, then uniq, count +my $n; +for my $g (@groups) { + my %yes; + my @members = split("\n", $g); + my $goal = scalar @members; + for my $m (@members) { + chomp($m); + $yes{$_} += 1 for split('', $m); + } + $n += scalar grep { $yes{$_} == $goal } keys %yes; +} +print "$n\n"; diff --git a/2020/07/input b/2020/07/input @@ -0,0 +1,594 @@ +faded yellow bags contain 4 mirrored fuchsia bags, 4 dotted indigo bags, 3 faded orange bags, 5 plaid crimson bags. +striped olive bags contain 4 dark crimson bags. +dotted indigo bags contain 4 faded black bags, 4 clear cyan bags, 5 vibrant teal bags. +plaid crimson bags contain 3 shiny gold bags, 3 plaid gray bags. +muted fuchsia bags contain 3 shiny bronze bags. +plaid gray bags contain no other bags. +dull maroon bags contain 2 posh maroon bags, 3 wavy aqua bags, 2 faded white bags, 5 posh bronze bags. +dull red bags contain 3 striped silver bags, 2 dark tan bags. +muted lavender bags contain 3 striped red bags. +shiny lime bags contain 1 dotted olive bag. +dim violet bags contain 5 faded orange bags, 4 plaid green bags, 1 faded black bag. +wavy indigo bags contain 4 bright aqua bags, 2 dotted orange bags, 2 vibrant yellow bags. +vibrant purple bags contain 3 plaid indigo bags, 3 dark gold bags, 3 striped yellow bags, 3 light tomato bags. +plaid plum bags contain 1 faded silver bag. +striped teal bags contain 2 shiny crimson bags, 1 dull gray bag, 3 vibrant teal bags. +posh crimson bags contain 2 light violet bags. +pale maroon bags contain 2 wavy maroon bags, 1 dotted white bag. +drab cyan bags contain 4 dim violet bags, 5 pale tan bags, 3 faded black bags. +bright black bags contain 2 faded magenta bags. +dotted green bags contain 3 muted cyan bags. +striped chartreuse bags contain 5 posh silver bags, 5 wavy violet bags. +drab olive bags contain 5 dull blue bags. +drab green bags contain 2 vibrant violet bags, 2 dim violet bags, 2 light brown bags. +dark violet bags contain 5 drab brown bags, 4 dim chartreuse bags, 4 dark salmon bags. +faded orange bags contain 4 dull lavender bags. +dark fuchsia bags contain 2 clear tomato bags. +plaid gold bags contain 3 clear tomato bags. +muted red bags contain 1 muted green bag. +dark coral bags contain 5 muted white bags, 3 mirrored indigo bags, 1 shiny blue bag, 2 drab green bags. +dark chartreuse bags contain 2 bright teal bags. +dim silver bags contain 4 shiny white bags, 2 vibrant plum bags, 3 clear plum bags. +clear silver bags contain 1 dull gray bag. +pale gray bags contain no other bags. +plaid chartreuse bags contain 3 dull brown bags. +dotted crimson bags contain 3 pale olive bags, 2 pale black bags. +dark blue bags contain 1 light red bag, 5 striped turquoise bags. +dim white bags contain 5 bright white bags, 4 light magenta bags, 4 wavy chartreuse bags. +striped magenta bags contain 3 dull coral bags. +drab bronze bags contain 4 bright red bags. +light gray bags contain 1 mirrored coral bag. +wavy brown bags contain 4 clear lime bags, 1 plaid lavender bag, 1 faded lavender bag. +bright violet bags contain 5 clear indigo bags, 1 plaid indigo bag, 3 light beige bags. +drab tan bags contain 4 drab chartreuse bags. +shiny teal bags contain 1 bright tan bag. +dark silver bags contain 1 drab orange bag, 1 striped plum bag, 2 bright gold bags. +wavy turquoise bags contain 3 striped gray bags, 1 dotted lime bag, 4 pale plum bags, 2 vibrant orange bags. +wavy red bags contain 1 dim gold bag, 1 striped turquoise bag, 1 bright red bag. +mirrored yellow bags contain 5 faded cyan bags, 2 wavy green bags. +wavy blue bags contain 5 dark violet bags, 4 vibrant gray bags. +mirrored olive bags contain 5 faded orange bags, 2 posh aqua bags, 3 dotted silver bags, 2 striped plum bags. +faded crimson bags contain 3 striped maroon bags, 4 pale tomato bags. +vibrant olive bags contain 2 wavy yellow bags, 2 mirrored orange bags. +vibrant fuchsia bags contain 4 dim yellow bags, 3 drab tan bags. +dotted tan bags contain 2 faded fuchsia bags, 2 pale turquoise bags, 4 mirrored gray bags. +mirrored beige bags contain 1 mirrored olive bag. +faded turquoise bags contain 5 dull yellow bags, 5 clear gray bags, 5 muted lavender bags. +wavy violet bags contain 5 dotted gold bags, 5 dull cyan bags. +light tan bags contain 1 dull salmon bag, 1 dull bronze bag, 1 dull tan bag. +wavy tan bags contain 4 drab black bags. +muted silver bags contain 1 dark lavender bag, 5 pale tan bags, 2 clear violet bags, 3 drab coral bags. +dull blue bags contain 5 muted olive bags, 2 drab salmon bags, 3 clear red bags. +bright chartreuse bags contain 5 dim teal bags. +posh bronze bags contain 3 plaid black bags, 1 clear lavender bag, 3 dim chartreuse bags, 1 plaid gray bag. +striped orange bags contain 5 dull turquoise bags, 2 dotted olive bags, 5 bright coral bags, 1 mirrored aqua bag. +posh white bags contain 4 dim tomato bags, 5 light salmon bags. +faded cyan bags contain 2 plaid crimson bags, 5 muted green bags, 4 bright olive bags. +dark red bags contain 2 bright blue bags, 5 faded turquoise bags, 5 bright black bags. +pale magenta bags contain 4 drab chartreuse bags, 2 light tomato bags, 5 dull lavender bags. +posh orange bags contain 3 muted gray bags. +clear tan bags contain 2 dim crimson bags, 3 light olive bags. +dark green bags contain 4 muted maroon bags, 5 striped gold bags, 2 drab indigo bags, 2 dotted silver bags. +dim blue bags contain 5 wavy coral bags, 4 shiny chartreuse bags, 5 bright teal bags, 2 drab beige bags. +dim indigo bags contain 2 dull cyan bags, 3 dark maroon bags. +dotted gold bags contain 4 drab tomato bags, 1 light cyan bag, 2 pale tan bags, 2 light tomato bags. +faded gold bags contain 2 drab tan bags, 5 mirrored chartreuse bags, 2 striped gold bags, 3 bright silver bags. +muted olive bags contain 2 plaid black bags, 3 shiny gold bags, 4 vibrant crimson bags. +shiny gray bags contain 4 clear violet bags. +dim teal bags contain no other bags. +drab fuchsia bags contain 4 dim purple bags, 4 striped beige bags. +dark cyan bags contain 3 drab salmon bags. +clear lavender bags contain 2 dim olive bags, 4 mirrored gold bags, 4 striped plum bags. +posh lime bags contain 4 mirrored teal bags, 3 wavy chartreuse bags, 2 pale cyan bags, 5 pale indigo bags. +vibrant gold bags contain 5 dim chartreuse bags, 1 mirrored red bag, 3 dark lime bags, 4 shiny silver bags. +light crimson bags contain 3 muted lavender bags. +dark lime bags contain 1 faded chartreuse bag, 3 shiny crimson bags, 2 drab aqua bags. +dotted beige bags contain 1 faded white bag, 5 vibrant yellow bags. +dim chartreuse bags contain 4 striped lime bags, 2 faded black bags. +wavy bronze bags contain 5 muted cyan bags, 3 light yellow bags, 4 dotted purple bags. +striped plum bags contain 2 drab black bags, 1 faded silver bag. +posh chartreuse bags contain 4 faded blue bags, 2 vibrant crimson bags, 4 dotted purple bags, 4 posh tan bags. +vibrant yellow bags contain 4 dim tan bags, 1 mirrored fuchsia bag. +pale salmon bags contain 2 dull tan bags, 2 mirrored crimson bags, 1 drab chartreuse bag, 3 muted crimson bags. +drab gray bags contain 2 vibrant coral bags. +mirrored teal bags contain 5 vibrant violet bags. +striped maroon bags contain 2 dim violet bags, 3 dotted gold bags, 4 bright olive bags. +clear turquoise bags contain 4 plaid green bags. +vibrant white bags contain 5 dotted beige bags. +wavy chartreuse bags contain 1 faded orange bag, 4 shiny lavender bags. +mirrored gray bags contain 1 clear magenta bag. +bright aqua bags contain 3 mirrored gold bags, 5 shiny magenta bags, 1 shiny silver bag, 5 posh tan bags. +plaid violet bags contain 2 muted olive bags, 2 dotted chartreuse bags, 2 faded magenta bags, 1 drab cyan bag. +plaid olive bags contain 3 wavy lime bags, 2 faded cyan bags, 2 posh tan bags. +bright crimson bags contain 4 clear beige bags, 1 plaid teal bag, 3 shiny magenta bags. +shiny salmon bags contain 3 light silver bags, 3 faded orange bags, 3 dim tomato bags, 3 shiny gold bags. +mirrored red bags contain 5 shiny black bags. +shiny fuchsia bags contain 1 faded yellow bag, 1 plaid teal bag. +wavy tomato bags contain 4 light crimson bags, 3 clear blue bags. +clear lime bags contain 4 dark gray bags, 5 drab tomato bags. +light maroon bags contain 3 dark plum bags, 4 plaid crimson bags. +drab yellow bags contain 3 vibrant aqua bags, 5 pale red bags. +mirrored fuchsia bags contain 3 pale purple bags, 1 clear yellow bag, 1 wavy black bag, 4 pale gray bags. +clear black bags contain 1 plaid lavender bag, 4 muted indigo bags. +drab silver bags contain 1 faded green bag, 3 pale black bags. +clear teal bags contain 2 dotted silver bags. +plaid indigo bags contain 4 dotted purple bags. +striped indigo bags contain 1 mirrored indigo bag, 4 faded plum bags, 4 wavy crimson bags. +light salmon bags contain no other bags. +dull plum bags contain 4 plaid cyan bags. +muted tomato bags contain 4 dark violet bags. +mirrored orange bags contain no other bags. +striped tomato bags contain 5 dotted chartreuse bags, 2 dark white bags. +dotted magenta bags contain 2 wavy gold bags, 5 pale gray bags, 2 bright chartreuse bags. +vibrant blue bags contain 3 dotted cyan bags, 4 clear gold bags, 2 dark cyan bags. +mirrored crimson bags contain 1 dim salmon bag, 4 posh aqua bags. +shiny turquoise bags contain 2 striped blue bags, 2 light orange bags, 3 dim fuchsia bags, 2 dark olive bags. +muted gray bags contain 3 dotted yellow bags, 4 dim orange bags, 3 clear beige bags, 3 posh tan bags. +dim bronze bags contain 1 light magenta bag, 4 shiny purple bags, 1 light red bag. +dotted olive bags contain 2 dark crimson bags. +plaid bronze bags contain 4 bright silver bags, 1 faded lime bag, 3 striped lime bags, 3 drab coral bags. +posh blue bags contain 2 clear tomato bags. +plaid coral bags contain 4 clear turquoise bags, 1 plaid brown bag, 1 drab indigo bag. +faded magenta bags contain 2 wavy gray bags, 4 dark gold bags, 4 shiny white bags, 4 faded black bags. +light brown bags contain 3 striped red bags, 4 faded black bags, 5 vibrant violet bags. +dotted turquoise bags contain 2 mirrored orange bags. +pale bronze bags contain 2 mirrored silver bags, 1 faded cyan bag. +dark purple bags contain 1 muted lavender bag, 1 dull yellow bag, 5 vibrant tan bags, 1 dark gold bag. +plaid white bags contain 2 pale turquoise bags, 4 clear green bags. +wavy magenta bags contain 3 shiny blue bags, 1 dark yellow bag. +wavy gold bags contain 1 dotted indigo bag. +dull lavender bags contain 1 striped plum bag, 5 pale gray bags. +shiny silver bags contain 5 shiny lavender bags, 1 plaid crimson bag, 1 wavy black bag. +clear blue bags contain 2 plaid bronze bags, 1 shiny purple bag. +faded chartreuse bags contain 3 dull bronze bags. +pale blue bags contain 3 plaid yellow bags, 1 pale black bag, 4 clear magenta bags, 3 mirrored silver bags. +vibrant green bags contain 4 bright magenta bags, 4 dark black bags, 5 wavy chartreuse bags. +drab tomato bags contain 3 drab orange bags, 4 striped coral bags. +clear cyan bags contain 3 wavy chartreuse bags, 1 light salmon bag, 2 dim purple bags. +dim magenta bags contain 4 dim turquoise bags, 1 clear gray bag, 4 dim lime bags, 3 mirrored tomato bags. +wavy maroon bags contain 5 pale plum bags, 3 pale black bags, 3 striped red bags, 4 drab salmon bags. +posh gold bags contain 3 dim chartreuse bags, 1 faded blue bag, 4 mirrored teal bags. +muted aqua bags contain 2 faded maroon bags, 1 mirrored blue bag, 5 pale crimson bags. +muted orange bags contain 1 muted olive bag. +posh tan bags contain 4 muted lavender bags, 2 plaid crimson bags, 4 striped lime bags. +mirrored indigo bags contain 1 muted olive bag, 2 vibrant chartreuse bags, 4 light cyan bags. +wavy crimson bags contain 4 mirrored violet bags, 2 vibrant olive bags, 5 dull lavender bags, 1 drab cyan bag. +dim lavender bags contain 4 light salmon bags, 5 plaid tomato bags, 4 drab fuchsia bags. +dotted yellow bags contain 4 vibrant chartreuse bags. +light fuchsia bags contain 2 wavy red bags, 2 faded lime bags, 1 pale brown bag, 5 dotted green bags. +clear beige bags contain 5 drab chartreuse bags, 4 dark olive bags, 5 dim gold bags. +shiny gold bags contain 1 pale turquoise bag. +dim tomato bags contain no other bags. +plaid salmon bags contain 1 striped tan bag, 5 plaid purple bags, 1 mirrored crimson bag. +dotted lavender bags contain 3 striped teal bags, 1 vibrant gray bag. +light olive bags contain 3 posh tomato bags, 5 dim coral bags, 4 posh white bags, 2 dark turquoise bags. +striped silver bags contain 1 clear tomato bag, 1 drab cyan bag. +striped lavender bags contain 4 posh chartreuse bags, 5 faded coral bags. +faded beige bags contain 5 muted gold bags, 5 clear gold bags, 2 posh white bags. +drab indigo bags contain 1 pale magenta bag. +light blue bags contain 2 light chartreuse bags, 4 drab black bags, 2 dull bronze bags. +dull gold bags contain 5 dark blue bags, 2 bright green bags. +faded bronze bags contain 5 dim olive bags. +mirrored lime bags contain 5 pale crimson bags. +shiny coral bags contain 3 drab green bags, 3 posh white bags, 4 clear gray bags, 3 muted orange bags. +clear magenta bags contain 3 plaid olive bags, 4 plaid indigo bags, 1 dull blue bag. +wavy black bags contain 3 clear cyan bags, 3 dull bronze bags, 2 wavy chartreuse bags. +pale green bags contain 2 mirrored silver bags, 3 drab blue bags, 5 drab green bags, 4 pale tomato bags. +drab violet bags contain 1 drab orange bag, 1 vibrant indigo bag, 2 mirrored chartreuse bags. +light chartreuse bags contain 4 posh white bags, 5 dull bronze bags, 4 wavy coral bags. +dull black bags contain 4 muted red bags, 4 faded white bags, 5 plaid tomato bags, 2 dark blue bags. +dark gray bags contain 2 bright green bags, 5 light blue bags, 3 light tan bags, 2 shiny gold bags. +light turquoise bags contain 5 shiny coral bags, 3 dull brown bags, 3 striped tan bags, 4 striped silver bags. +mirrored magenta bags contain 3 vibrant silver bags, 4 vibrant crimson bags, 4 shiny coral bags, 1 shiny indigo bag. +dull lime bags contain 3 pale turquoise bags, 2 bright olive bags. +mirrored gold bags contain 1 faded silver bag, 4 pale gray bags. +clear chartreuse bags contain 4 dark gray bags, 1 pale lime bag, 1 plaid fuchsia bag. +dull indigo bags contain 4 posh silver bags. +dull yellow bags contain 3 wavy lavender bags, 3 muted maroon bags. +bright silver bags contain 2 wavy black bags, 1 dim coral bag. +clear indigo bags contain 1 posh black bag, 4 muted teal bags, 1 wavy maroon bag. +bright brown bags contain 3 shiny cyan bags, 5 clear green bags, 1 wavy magenta bag. +shiny crimson bags contain 1 faded black bag, 2 vibrant chartreuse bags. +striped white bags contain 4 light red bags, 3 dotted cyan bags. +pale tomato bags contain 1 posh white bag. +posh salmon bags contain 2 striped white bags, 5 clear purple bags, 5 bright yellow bags. +faded blue bags contain 5 drab cyan bags, 1 plaid crimson bag, 5 light crimson bags. +mirrored black bags contain 4 light tan bags, 3 faded blue bags. +bright red bags contain 3 pale magenta bags, 4 faded chartreuse bags. +drab lavender bags contain 5 dim red bags, 4 wavy black bags, 4 dull cyan bags, 5 clear gray bags. +light coral bags contain 4 dark lavender bags, 2 clear orange bags, 2 dull maroon bags. +bright plum bags contain 1 shiny blue bag, 5 striped salmon bags, 2 plaid olive bags. +faded tomato bags contain 4 pale turquoise bags. +wavy purple bags contain 1 light red bag. +striped crimson bags contain 2 shiny tan bags, 1 striped salmon bag, 5 dotted cyan bags. +posh olive bags contain 3 vibrant indigo bags. +plaid red bags contain 4 dotted violet bags, 1 plaid black bag, 4 light chartreuse bags. +pale aqua bags contain 3 plaid brown bags. +dotted silver bags contain 5 striped plum bags. +plaid magenta bags contain 4 clear lime bags, 1 muted chartreuse bag, 1 dark gray bag. +vibrant plum bags contain 3 clear yellow bags, 1 striped salmon bag. +faded lime bags contain 5 dull plum bags. +wavy lavender bags contain 3 dull bronze bags. +clear olive bags contain 5 pale bronze bags. +striped cyan bags contain 2 dotted gray bags. +drab black bags contain no other bags. +posh turquoise bags contain 1 clear teal bag. +plaid lime bags contain 5 pale gray bags, 5 shiny black bags, 2 faded tan bags, 4 clear lavender bags. +drab maroon bags contain 4 posh maroon bags, 3 drab lavender bags, 2 shiny lavender bags. +dull beige bags contain 3 mirrored coral bags, 2 faded fuchsia bags, 5 bright fuchsia bags. +dull bronze bags contain 2 mirrored olive bags. +striped violet bags contain 2 vibrant orange bags, 3 muted indigo bags, 5 light plum bags, 2 dark lavender bags. +striped fuchsia bags contain 3 striped salmon bags, 4 posh brown bags, 1 posh maroon bag. +light aqua bags contain 4 clear plum bags, 1 dull orange bag, 5 wavy magenta bags, 5 pale chartreuse bags. +wavy lime bags contain 1 mirrored teal bag, 1 posh tan bag, 5 clear teal bags, 4 plaid crimson bags. +plaid fuchsia bags contain 4 dark gold bags, 1 muted red bag, 4 light tomato bags. +muted white bags contain 5 plaid brown bags, 4 dotted plum bags, 3 dim crimson bags, 3 dim aqua bags. +pale white bags contain 4 mirrored chartreuse bags, 2 bright lavender bags, 5 striped teal bags. +vibrant aqua bags contain 3 faded green bags, 4 muted tomato bags, 2 clear lavender bags. +posh red bags contain 4 bright chartreuse bags, 1 clear red bag. +striped yellow bags contain 2 faded aqua bags, 3 light fuchsia bags, 5 dotted purple bags, 5 drab coral bags. +shiny lavender bags contain 2 faded orange bags. +dull coral bags contain 1 dull tan bag, 2 dull beige bags, 3 faded maroon bags, 1 wavy aqua bag. +faded violet bags contain 5 clear red bags. +dark turquoise bags contain 3 light chartreuse bags. +plaid silver bags contain 2 drab cyan bags, 1 dotted gray bag, 4 pale orange bags. +pale tan bags contain no other bags. +light white bags contain 2 shiny lime bags, 5 dull lavender bags, 4 plaid white bags. +dim beige bags contain 5 dotted silver bags, 5 dark gold bags, 1 muted turquoise bag, 1 pale olive bag. +muted crimson bags contain 2 faded silver bags, 2 dark olive bags. +shiny tan bags contain 2 dotted salmon bags. +dull magenta bags contain 3 drab black bags, 5 dim purple bags, 3 mirrored bronze bags. +dull white bags contain 1 clear teal bag, 2 faded violet bags, 4 dull bronze bags, 2 dotted gold bags. +clear green bags contain 3 pale crimson bags. +dark bronze bags contain 4 shiny cyan bags, 5 shiny white bags. +vibrant red bags contain 2 dark tomato bags, 3 muted crimson bags. +striped brown bags contain 4 pale yellow bags. +light bronze bags contain 5 drab silver bags, 5 wavy purple bags. +vibrant tomato bags contain 4 mirrored orange bags, 3 faded teal bags. +bright coral bags contain 4 clear maroon bags, 3 dim chartreuse bags. +shiny green bags contain 2 muted crimson bags, 5 pale tan bags, 3 drab black bags, 3 striped teal bags. +mirrored green bags contain 2 light black bags, 5 posh purple bags, 1 posh tan bag, 1 mirrored orange bag. +dull tan bags contain 3 bright tomato bags. +muted indigo bags contain 3 wavy coral bags. +shiny blue bags contain 1 wavy black bag, 2 dull maroon bags. +posh beige bags contain 5 dim crimson bags, 1 posh white bag, 2 mirrored teal bags, 2 vibrant chartreuse bags. +dim plum bags contain 2 vibrant chartreuse bags, 2 posh teal bags, 3 drab white bags. +vibrant teal bags contain 2 dim tomato bags, 2 dim teal bags, 4 drab chartreuse bags. +wavy olive bags contain 5 vibrant gold bags, 2 drab black bags, 2 shiny lime bags, 2 light coral bags. +faded white bags contain 4 posh cyan bags, 1 bright red bag, 2 pale olive bags, 3 plaid olive bags. +pale indigo bags contain 5 dim crimson bags, 1 dim tan bag, 5 plaid green bags. +pale fuchsia bags contain 4 light purple bags, 4 clear beige bags, 3 muted teal bags, 3 light blue bags. +faded gray bags contain 1 clear maroon bag, 2 dim fuchsia bags, 5 bright purple bags, 4 striped turquoise bags. +dark lavender bags contain 1 muted lavender bag, 2 vibrant crimson bags, 1 clear yellow bag. +light magenta bags contain 5 faded coral bags, 3 muted green bags, 4 mirrored fuchsia bags, 1 clear coral bag. +plaid cyan bags contain 1 muted crimson bag. +dim gold bags contain 3 clear cyan bags, 3 dim tomato bags, 3 shiny lavender bags, 2 vibrant teal bags. +bright tomato bags contain 1 striped red bag, 1 vibrant violet bag, 4 striped turquoise bags. +drab teal bags contain 2 posh turquoise bags, 1 shiny black bag. +pale olive bags contain 2 shiny gold bags, 3 posh bronze bags, 4 bright tomato bags, 2 bright olive bags. +pale brown bags contain 3 clear tomato bags. +dark yellow bags contain 3 light brown bags. +pale black bags contain 4 bright silver bags. +muted brown bags contain 2 light crimson bags, 4 drab chartreuse bags, 5 pale turquoise bags, 4 posh white bags. +wavy beige bags contain 2 posh maroon bags, 5 dark turquoise bags. +shiny olive bags contain 1 light salmon bag, 2 light crimson bags. +dotted teal bags contain 4 pale turquoise bags. +clear bronze bags contain 1 dotted tomato bag, 5 striped maroon bags, 5 shiny plum bags, 4 clear lime bags. +dim lime bags contain 3 dim lavender bags. +shiny aqua bags contain 2 clear plum bags, 1 plaid lavender bag, 2 faded aqua bags, 1 dim purple bag. +vibrant lime bags contain 4 dotted plum bags, 2 muted gray bags, 1 posh beige bag. +muted beige bags contain 1 mirrored lavender bag, 4 muted plum bags. +wavy yellow bags contain 4 posh cyan bags, 5 dim gold bags, 3 vibrant violet bags. +bright purple bags contain 1 bright chartreuse bag, 5 posh violet bags, 2 pale purple bags. +vibrant violet bags contain 2 wavy coral bags, 2 pale gray bags. +faded indigo bags contain 5 muted tomato bags, 2 dull tomato bags. +mirrored brown bags contain 1 shiny white bag, 4 dotted lavender bags, 3 striped cyan bags, 5 clear crimson bags. +bright beige bags contain 2 bright salmon bags. +bright gold bags contain 4 plaid crimson bags. +drab gold bags contain 5 pale tan bags. +bright orange bags contain 1 vibrant gold bag. +shiny brown bags contain 4 plaid lime bags, 4 dull gray bags, 1 pale tomato bag. +striped beige bags contain 1 clear yellow bag, 1 pale magenta bag, 4 dull bronze bags, 5 bright fuchsia bags. +clear brown bags contain 2 bright salmon bags, 2 vibrant turquoise bags. +muted turquoise bags contain 5 dim crimson bags, 1 drab chartreuse bag. +dark crimson bags contain 5 bright tomato bags. +clear yellow bags contain 2 dim olive bags. +bright lime bags contain 5 faded gray bags, 4 dull gold bags, 3 dark salmon bags, 4 posh lime bags. +muted coral bags contain 3 posh bronze bags, 3 striped gold bags. +dark salmon bags contain 2 vibrant indigo bags, 5 posh coral bags, 3 faded silver bags. +vibrant orange bags contain 4 dark turquoise bags, 2 vibrant lime bags. +pale violet bags contain 1 shiny brown bag, 2 dim plum bags, 3 dull crimson bags, 3 bright orange bags. +shiny purple bags contain 1 vibrant lavender bag, 1 dotted yellow bag. +drab orange bags contain 3 faded aqua bags. +posh brown bags contain 3 pale magenta bags, 4 faded orange bags, 1 drab chartreuse bag. +shiny bronze bags contain 3 light magenta bags, 3 drab indigo bags, 5 vibrant yellow bags. +muted teal bags contain 3 dim olive bags. +bright turquoise bags contain 3 bright chartreuse bags, 4 mirrored tomato bags. +muted chartreuse bags contain 4 faded gray bags, 1 dull salmon bag, 3 clear beige bags. +clear white bags contain 3 muted maroon bags. +posh violet bags contain 4 shiny white bags, 1 dull orange bag. +dotted brown bags contain 4 muted aqua bags. +mirrored plum bags contain 5 clear plum bags, 4 faded tomato bags. +drab crimson bags contain 1 pale white bag, 4 dotted maroon bags, 2 drab beige bags, 5 drab tan bags. +plaid black bags contain 1 light salmon bag, 3 mirrored orange bags, 2 dim purple bags. +dim orange bags contain 4 wavy black bags, 1 clear red bag. +faded plum bags contain 1 posh violet bag, 1 pale silver bag, 4 muted magenta bags. +vibrant salmon bags contain 2 dotted red bags, 1 dull maroon bag, 1 plaid tomato bag. +muted cyan bags contain 5 posh aqua bags, 2 faded silver bags, 2 striped red bags, 4 dim tomato bags. +muted salmon bags contain 5 muted teal bags, 3 striped cyan bags. +dim cyan bags contain 5 drab brown bags, 4 muted red bags, 1 wavy coral bag. +drab blue bags contain 4 faded aqua bags, 2 pale gray bags. +dotted lime bags contain 3 light olive bags, 2 light tomato bags, 5 dull gold bags, 2 dotted gold bags. +muted violet bags contain 4 wavy coral bags, 4 pale crimson bags, 1 dim coral bag, 2 mirrored coral bags. +vibrant maroon bags contain 5 wavy aqua bags, 4 muted orange bags, 3 dull tomato bags. +light tomato bags contain 3 dim tomato bags, 1 dim purple bag, 2 plaid gray bags, 3 striped red bags. +dotted violet bags contain 3 muted green bags, 2 faded silver bags. +mirrored coral bags contain 5 drab black bags, 2 vibrant crimson bags, 2 mirrored gold bags. +muted black bags contain 3 mirrored plum bags, 2 bright olive bags. +faded olive bags contain 1 vibrant orange bag, 3 faded gray bags, 3 shiny green bags, 2 muted lavender bags. +clear gold bags contain 4 dim purple bags. +striped lime bags contain 2 pale gray bags, 5 light brown bags, 5 vibrant violet bags, 4 bright tomato bags. +drab coral bags contain 2 pale tan bags, 5 striped teal bags, 1 drab indigo bag. +dotted purple bags contain 2 faded chartreuse bags, 3 clear beige bags, 4 striped turquoise bags. +light gold bags contain 2 dark gold bags, 5 striped salmon bags. +faded teal bags contain 5 plaid black bags, 5 dotted crimson bags, 3 mirrored magenta bags. +dull silver bags contain 5 bright yellow bags, 4 drab aqua bags, 4 shiny indigo bags. +shiny magenta bags contain 5 pale purple bags. +dull salmon bags contain 2 shiny black bags, 1 bright tomato bag. +posh fuchsia bags contain 1 pale teal bag, 1 clear orange bag. +mirrored lavender bags contain 2 posh brown bags, 3 light tomato bags, 5 plaid aqua bags, 2 vibrant olive bags. +posh tomato bags contain 2 drab blue bags. +faded maroon bags contain 2 dull beige bags, 2 dark gray bags. +dotted tomato bags contain 4 mirrored olive bags, 4 dull gold bags, 2 dotted silver bags, 4 wavy maroon bags. +muted bronze bags contain 2 dim olive bags, 2 posh lime bags, 3 drab coral bags, 5 wavy silver bags. +wavy aqua bags contain 2 striped lime bags, 4 wavy lime bags, 2 dim tan bags, 4 faded cyan bags. +dull violet bags contain 4 bright gold bags, 2 dim coral bags. +posh gray bags contain 2 dull bronze bags, 3 faded blue bags, 4 posh silver bags. +striped gold bags contain 4 wavy lavender bags, 2 muted gray bags, 3 wavy yellow bags. +vibrant black bags contain 3 shiny silver bags, 1 faded yellow bag. +dull teal bags contain 4 light blue bags, 3 posh lavender bags. +muted green bags contain 4 vibrant violet bags. +plaid green bags contain 3 dim purple bags, 4 dim teal bags, 1 muted cyan bag. +plaid blue bags contain 2 light purple bags, 4 dim gold bags, 5 pale black bags, 5 dim lavender bags. +vibrant turquoise bags contain 5 drab orange bags, 4 dark gold bags. +muted plum bags contain 3 dull aqua bags, 1 wavy lime bag, 3 dark green bags. +bright fuchsia bags contain 5 wavy gray bags, 1 dim teal bag, 5 muted cyan bags. +clear violet bags contain 1 bright salmon bag. +dotted chartreuse bags contain 4 pale plum bags, 2 bright purple bags. +vibrant gray bags contain 4 dark turquoise bags, 5 faded gold bags, 3 light olive bags. +dark tan bags contain 2 light olive bags, 1 vibrant fuchsia bag, 4 vibrant blue bags. +mirrored violet bags contain 2 muted gray bags. +mirrored maroon bags contain 5 mirrored coral bags, 2 faded lime bags, 3 dark gray bags. +dotted black bags contain 1 clear violet bag, 2 wavy chartreuse bags, 3 faded silver bags, 2 plaid gray bags. +shiny maroon bags contain 3 wavy turquoise bags, 2 dim purple bags, 1 shiny silver bag, 2 dim cyan bags. +dull cyan bags contain 3 mirrored olive bags. +drab brown bags contain 4 striped lime bags, 2 bright aqua bags. +dim crimson bags contain 2 drab black bags, 2 vibrant teal bags. +dim brown bags contain 2 mirrored beige bags. +vibrant silver bags contain 1 dark gold bag, 4 vibrant indigo bags, 5 dim red bags, 3 light blue bags. +dull olive bags contain 2 clear red bags, 1 vibrant plum bag. +faded purple bags contain 5 faded olive bags. +pale yellow bags contain 3 vibrant teal bags, 3 shiny violet bags, 2 dull yellow bags. +posh black bags contain 4 clear beige bags, 4 striped salmon bags, 4 wavy lavender bags. +dotted cyan bags contain 5 shiny crimson bags, 5 dark lavender bags, 5 faded green bags, 3 dull lime bags. +mirrored silver bags contain 4 light lime bags, 1 posh tomato bag. +pale gold bags contain 2 striped teal bags, 3 wavy chartreuse bags, 2 plaid tomato bags. +dotted white bags contain 2 muted purple bags, 2 posh white bags, 3 faded plum bags. +mirrored tan bags contain 2 clear bronze bags, 2 clear orange bags, 5 striped gray bags. +plaid beige bags contain 4 drab turquoise bags. +faded red bags contain 3 vibrant yellow bags, 3 pale brown bags, 4 dim beige bags, 5 wavy chartreuse bags. +pale coral bags contain 3 clear coral bags. +dull orange bags contain 5 wavy chartreuse bags, 5 plaid cyan bags. +dull brown bags contain 5 plaid olive bags, 3 faded chartreuse bags, 3 mirrored crimson bags. +mirrored aqua bags contain 5 faded green bags. +vibrant tan bags contain 1 dark turquoise bag, 4 plaid lime bags. +faded fuchsia bags contain 4 clear gray bags, 4 faded silver bags. +dim purple bags contain 5 dull lavender bags, 4 faded black bags, 1 muted cyan bag. +posh purple bags contain 1 wavy turquoise bag, 1 drab cyan bag, 2 dull coral bags, 4 posh yellow bags. +drab turquoise bags contain 3 dull black bags, 5 dotted bronze bags. +shiny orange bags contain 5 plaid crimson bags, 4 dotted coral bags. +plaid orange bags contain 3 wavy gray bags, 5 plaid crimson bags, 2 striped plum bags, 5 pale beige bags. +vibrant bronze bags contain 1 posh turquoise bag, 3 plaid turquoise bags, 1 dotted crimson bag. +clear tomato bags contain 5 mirrored fuchsia bags. +wavy coral bags contain 2 mirrored orange bags. +posh coral bags contain 5 dotted salmon bags. +bright tan bags contain 4 drab gray bags, 4 vibrant plum bags. +dotted gray bags contain 1 dull lime bag, 4 dotted tomato bags, 4 faded gold bags. +pale red bags contain 2 mirrored olive bags, 1 faded blue bag, 1 dark crimson bag, 3 striped teal bags. +striped aqua bags contain 2 drab black bags, 5 dull bronze bags, 3 pale purple bags, 4 faded silver bags. +plaid purple bags contain 3 bright salmon bags, 2 dim beige bags, 3 faded red bags. +drab purple bags contain 4 dotted black bags, 2 shiny black bags, 1 light plum bag, 1 dotted gold bag. +muted purple bags contain 3 pale crimson bags. +posh silver bags contain 4 bright gold bags, 1 dim coral bag, 2 drab chartreuse bags, 1 dim chartreuse bag. +dark black bags contain 1 bright green bag, 5 plaid cyan bags, 4 dotted purple bags. +striped coral bags contain 3 shiny lavender bags. +shiny yellow bags contain 4 dim tomato bags, 1 drab white bag. +bright magenta bags contain 2 muted silver bags, 3 dull bronze bags, 1 faded blue bag. +light black bags contain 4 posh silver bags. +pale purple bags contain 5 dull lavender bags, 1 mirrored orange bag. +striped salmon bags contain 3 faded chartreuse bags, 2 posh white bags, 1 striped lime bag, 3 drab cyan bags. +dull fuchsia bags contain 2 plaid tomato bags. +plaid maroon bags contain 5 dotted red bags, 2 vibrant magenta bags, 4 dotted purple bags. +posh yellow bags contain 2 wavy beige bags, 5 light yellow bags, 3 striped gray bags. +dull turquoise bags contain 1 drab lavender bag, 4 faded crimson bags, 2 drab purple bags. +wavy silver bags contain 5 dotted cyan bags, 2 faded blue bags, 2 faded aqua bags. +clear orange bags contain 5 posh silver bags, 1 vibrant teal bag, 1 pale tomato bag, 3 dull tomato bags. +drab chartreuse bags contain no other bags. +shiny black bags contain 5 dim teal bags, 1 faded silver bag, 2 posh beige bags, 1 bright olive bag. +pale teal bags contain 2 dull beige bags. +drab plum bags contain 5 pale beige bags, 2 wavy maroon bags. +vibrant lavender bags contain 4 wavy yellow bags. +dim turquoise bags contain 5 shiny crimson bags. +plaid tan bags contain 5 clear purple bags, 2 light indigo bags, 4 plaid cyan bags. +pale silver bags contain 1 pale green bag, 4 striped beige bags. +mirrored bronze bags contain 1 drab orange bag, 2 posh lavender bags, 2 muted gray bags. +plaid tomato bags contain 4 striped red bags, 3 bright olive bags. +bright indigo bags contain 4 dull tan bags. +light violet bags contain 5 faded magenta bags, 5 drab tomato bags. +clear aqua bags contain 1 plaid gray bag. +drab salmon bags contain 5 faded silver bags, 1 bright tomato bag, 1 light lime bag. +light teal bags contain 5 wavy brown bags, 2 muted indigo bags, 2 pale gold bags. +drab red bags contain 2 shiny chartreuse bags, 3 dim yellow bags, 3 vibrant teal bags, 3 mirrored silver bags. +bright white bags contain 5 dotted tan bags, 4 drab beige bags, 3 dim indigo bags, 2 dotted white bags. +dotted fuchsia bags contain 3 faded tomato bags, 1 dotted lavender bag. +dotted aqua bags contain 4 clear plum bags, 4 faded maroon bags, 1 posh bronze bag. +light purple bags contain 5 dotted cyan bags, 4 posh olive bags, 5 plaid fuchsia bags, 3 striped white bags. +shiny indigo bags contain 2 mirrored gold bags, 4 pale magenta bags, 5 shiny white bags, 4 posh tan bags. +pale turquoise bags contain 1 pale tan bag, 4 striped red bags, 1 bright olive bag. +plaid aqua bags contain 3 plaid black bags, 3 dim crimson bags. +posh cyan bags contain 3 dim tomato bags, 4 pale crimson bags, 4 shiny gold bags. +mirrored white bags contain 2 faded cyan bags. +shiny chartreuse bags contain 3 muted maroon bags, 2 dotted teal bags. +dim green bags contain 4 light salmon bags, 1 muted crimson bag, 2 striped beige bags. +striped blue bags contain 4 dark bronze bags, 5 faded plum bags, 3 bright white bags. +drab lime bags contain 4 dull tomato bags. +clear purple bags contain 2 drab chartreuse bags, 4 clear green bags. +dotted blue bags contain 5 dim purple bags, 3 dull brown bags. +vibrant cyan bags contain 2 drab indigo bags, 4 faded chartreuse bags. +light beige bags contain 3 dark orange bags, 3 vibrant cyan bags. +light lavender bags contain 1 muted cyan bag, 5 faded tan bags. +dim fuchsia bags contain 2 pale salmon bags. +mirrored purple bags contain 2 clear red bags. +faded brown bags contain 1 clear tan bag, 4 faded crimson bags. +muted magenta bags contain 5 pale tomato bags, 3 muted maroon bags. +pale beige bags contain 5 dark gold bags, 1 dull beige bag. +vibrant brown bags contain 2 striped gold bags, 1 bright gold bag. +clear coral bags contain 4 pale crimson bags, 1 dark teal bag, 4 mirrored coral bags, 4 striped gold bags. +striped tan bags contain 4 dim violet bags. +pale chartreuse bags contain 2 vibrant blue bags, 5 dark turquoise bags, 2 faded olive bags. +posh plum bags contain 1 plaid aqua bag. +striped purple bags contain 3 shiny tomato bags, 5 posh purple bags. +dark gold bags contain 5 vibrant crimson bags, 2 light tomato bags, 3 light salmon bags, 3 muted brown bags. +shiny cyan bags contain 1 vibrant crimson bag, 5 drab indigo bags. +bright yellow bags contain 3 plaid indigo bags. +bright blue bags contain 5 mirrored magenta bags. +dotted salmon bags contain 5 vibrant crimson bags, 2 posh chartreuse bags, 5 wavy gray bags, 4 pale turquoise bags. +dim olive bags contain 1 clear cyan bag. +striped turquoise bags contain 5 faded silver bags, 3 pale tan bags, 5 faded orange bags, 2 bright olive bags. +vibrant beige bags contain 3 faded yellow bags, 3 bright green bags, 3 faded bronze bags, 4 drab fuchsia bags. +clear maroon bags contain 1 vibrant indigo bag. +vibrant coral bags contain 2 mirrored tomato bags, 5 dull bronze bags, 1 vibrant teal bag, 3 pale salmon bags. +dotted orange bags contain 2 plaid green bags, 4 striped violet bags, 4 bright chartreuse bags, 4 dotted plum bags. +dull tomato bags contain 2 vibrant crimson bags. +wavy teal bags contain 1 bright orange bag. +dark teal bags contain 4 dim tan bags, 4 striped gray bags, 4 dim red bags, 4 plaid bronze bags. +vibrant indigo bags contain 3 drab coral bags, 2 plaid green bags, 4 shiny gold bags, 3 wavy coral bags. +striped red bags contain 4 faded silver bags, 4 light salmon bags, 3 drab black bags. +drab aqua bags contain 5 faded black bags. +wavy plum bags contain 4 posh blue bags, 5 striped olive bags, 3 shiny violet bags, 4 bright silver bags. +posh lavender bags contain 3 wavy silver bags, 1 drab lavender bag. +dotted red bags contain 5 drab bronze bags, 5 plaid gray bags. +dark orange bags contain 4 mirrored blue bags, 1 drab black bag. +bright lavender bags contain 4 shiny magenta bags, 2 bright tomato bags, 3 dim salmon bags, 4 dim purple bags. +mirrored chartreuse bags contain 2 wavy black bags, 4 dull cyan bags, 5 striped coral bags. +mirrored tomato bags contain 5 clear beige bags. +wavy fuchsia bags contain 2 muted silver bags, 2 shiny gold bags. +muted lime bags contain 2 striped turquoise bags, 3 dim tan bags. +shiny white bags contain 4 mirrored olive bags. +posh maroon bags contain 3 vibrant violet bags, 5 striped turquoise bags, 2 dull lavender bags, 4 faded orange bags. +faded aqua bags contain 2 faded orange bags, 2 pale magenta bags, 1 posh white bag. +mirrored blue bags contain 5 pale purple bags, 2 light red bags, 2 striped teal bags, 4 shiny crimson bags. +dotted plum bags contain 1 light chartreuse bag, 5 drab tan bags, 3 pale red bags. +muted tan bags contain 3 drab cyan bags, 2 posh olive bags, 1 dim tomato bag. +shiny tomato bags contain 3 mirrored cyan bags, 5 dim yellow bags. +pale lavender bags contain 2 dull beige bags. +pale orange bags contain 1 posh gold bag. +wavy green bags contain 4 posh bronze bags. +faded lavender bags contain 3 clear gold bags, 4 mirrored cyan bags, 4 faded silver bags, 5 posh chartreuse bags. +posh teal bags contain 1 shiny purple bag, 4 dotted violet bags, 1 dotted tomato bag, 5 dull indigo bags. +clear crimson bags contain 2 shiny lavender bags. +dim black bags contain 2 vibrant coral bags, 2 drab green bags. +dull crimson bags contain 3 vibrant orange bags, 2 drab salmon bags. +muted gold bags contain 3 posh chartreuse bags, 4 striped gold bags, 4 drab brown bags, 2 dim black bags. +dull chartreuse bags contain 3 clear fuchsia bags. +light orange bags contain 5 clear orange bags, 5 faded bronze bags, 3 clear crimson bags. +dark tomato bags contain 5 dotted chartreuse bags, 3 dull gray bags, 5 muted crimson bags. +dark brown bags contain 3 posh red bags. +faded green bags contain 1 dark white bag. +dark olive bags contain 4 vibrant teal bags, 3 pale magenta bags, 4 pale gray bags. +striped bronze bags contain 3 striped tan bags, 5 dark gray bags, 4 vibrant white bags. +striped black bags contain 1 striped turquoise bag, 1 vibrant olive bag, 1 striped salmon bag. +clear plum bags contain 4 wavy chartreuse bags, 1 pale bronze bag, 2 striped plum bags. +faded tan bags contain 2 muted cyan bags, 4 dim salmon bags, 3 vibrant crimson bags, 4 striped plum bags. +faded silver bags contain no other bags. +light silver bags contain 4 muted gray bags, 3 mirrored crimson bags, 3 dull tan bags, 2 drab indigo bags. +dim aqua bags contain 2 posh tomato bags, 2 muted coral bags, 5 wavy gray bags, 3 dull tan bags. +vibrant crimson bags contain 1 shiny lavender bag, 3 bright tomato bags. +dim maroon bags contain 4 light olive bags. +bright maroon bags contain 2 faded tan bags, 5 pale tomato bags, 5 dotted purple bags. +dim gray bags contain 1 muted gold bag, 4 shiny magenta bags, 2 wavy salmon bags, 2 posh violet bags. +dim coral bags contain 3 striped coral bags, 5 clear gold bags, 3 wavy chartreuse bags. +posh indigo bags contain 3 dull salmon bags. +striped green bags contain 3 vibrant crimson bags, 4 plaid plum bags, 4 muted brown bags. +dull purple bags contain 3 drab gold bags, 1 plaid gray bag, 4 striped silver bags. +light yellow bags contain 3 pale salmon bags, 5 dark cyan bags, 3 dull tomato bags, 3 mirrored silver bags. +shiny red bags contain 3 faded gold bags, 1 light salmon bag, 5 mirrored turquoise bags. +vibrant magenta bags contain 1 drab tomato bag, 5 plaid cyan bags. +plaid lavender bags contain 1 dull lavender bag, 5 vibrant black bags, 2 muted olive bags, 4 shiny lavender bags. +light cyan bags contain 1 bright silver bag. +dark plum bags contain 2 drab salmon bags, 3 dull violet bags, 3 posh lime bags. +dull green bags contain 4 bright gold bags, 2 posh gold bags, 2 striped plum bags. +wavy salmon bags contain 3 faded gray bags, 5 dotted cyan bags, 3 plaid maroon bags. +pale lime bags contain 1 shiny purple bag. +shiny plum bags contain 3 mirrored magenta bags, 4 clear violet bags, 5 dull tomato bags, 5 dotted violet bags. +dim red bags contain 2 posh white bags, 4 drab cyan bags, 1 dark yellow bag, 1 pale purple bag. +light red bags contain 3 dotted indigo bags, 4 bright tomato bags, 1 mirrored olive bag, 4 pale turquoise bags. +dim yellow bags contain 5 faded aqua bags, 2 shiny purple bags, 1 plaid bronze bag. +drab magenta bags contain 4 dotted coral bags, 3 plaid lime bags. +clear gray bags contain 5 plaid green bags, 3 pale purple bags. +plaid turquoise bags contain 4 mirrored crimson bags, 2 muted lavender bags, 3 light blue bags, 2 dull blue bags. +mirrored turquoise bags contain 5 muted magenta bags, 4 light red bags. +pale plum bags contain 3 clear beige bags, 5 striped plum bags, 4 striped lime bags, 2 striped teal bags. +vibrant chartreuse bags contain 2 drab chartreuse bags, 2 striped red bags, 4 dim teal bags. +striped gray bags contain 3 striped red bags, 1 drab green bag. +muted maroon bags contain 4 clear yellow bags, 1 dim tan bag, 3 vibrant cyan bags, 1 bright tomato bag. +posh aqua bags contain 3 faded silver bags, 5 pale tan bags, 2 striped red bags, 3 light salmon bags. +dotted bronze bags contain 4 striped gold bags, 5 dark lime bags, 2 pale magenta bags, 1 pale salmon bag. +dark aqua bags contain 4 dull salmon bags, 2 striped salmon bags, 5 clear turquoise bags. +plaid brown bags contain 4 posh silver bags. +bright cyan bags contain 2 posh yellow bags, 5 posh lavender bags, 4 shiny cyan bags. +dark indigo bags contain 5 pale turquoise bags, 4 light crimson bags, 2 dim orange bags. +muted yellow bags contain 3 light coral bags, 1 vibrant turquoise bag, 5 clear magenta bags, 2 pale olive bags. +clear fuchsia bags contain 2 posh silver bags, 1 striped yellow bag, 3 striped lime bags. +bright salmon bags contain 2 vibrant cyan bags. +dotted maroon bags contain 2 posh violet bags. +shiny violet bags contain 3 dim teal bags. +plaid teal bags contain 2 drab orange bags, 1 dim violet bag, 1 bright fuchsia bag. +faded salmon bags contain 5 drab orange bags, 3 clear indigo bags, 1 plaid cyan bag. +shiny beige bags contain 5 bright brown bags, 4 pale brown bags. +plaid yellow bags contain 3 vibrant crimson bags. +light indigo bags contain 4 vibrant cyan bags, 2 dotted purple bags. +dull aqua bags contain 5 pale tan bags. +posh green bags contain 2 light silver bags, 3 posh lime bags, 2 vibrant olive bags. +dark beige bags contain 3 dotted coral bags, 5 wavy chartreuse bags. +mirrored salmon bags contain 4 posh blue bags, 5 posh yellow bags, 4 posh fuchsia bags, 3 drab tomato bags. +pale crimson bags contain 3 dim tomato bags, 3 vibrant teal bags, 5 dotted silver bags. +wavy gray bags contain 1 dim olive bag, 4 plaid green bags. +bright olive bags contain 5 faded orange bags, 1 plaid black bag, 2 plaid gray bags, 3 faded silver bags. +light lime bags contain 5 dull lavender bags, 2 posh aqua bags, 4 dull aqua bags. +dim salmon bags contain 3 muted lavender bags, 1 light lime bag. +dark white bags contain 1 posh aqua bag, 3 wavy black bags. +posh magenta bags contain 5 striped silver bags, 3 wavy bronze bags, 3 faded beige bags. +mirrored cyan bags contain 5 light brown bags, 1 muted cyan bag, 4 posh silver bags. +dark magenta bags contain 2 muted indigo bags, 2 muted coral bags. +clear salmon bags contain 3 pale chartreuse bags. +dim tan bags contain 2 pale crimson bags. +bright gray bags contain 3 mirrored fuchsia bags. +bright green bags contain 5 plaid crimson bags, 3 striped turquoise bags. +faded black bags contain 1 striped red bag, 1 dim teal bag, 5 faded silver bags, 3 striped plum bags. +wavy orange bags contain 1 dark white bag. +wavy cyan bags contain 5 light olive bags. +muted blue bags contain 5 wavy maroon bags, 1 light tomato bag. +light green bags contain 1 shiny teal bag, 5 bright lime bags, 4 drab white bags, 5 posh aqua bags. +drab white bags contain 4 posh silver bags, 4 mirrored crimson bags. +bright teal bags contain 5 dotted purple bags, 1 faded yellow bag, 4 shiny coral bags. +light plum bags contain 3 pale cyan bags, 5 faded tan bags. +faded coral bags contain 4 dull gray bags. +dotted coral bags contain 2 posh bronze bags, 5 posh aqua bags, 2 mirrored violet bags. +pale cyan bags contain 2 mirrored orange bags, 2 dim tomato bags. +drab beige bags contain 4 bright aqua bags, 2 mirrored tomato bags, 2 plaid turquoise bags, 1 wavy chartreuse bag. +dark maroon bags contain 1 dull gray bag, 2 mirrored olive bags, 1 light olive bag, 1 shiny fuchsia bag. +wavy white bags contain 4 dull lavender bags. +dull gray bags contain 5 plaid black bags, 3 light lime bags, 2 wavy chartreuse bags, 5 dim tomato bags. +clear red bags contain 5 light crimson bags, 3 faded chartreuse bags, 4 clear teal bags, 4 mirrored blue bags. +bright bronze bags contain 1 clear magenta bag, 2 clear gray bags, 2 dull coral bags, 5 vibrant gray bags. diff --git a/2020/07/sol1.pl b/2020/07/sol1.pl @@ -0,0 +1,43 @@ +#!/usr/bin/env perl +# idea: +# this is a weighted DAG. The natural way the rules flow, I _want_ to make it +# so that the edges go from container->containee BUT, for the problem we want +# to solve, it makes much more sense to build the graph containee->[container] +# so that we can then do a quick walk of all possible containers +use strict; +use warnings; + + +# build the graph +my %h; +my %all; +open(my $fh, '<', 'input') or die "$!"; +for my $rule (<$fh>) { + my ($container, $containees) = $rule =~ /^(.*) bags contain (.*)\.$/; + $all{$container} = 1; + if ($containees eq 'no other bags') { + # skip! + next; + } + my @subs = map { s/\d+ (.*) bag(?:s)?/$1/r } split(', ', $containees); + $all{$_} = 1 for @subs; + $all{$container} = 1; + for my $s (@subs) { + push(@{$h{$s}}, $container); + } +} + +# walk the walk +my @q = @{$h{'shiny gold'}}; # direct containers +my %seen; +while (my $i = shift @q) { + next if $seen{$i}; + $seen{$i} = 1; + if (exists $h{$i}) { + # I suppose there might be some outer-only bags + push (@q, @{$h{$i}}); + } +} +printf "%d out of %d\n", scalar keys %seen, scalar keys %all; + +exit(0); diff --git a/2020/07/sol2.pl b/2020/07/sol2.pl @@ -0,0 +1,41 @@ +#!/usr/bin/env perl +# idea: +# this is a weighted DAG. This time, we go container->containee +use strict; +use warnings; + + +# build the graph +my %h; +open(my $fh, '<', 'input') or die "$!"; +for my $rule (<$fh>) { + my ($container, $containees) = $rule =~ /^(.*) bags contain (.*)\.$/; + if ($containees eq 'no other bags') { + next; + } + my @subs = split(', ', $containees); + for my $s (@subs) { + my ($count, $name) = $s =~ m/(\d+) (.*) bag(?:s)?/; + push(@{$h{$container}}, [$count, $name]); + } +} + +# walk the walk +printf "%d\n", num_bags('shiny gold'); + +sub num_bags { + my ($b) = @_; + if (!exists $h{$b}) { + # no other bags needed + return 0; + } + my $n = 0; + for my $s (@{$h{$b}}) { + # Don't forget to add yourself! + $n += ($s->[0] * num_bags($s->[1])) + $s->[0]; + } + return $n; +} + +exit(0); + diff --git a/2020/08/input b/2020/08/input @@ -0,0 +1,625 @@ +jmp +301 +acc +27 +nop +299 +jmp +168 +acc +0 +acc +48 +acc -5 +jmp +420 +jmp +155 +acc -16 +acc -15 +nop +582 +acc -5 +jmp +490 +acc +10 +nop +300 +acc -2 +acc -1 +jmp +252 +jmp +2 +jmp +234 +acc +36 +acc +50 +jmp +564 +jmp +102 +jmp +473 +acc +37 +acc +1 +acc +20 +jmp +355 +acc +28 +acc -14 +acc +22 +jmp +329 +acc +44 +jmp +1 +jmp +23 +nop +312 +jmp +251 +acc +12 +acc +39 +acc +33 +jmp -21 +acc +28 +acc +14 +acc +42 +acc +33 +jmp +502 +jmp +123 +acc +24 +jmp +11 +acc -8 +nop +218 +nop +516 +jmp +244 +jmp -36 +nop +192 +acc -11 +jmp +100 +jmp +299 +jmp +400 +acc +29 +acc +13 +jmp +1 +acc +45 +jmp +458 +acc +6 +acc +15 +jmp +542 +acc +38 +acc -15 +acc -15 +acc -11 +jmp +474 +acc +0 +acc +1 +jmp +55 +acc +14 +acc +13 +acc +37 +acc -18 +jmp +95 +jmp -73 +acc +25 +jmp -54 +jmp +413 +acc -17 +acc +25 +acc +22 +jmp +405 +jmp +151 +jmp +1 +acc -14 +acc +33 +acc +30 +jmp -86 +acc +32 +acc -3 +acc +26 +acc +7 +jmp +493 +acc +44 +jmp +1 +nop +357 +acc +47 +jmp +412 +jmp +321 +acc -5 +jmp +12 +acc +18 +acc -1 +acc +29 +jmp +430 +acc +35 +acc +34 +jmp +1 +acc -6 +jmp +184 +acc -12 +jmp -36 +acc +22 +acc -5 +acc +14 +acc +0 +jmp +198 +jmp +293 +nop +76 +acc +8 +acc +13 +jmp +464 +jmp +309 +acc -19 +acc +27 +acc -10 +jmp +29 +acc -17 +jmp -77 +acc +49 +nop +224 +acc +0 +jmp +77 +acc +35 +acc +3 +jmp +317 +nop +27 +acc +6 +jmp +164 +acc +10 +acc +41 +acc -2 +acc -8 +jmp +347 +acc +14 +nop +148 +jmp +302 +acc +21 +acc +8 +jmp +282 +acc +3 +acc +12 +jmp +138 +acc -10 +jmp +311 +acc -6 +acc -10 +acc +13 +jmp +116 +acc +31 +acc +39 +acc +28 +jmp +244 +nop +59 +acc +16 +jmp +1 +jmp +436 +jmp -31 +acc -12 +acc +43 +jmp -135 +acc -1 +acc +35 +acc +50 +acc +0 +jmp +398 +jmp -83 +acc +40 +acc +26 +acc -8 +jmp +393 +acc +28 +acc -7 +acc +43 +jmp +231 +jmp -22 +acc -1 +acc -18 +acc +19 +jmp -111 +acc +38 +acc +21 +acc +7 +jmp +134 +acc +8 +acc +18 +acc -9 +acc -7 +jmp +24 +acc +5 +acc +0 +jmp -46 +acc +2 +acc -12 +acc -17 +acc +36 +jmp -88 +nop -71 +jmp +181 +jmp -15 +jmp +52 +acc +15 +acc +0 +jmp -32 +acc -6 +nop +166 +acc +10 +acc +38 +jmp +123 +acc +9 +jmp -151 +jmp +231 +jmp +1 +acc +34 +jmp +186 +jmp +96 +acc +48 +acc +9 +jmp +198 +acc +7 +acc +35 +acc +22 +jmp +82 +nop +1 +nop -156 +nop -49 +jmp +91 +acc +8 +acc -17 +jmp -53 +acc +29 +nop +283 +acc -2 +nop +50 +jmp +290 +jmp +296 +jmp +219 +jmp +268 +jmp -119 +nop +353 +jmp -157 +acc +21 +acc +30 +jmp +345 +acc -9 +jmp -119 +acc +0 +jmp -196 +acc +33 +acc +0 +acc +1 +jmp -248 +acc +15 +jmp -44 +acc +9 +acc +46 +acc +50 +jmp +257 +acc -6 +acc -16 +jmp +320 +acc +35 +nop -4 +jmp -5 +acc +30 +acc +27 +jmp +1 +jmp +296 +acc +8 +acc +40 +jmp +210 +acc -14 +acc +34 +acc +42 +jmp +173 +acc +16 +acc +47 +acc +11 +acc +32 +jmp -206 +jmp -39 +acc +45 +jmp +247 +acc -17 +nop +261 +nop -254 +acc +48 +jmp +62 +acc +50 +acc +26 +acc +1 +jmp +130 +acc -14 +nop +47 +acc -9 +jmp -276 +jmp -104 +jmp +135 +acc +40 +jmp -296 +jmp +11 +acc +2 +acc -17 +jmp -238 +acc +34 +acc +37 +jmp -166 +nop -205 +acc -4 +acc +22 +jmp +56 +acc +1 +nop -210 +nop -30 +acc -18 +jmp -250 +jmp -107 +acc +45 +acc +50 +acc +3 +acc +3 +jmp -63 +acc +35 +jmp +1 +acc -5 +nop +255 +jmp +254 +jmp +210 +acc +10 +acc +7 +jmp +207 +acc +17 +acc +25 +nop -22 +jmp +62 +acc +35 +acc +18 +acc +22 +acc +10 +jmp -186 +acc +24 +acc +32 +jmp -31 +jmp -131 +jmp -337 +acc +41 +acc -10 +acc +42 +jmp +207 +acc -16 +acc -14 +nop -225 +acc -15 +jmp +70 +nop -303 +acc -10 +acc +11 +acc +17 +jmp +234 +acc -8 +acc +33 +jmp -131 +acc -9 +acc -12 +acc +31 +jmp -25 +nop -277 +acc +22 +jmp -273 +acc +19 +jmp -244 +acc -8 +nop +220 +acc +48 +jmp -261 +acc +23 +acc +11 +acc -16 +jmp -47 +acc +50 +acc -9 +acc +23 +jmp -38 +jmp +146 +nop -168 +jmp -88 +acc +37 +acc +36 +acc +43 +acc -7 +jmp +147 +jmp +1 +acc +42 +jmp -352 +acc +39 +jmp +76 +acc +47 +jmp +88 +acc -2 +jmp -102 +acc +20 +jmp +144 +acc +47 +acc +25 +jmp -55 +nop -65 +jmp -375 +acc +8 +jmp +161 +acc +46 +acc +5 +acc +16 +jmp +53 +acc +27 +acc +1 +jmp -6 +jmp -207 +acc -6 +acc +27 +nop +126 +jmp -197 +jmp -110 +jmp +123 +acc +13 +acc +31 +nop +22 +acc +41 +jmp -127 +acc -7 +nop -386 +acc +0 +jmp -65 +jmp -306 +acc +44 +acc +19 +acc +42 +acc +29 +jmp +92 +acc +42 +nop -156 +jmp -56 +jmp -346 +nop +95 +acc -6 +acc -19 +jmp -292 +jmp -443 +acc -12 +acc -18 +jmp +102 +nop +35 +acc +44 +acc +27 +nop -122 +jmp +97 +jmp -382 +jmp -85 +acc -9 +nop -324 +jmp -422 +acc -9 +acc +25 +acc +38 +acc -3 +jmp -298 +acc -2 +acc +26 +acc +14 +jmp -252 +acc +4 +jmp +75 +acc +17 +nop -208 +jmp -235 +acc +19 +jmp -322 +acc +14 +acc -3 +jmp +124 +jmp -221 +jmp -9 +acc +0 +acc +45 +acc -3 +jmp -376 +acc +20 +acc -3 +acc +17 +acc +19 +jmp -400 +acc -16 +acc +25 +jmp -37 +jmp -317 +acc +31 +acc +19 +acc +24 +acc +9 +jmp -181 +acc +35 +jmp -488 +acc -13 +acc +26 +acc -2 +jmp -338 +acc -1 +acc +17 +acc +44 +nop -262 +jmp -86 +acc +17 +acc -1 +acc +23 +jmp +79 +acc -5 +acc +18 +jmp +1 +acc +12 +jmp -127 +acc +1 +acc +35 +acc -10 +acc +14 +jmp -352 +acc +39 +nop +67 +jmp -290 +acc -13 +jmp +41 +jmp -150 +jmp -121 +acc +7 +jmp -331 +acc +42 +nop -389 +acc +4 +jmp -7 +acc -17 +acc -8 +acc -4 +jmp -209 +acc +42 +acc +39 +acc +43 +jmp -306 +acc -18 +acc -16 +acc +13 +jmp -414 +acc +3 +jmp -442 +nop +41 +acc -12 +jmp -194 +jmp -503 +acc -18 +acc +35 +acc -4 +acc +18 +jmp -393 +nop -348 +acc -7 +jmp -521 +acc +48 +acc -19 +acc -3 +acc +44 +jmp +2 +jmp -126 +nop -474 +acc -9 +acc -2 +acc +35 +jmp -587 +jmp -328 +acc -14 +nop -468 +acc +39 +jmp -157 +jmp -538 +acc +0 +nop -264 +acc +19 +nop -266 +jmp -91 +acc +20 +acc +14 +jmp -329 +acc -11 +acc +8 +jmp -219 +jmp -320 +acc +10 +acc +49 +nop -603 +acc +49 +jmp -344 +nop -356 +nop -93 +acc +27 +acc +24 +jmp -482 +nop -126 +nop -345 +acc +6 +acc +3 +jmp +1 diff --git a/2020/08/sol1.pl b/2020/08/sol1.pl @@ -0,0 +1,33 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +open(my $fh, '<', 'input') or die "$!"; +my @lines; +{ + local $/; + my $content = <$fh>; + @lines = split("\n", $content); +} + +my $acc = 0; +my $ptr = 0; +my %seen; +my %C = ( + acc => sub { $acc += $_[0]; $ptr++ }, + nop => sub { $ptr++ }, + jmp => sub { $ptr += $_[0] }, +); + +while (1) { + if (exists $seen{$ptr}) { + print "$acc\n"; + exit(0); + } + my ($ins, $val) = split(' ', $lines[$ptr]); + # print "$ptr\t$acc\t$lines[$ptr]\n"; + $seen{$ptr} = 1; + $C{$ins}->($val); +} + +# heh infinite loop if we don't find an infinite loop diff --git a/2020/08/sol2.pl b/2020/08/sol2.pl @@ -0,0 +1,52 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +open(my $fh, '<', 'input') or die "$!"; +my @lines; +{ + local $/; + my $content = <$fh>; + @lines = split("\n", $content); +} + +my $goal = scalar @lines; +my $attempts; +for (my $i = 0; $i < @lines; $i++) { + my ($inst, $val) = split(' ', $lines[$i]); + if ($inst eq 'nop') { + my @game = @lines; + $game[$i] = "jmp $val"; + play_out(@game); + } elsif ($inst eq 'jmp') { + my @game = @lines; + $game[$i] = "nop $val"; + play_out(@game); + } +} + +sub play_out { + my (@game) = @_; + $attempts++; + + my $acc = 0; + my $ptr = 0; + my %seen; + my %C = ( + acc => sub { $acc += $_[0]; $ptr++ }, + nop => sub { $ptr++ }, + jmp => sub { $ptr += $_[0] }, + ); + + while ($ptr != $goal) { + if (exists $seen{$ptr}) { + return 0; + } + my ($ins, $val) = split(' ', $game[$ptr]); + # print "$ptr\t$acc\t$lines[$ptr]\n"; + $seen{$ptr} = 1; + $C{$ins}->($val); + } + print "After $attempts attempts: $acc\n"; + exit(0); +} diff --git a/2020/09/input b/2020/09/input @@ -0,0 +1,1000 @@ +26 +36 +37 +9 +8 +22 +41 +5 +17 +44 +40 +31 +10 +33 +30 +50 +24 +4 +12 +46 +39 +45 +42 +7 +27 +13 +58 +11 +14 +53 +9 +15 +23 +18 +16 +21 +17 +49 +19 +20 +32 +31 +22 +30 +24 +35 +28 +33 +25 +47 +57 +26 +27 +29 +83 +34 +37 +36 +59 +46 +39 +51 +44 +54 +56 +48 +49 +100 +62 +50 +52 +72 +53 +55 +60 +96 +61 +91 +65 +70 +85 +87 +88 +114 +83 +113 +92 +93 +97 +104 +142 +99 +102 +103 +153 +105 +108 +115 +116 +148 +144 +152 +177 +135 +167 +171 +201 +256 +182 +176 +252 +185 +190 +196 +203 +202 +348 +240 +208 +292 +213 +300 +323 +301 +315 +367 +302 +502 +393 +357 +353 +358 +390 +760 +361 +375 +492 +710 +398 +405 +448 +509 +421 +594 +505 +566 +810 +690 +603 +924 +655 +1317 +711 +823 +714 +1171 +719 +736 +759 +1080 +773 +803 +819 +953 +1528 +869 +1195 +1522 +1071 +1509 +1169 +2270 +1314 +1514 +1369 +1366 +1425 +1430 +2620 +2125 +1455 +1830 +1495 +1532 +4045 +1576 +1622 +2397 +1822 +2501 +3331 +2240 +2385 +2664 +2942 +2483 +2680 +2683 +6285 +2791 +2796 +2855 +2987 +4522 +2950 +3108 +3198 +3317 +4207 +3398 +3816 +5031 +4809 +4062 +4868 +4625 +5667 +5049 +5338 +5163 +5587 +5363 +7318 +6506 +5646 +5651 +7405 +5937 +7214 +9874 +6306 +10612 +7379 +11586 +9708 +9179 +15648 +8871 +8687 +16263 +9674 +10212 +10387 +15046 +15901 +19548 +11009 +31549 +40236 +11297 +18965 +13151 +17087 +19920 +16014 +22320 +17766 +16558 +17558 +30262 +17866 +18361 +19083 +19984 +19886 +33617 +39878 +21396 +26343 +22306 +24448 +24160 +27311 +27855 +63879 +29165 +35097 +32572 +47775 +33572 +34324 +40072 +57630 +35919 +53325 +36227 +37444 +38969 +44046 +41282 +45844 +43702 +45556 +58020 +46466 +48608 +51471 +55166 +94135 +80653 +70016 +66144 +70243 +80251 +83910 +76413 +72146 +73363 +77509 +88915 +73671 +103576 +99302 +84984 +188560 +89258 +181085 +92022 +95074 +97937 +136160 +158162 +128529 +136387 +143379 +138290 +168180 +142389 +157273 +145509 +149776 +147034 +169531 +158655 +162586 +162929 +191324 +281669 +174242 +258003 +187195 +187096 +189959 +193011 +226466 +264689 +264916 +266819 +274677 +389395 +301044 +287898 +320202 +292543 +308095 +342787 +309620 +480909 +321584 +325515 +438931 +374291 +361338 +361437 +532680 +377055 +419477 +382970 +607476 +491155 +684166 +531735 +541496 +635135 +602163 +1216846 +580441 +600638 +744992 +617715 +631204 +1022890 +647099 +686952 +686853 +722775 +735629 +738393 +738492 +1271073 +1903798 +1067136 +874125 +1032651 +1149450 +1073231 +1353344 +1121937 +1181079 +1613092 +1231842 +1198156 +1750088 +1248919 +1264814 +1278303 +1333952 +2436941 +2590651 +1805529 +1458404 +2222681 +2936449 +1941261 +1906776 +1947356 +2105882 +2980007 +2872025 +2195168 +2455889 +2320093 +2303016 +2379235 +2429998 +2447075 +2707323 +2513733 +2736707 +2543117 +3263933 +5086558 +3365180 +4136429 +3399665 +3405760 +4053238 +4863210 +3848037 +3854132 +4485117 +4758905 +4498184 +4515261 +4574403 +4816749 +4623109 +4682251 +4826310 +5807050 +4960808 +5056850 +5250440 +8422030 +5908297 +6629113 +6764845 +7219312 +9361394 +7897849 +7253797 +8422440 +8717342 +9932691 +8339249 +9138370 +12962358 +10489301 +13383248 +9631253 +9439858 +9305360 +16126239 +9787118 +10017658 +10211248 +16392167 +14611834 +13393958 +17152003 +15104094 +16615191 +14473109 +15151646 +15593046 +19950349 +17056591 +18936613 +25032904 +17477619 +18443730 +19071111 +27108872 +19226976 +18745218 +31230333 +19516608 +19804776 +36342516 +20228906 +23605206 +27867067 +31668425 +31837688 +36844097 +35101995 +43969517 +29624755 +36704595 +32649637 +35500321 +34534210 +36414232 +35921349 +38298087 +37188948 +68010941 +38974124 +62714735 +38261826 +39321384 +39745514 +64726750 +43834112 +48095973 +60309801 +130725676 +61293180 +67183847 +66329350 +62274392 +87841487 +110163462 +99283925 +72689269 +70034531 +70455559 +75388356 +73110297 +75450774 +76163072 +77235950 +149484846 +77583210 +78007340 +79066898 +132308923 +127001142 +114425323 +131748739 +133982449 +123567572 +134403477 +128603742 +132729951 +137662748 +140490090 +104054607 +145799566 +148038769 +232658349 +143565856 +148498653 +200111439 +179505381 +153399022 +154819160 +155590550 +202634470 +157074238 +213470375 +218479930 +248407772 +238458084 +310409710 +272066225 +227622179 +252093376 +289365422 +286161401 +258873767 +396446541 +247620463 +439560423 +291604625 +430256649 +406912536 +382441339 +308218182 +395532322 +402439623 +311893398 +466080263 +359708708 +370544613 +446102109 +648736579 +479715555 +499688404 +475242642 +530939992 +575526823 +545035168 +506494230 +577766026 +539225088 +986209785 +555838645 +599822807 +603498023 +620111580 +671602106 +667926890 +990656193 +861612585 +730253321 +682438011 +805810817 +834951350 +925817664 +921344751 +954958197 +1133604671 +1006182634 +1014467730 +1062332875 +1432311894 +1045719318 +1868143692 +1223609603 +1095063733 +1609680657 +1155661452 +1203320830 +1271424913 +1545929244 +1339528996 +1488248828 +1608255675 +1731628481 +1565204671 +1744770886 +1939415488 +1756296101 +1932000298 +2179323989 +2000677515 +3476399367 +2571387305 +2250725185 +2108052193 +2317144231 +2904733667 +2298384563 +4230384861 +3695711589 +4503387603 +6248158489 +2474745743 +3003053394 +2827777824 +2947784671 +3935620090 +5936297605 +3296833152 +4040052491 +3501066987 +3688296399 +5155458852 +4406436756 +5007101813 +4549109748 +4358777378 +5078503009 +4425196424 +4582797936 +4615528794 +6163042142 +6234004653 +5302523567 +5422530414 +5477799137 +5975812730 +5771578895 +5830831218 +6124610976 +11398343144 +17522954120 +6797900139 +6985129551 +8990819966 +9971640162 +8113492823 +8765214134 +8783973802 +8907887126 +8941575314 +10591341524 +9040725218 +9007994360 +10558610666 +9918052361 +10725053981 +14889825110 +14838825578 +10900329551 +16956769713 +11602410113 +13783029690 +11955442194 +20739415996 +16769540301 +15750343685 +14911392962 +15769103353 +16878706957 +16897466625 +17805939352 +17549187936 +23897819470 +18048719578 +17949569674 +18926046721 +18958777579 +19566605026 +20476663027 +25811722513 +38736645048 +22502739664 +22855771745 +27797796176 +23557852307 +25385439803 +26866835156 +27705785879 +55615352005 +42422376771 +30661736647 +30680496315 +32647810310 +33776173582 +34847036299 +35755509026 +43360910449 +45825612735 +45747365850 +63775182409 +38492651747 +38525382605 +42069344690 +64925116435 +45358511409 +46060591971 +46413624052 +80205547708 +48943292110 +64456669897 +52252274959 +54572621035 +66198437626 +61342232962 +63309546957 +63328306625 +65527532614 +81853562196 +68623209881 +104020184361 +129148839818 +80561996437 +77018034352 +84272748455 +80594727295 +83851163156 +110870293949 +131951516506 +91419103380 +91772135461 +95003884081 +131590655387 +143871543394 +103515913145 +119029290932 +106824895994 +145991724415 +124651779919 +126869765576 +126637853582 +172139123026 +134150742495 +145641244233 +149185206318 +157580030789 +157612761647 +164445890451 +168123911611 +164867475750 +172013830675 +291083744033 +256010102312 +183191238841 +186422987461 +186776019542 +295176930733 +210340809139 +222545204077 +225854186926 +231476675913 +233462749576 +251289633501 +291505329332 +275823059900 +291730773284 +325736673258 +303221275022 +344356050331 +523207449197 +329626592322 +322058652098 +329313366201 +332991387361 +336881306425 +355205069516 +774497082698 +1000351269624 +617242002590 +373199007003 +397116828681 +448399391003 +432886013216 +454021879990 +457330862839 +509285809476 +484752383077 +613789425382 +567328389232 +567553833184 +594952048306 +625279927120 +632534641223 +1096555734796 +1373550276627 +994038192553 +776080532088 +662304753562 +669872693786 +1454373149614 +770315835684 +1110704144565 +806085020219 +821598398006 +827220886993 +830002841897 +1199863030455 +942083245916 +911352742829 +966616672315 +1052080772309 +1454133039229 +1276094178944 +1134882222416 +1389152231190 +1804754916202 +1619318119673 +1763681643922 +2203553118524 +1440188529470 +1492307595459 +1332177447348 +1483903151568 +2300504974019 +2141946276371 +2946440634688 +2216373118183 +1627683418225 +2449320961570 +2251943802764 +1741355584726 +1853435988745 +1877969415144 +2046234965245 +2018697444624 +3193907147392 +2410976401360 +2772365976818 +2524034453606 +2721329678538 +2816080598916 +4834778043540 +3119991013684 +2824485042807 +2924091681038 +2959860865573 +3185613436093 +3625849427939 +3594791573471 +4235070562807 +4574124052913 +4495555926815 +3369039002951 +3731405403889 +3993299387490 +3760053029350 +4264412390105 +6906532328175 +4064932409869 +4429673845984 +4935010854966 +6149883881545 +5245364132144 +5340115052522 +5645421359576 +6010098478900 +5748576723845 +5784345908380 +5883952546611 +7681169362908 +6145474301666 +11402088254990 +6963830576422 +7354844602821 +7362338390441 +8329344799974 +7100444406840 +7129092032301 +7491458433239 +7753352416840 +7824985439219 +10890785491720 +13429746086753 +8494606255853 +10683587578811 +10180374987110 +10585479184666 +11393998083421 +11088691776367 +11429767267956 +18558859300257 +11532922632225 +13826643664574 +12984396953451 +13245918708506 +15595050662693 +14064274983262 +14491430422742 +21575263508480 +14853796823680 +35401907173054 +53960766473311 +33005030776436 +15244810850079 +15578337856059 +18674981242963 +19080085440519 +54580294284916 +19178193834664 +20765854171776 +21674170961033 +26333502626446 +22926920715646 +22518459044323 +27008105124015 +28318074087316 +27737349131248 +32501624907537 +26230315661957 +37009889467065 +28555705406004 +28918071806942 +70158632140975 +45413588066965 +30098607673759 +30823148706138 +62600232581296 +41475126512036 +33919792093042 +34253319099022 +61261424223037 +38258279275183 +57180239814668 +39944048006440 +44192630005356 +44601091676679 +45445379759969 +52617066718082 +48748774706280 +64351926772781 +53967664793205 +56655420938190 +73519163483621 +109765514839746 +57473777212946 +85667756517392 +59016679480701 +60921756379897 +97274958755884 +126952159354077 +64742940799180 +72511598374205 +92561114724522 +68173111192064 diff --git a/2020/09/sol1.pl b/2020/09/sol1.pl @@ -0,0 +1,40 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +my $preamble = 25; +my $n = 0; +my @mem; +while (my $l = <ARGV>) { + chomp $l; + if ($n < $preamble) { + # build memory + push (@mem, $l); + $n++; + } else { + # use memory + check($l, \@mem); + shift(@mem); + push(@mem, $l); + } +} +exit 1; + +sub check { + my ($l, $memA) = @_; + + # TODO: optimize? + my %seen; + for my $m (@$memA) { + $seen{$m} = 1; + my $c = $l - $m; + if ($seen{$c} && $c != $m) { + # success! + return; + } + } + + # nothing adds up! report & exit + print "$l\n"; + exit 0; +} diff --git a/2020/09/sol2.pl b/2020/09/sol2.pl @@ -0,0 +1,46 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use List::Util qw(min max); + +my $invalid = `./sol1.pl input`; # cheers +die "$!" if $?; + +my @nums; +{ + local $/; + open(my $fh, '<', 'input') or die "$!"; + @nums = split("\n", <$fh>); +} + +# IDEA: caterpillar slide +# - inch front forward until > invalid +# - inch back forward until < invalid +# if at any point = invalid, we win +my $sum = 0; +my @mem; + +print "GOAL: $invalid\n"; +for my $n (@nums) { + printf "DBG> n: %d, sum: %d, wind: %d\n", $n, $sum, scalar @mem; + if ($sum == $invalid) { + my $result = min(@mem) + max(@mem); + print "$result\n"; + exit 0; + } + + # move that butt forward until we can add $n without overflowing + while (($sum + $n) > $invalid) { + $sum -= shift(@mem); + if (!@mem) { + # impossible, too big + exit(1); + } + } + # scooch forward! + $sum += $n; + push(@mem, $n); +} + +exit 1; diff --git a/2020/10/input b/2020/10/input @@ -0,0 +1,100 @@ +46 +63 +21 +115 +125 +35 +89 +17 +116 +90 +51 +66 +111 +142 +148 +60 +2 +50 +82 +20 +47 +24 +80 +101 +103 +16 +34 +72 +145 +141 +124 +14 +123 +27 +62 +61 +95 +138 +29 +7 +149 +147 +104 +152 +22 +81 +11 +96 +97 +30 +41 +98 +59 +45 +88 +37 +10 +114 +110 +4 +56 +122 +139 +117 +108 +91 +36 +146 +131 +109 +31 +75 +70 +140 +38 +121 +3 +28 +118 +54 +107 +84 +15 +76 +71 +102 +130 +132 +87 +55 +129 +83 +23 +42 +69 +1 +77 +135 +128 +94 diff --git a/2020/10/sol1.pl b/2020/10/sol1.pl @@ -0,0 +1,27 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +my @adapters; +while (<ARGV>) { + chomp; + push(@adapters, $_); +} + +@adapters = sort { $a <=> $b } @adapters; + +my %spread; +my $last = 0; +for my $n (@adapters) { + my $delta = $n - $last; + if ($delta > 3) { + die "assert -- greater than 3 diff\n"; + } + $spread{$delta}++; + $last = $n; +} + +$spread{3}++; # for the device + +my $result = $spread{1} * $spread{3}; +print "$result\n"; diff --git a/2020/10/sol2.pl b/2020/10/sol2.pl @@ -0,0 +1,36 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +my @adapters; +while (<ARGV>) { + chomp; + push(@adapters, $_); +} + +# reverse! +@adapters = sort { $b <=> $a } (@adapters, 0); + +# Consider 1 2 3 4 5 6 +# set n(9) = 1 +# 6 -> n(9) # 1 +# 5 -> n(6) # 1 +# 4 -> n(5) + n(6) # 2 +# 3 -> n(4) + n(5) + n(6) # 4 +# 2 -> n(3) + n(4) + n(5) # 7 +# 1 -> n(2) + n(3) + n(4) # 13 + +my %H; +$H{$adapters[0] + 3} = 1; # device +while (@adapters) { + my $n = shift(@adapters); + # how many things can you get to? + my $total; + for (my $i = $n + 1; $i <= $n + 3; $i++) { + if (exists($H{$i})) { + $total += $H{$i}; + } + } + $H{$n} = $total; +} +print "$H{0}\n"; diff --git a/2020/11/input b/2020/11/input @@ -0,0 +1,99 @@ +LLLLLLLLLL.LLLLLLLLL.LLLLL.LLLLL.LLLLLLL.LLLL..LLLLLLLL.LLLLLLLL.LLLLLLLL..LLLLLLLL.LLLLLLLL.LLLLL +LLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLL..LLLLLL.LLLLL.LLLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLLL.LLLLLLLL.LLLLL +LLLLLLLLLLLLLLLLLLLL.LLLLL.LLLLL.LLLLLLL.LLLLLLLLLLLLLL.LLLL.LLLLLLLLLLLL.LLLLLLLLL.LLLL.LLL.LLLLL +LLLLLLLLLLLLLLLLLLLL.LLLLL.LLLLLLLLLLLLL.LLLLL.LLLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLLLL.LLL.LLLLLLLLLL +LLLLLLLLLL.LLLLLLLLL.LLLLL.LLLLL.LLLLLLL.LLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLLLL.LLLLL +LLLLLLLLLL.LLLLLLLLL.LLLLL.L.LLLLLLLLLLL.LLL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LLL.LLLLL.LLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLLL.LLLLLLLLLLLLLL +LLLLLLLLLL.LLLLLLLLL.L.LLL.LLLLLLLLLLLLL.LLLLL.LLLLLLLL.LLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL.LLLLL +LLLLLLLLLL.LLLLLLLLLLLLLLL.LLLLL.LLLLLLLLLLLLL.LLLLLLLL.LLLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLL +...........L.....L............LL..L...LL...L.LLL.L....L.L.L......L..L...LL......L.L.L.........LL.. +LLLLLLLLLL.LLLLLLLLL.LLLLLLLLLLL.LLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLLL.LLLLLLLL.LLLLL +LL.LLLLLLLLLLLLLLLLL.LLLL.LLLLLL.LLLLLLL.LLLLL.LLLLLLLL.LLLLLLLL.LLLLLLLL.LLLLLLLLL.LLLLLLLL.LLLLL +LLLLLLLLLL.LLLLLLLLL.LLLLL.LLLLLLLLLLLLL.LLLLL.LLLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLLLL.LLLLLLLL.LLLLL +LLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLL.LLLLLLLL.L.LLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLL +LLLLLLLLLL.LLLLLLLLL.LLLLL.LLLLL..LLLLLL.LLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL +............L......L......L...L....L.....LLL....L.......L.....L.L..L....L..L.L....LL.....L....L.L. +LLLLLLLLLL..LLLLLLLLLLLLLL.LLLL.LLLLLLLL.LLLLL.LLLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLLL.LLLLLLLL.LLLLL +LLLLLLLLLL.LLLLLLLLLLLLLLL.LL.LLLLLLLLLLLLLLLLLLLLLLLLL.LLL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LLLL.LLLLL.LLLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLLLL.LLLLLLLL.LL.LL +LLLLLLLLLL.LLLLLLLLL.LLLLL.LLLLL.L.LLLLL.LLLLL.LLLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLLL.LLLLLLLL.LLLLL +LLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLL.LLL.LLLLLLLLLL.LLLLLLL.LLLLL +LLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLL.LLLLLL..LLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLL..LLLLLLLL.LLLLLLLL.LLLLL +LLLLLL.L.L.LLLLLLLLLLLLLLLLLLLLL.LLLLLL.LLLLLL.LLLLLLLL.LLLLLLLL.LLLLLLLL.LLLLLLLLL.LLLLLLLL.LLLLL +L.LLLLLLLLLLLLLLLLLLLLLLLL.LLLLL.LLLLLLL.LL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLL.LLL..LLLL diff --git a/2020/11/sol1.pl b/2020/11/sol1.pl @@ -0,0 +1,71 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use Storable qw(dclone); + +# Read in the grid +# TRICK: to make neighbors easier, pad by '.' on all ends +my @G; +my $i = 0; +while (<ARGV>) { + chomp; + $G[$i] = ['.', split('', $_), '.']; + $i++; +} +push(@G, [('.') x scalar @{$G[0]}]); +unshift(@G, [('.') x scalar @{$G[0]}]); + +$i = 0; +while (evolve(\@G)) { + print "Evolving ... $i\n"; + $i++; +} + +my $total = 0; +for my $r (@G) { + $total += scalar grep { $_ eq '#' } @$r; +} +print "$total\n"; + +sub evolve { + my ($G) = @_; + # 1. deep clone + # 2. for loop over grid, change (mark did_change) + # 3. return did_change + my $orig = dclone($G); + my $did_change; + + my $R = scalar @$orig; + my $C = scalar @{$orig->[0]}; + for (my $i = 1; $i < $R - 1; $i++) { + for (my $j = 1; $j < $C - 1; $j++) { + my $seat = $orig->[$i]->[$j]; + next if $seat eq '.'; # floor don't change + + # neighbors... + my @neighs = map { $orig->[$_->[0]]->[$_->[1]] } ( + [$i - 1, $j - 1], + [$i - 1, $j], + [$i - 1, $j + 1], + [$i, $j - 1], + #[$i, $j], <-- don't include self + [$i, $j + 1], + [$i + 1, $j - 1], + [$i + 1, $j], + [$i + 1, $j + 1], + ); + my $num_occ = scalar grep { $_ eq '#' } @neighs; + + if ($seat eq 'L' && $num_occ == 0) { + $G->[$i]->[$j] = '#'; + $did_change = 1; + } elsif ($seat eq '#' && $num_occ >= 4) { + $G->[$i]->[$j] = 'L'; + $did_change = 1; + } + } + } + + return $did_change;; +} diff --git a/2020/11/sol2.pl b/2020/11/sol2.pl @@ -0,0 +1,99 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use Storable qw(dclone); + +# Read in the grid +my @G; +my $i = 0; +while (<ARGV>) { + chomp; + $G[$i] = [split('', $_)]; + $i++; +} + +$i = 0; +while (evolve(\@G)) { + print "Evolving ... $i\n"; + $i++; +} + +my $total = 0; +for my $r (@G) { + $total += scalar grep { $_ eq '#' } @$r; +} +print "$total\n"; + +# TRICK! because floor is static, the neighbors NEVER CHANGE +# so we can pay the cost of finding them once, and then never +# again :) +my %neigh_cache; +sub neigh { + my ($i, $j, $G) = @_; + my $key = "$i,$j"; + if (exists $neigh_cache{$key}) { + return @{$neigh_cache{$key}}; + } + + # Not in cache, compute + my $R = scalar @$G; + my $C = scalar @{$G->[0]}; + my $finder = sub { + my ($updater) = @_; + my ($si, $sj) = $updater->($i, $j); + while ($si >= 0 && $si < $R && $sj >= 0 && $sj < $C) { + if ($G->[$si]->[$sj] ne '.') { + return [$si, $sj]; + } + ($si, $sj) = $updater->($si, $sj); + } + return; + }; + + my @neighs = grep { defined($_) } ( + $finder->(sub { return $_[0] + 1, $_[1] }), + $finder->(sub { return $_[0] - 1, $_[1] }), + $finder->(sub { return $_[0] + 1, $_[1] + 1 }), + $finder->(sub { return $_[0] + 1, $_[1] - 1 }), + $finder->(sub { return $_[0] - 1, $_[1] + 1 }), + $finder->(sub { return $_[0] - 1, $_[1] - 1 }), + $finder->(sub { return $_[0], $_[1] + 1 }), + $finder->(sub { return $_[0], $_[1] - 1 }), + ); + $neigh_cache{$key} = \@neighs; + return @neighs; +} + +sub evolve { + my ($G) = @_; + # 1. deep clone + # 2. for loop over grid, change (mark did_change) + # 3. return did_change + my $orig = dclone($G); + my $did_change; + + my $R = scalar @$orig; + my $C = scalar @{$orig->[0]}; + for (my $i = 0; $i < $R; $i++) { + for (my $j = 0; $j < $C; $j++) { + my $seat = $orig->[$i]->[$j]; + next if $seat eq '.'; # floor don't change + + # neighbors... + my @coords = neigh($i, $j, $orig); + my @neighs = map { $orig->[$_->[0]]->[$_->[1]] } @coords; + my $num_occ = scalar grep { $_ eq '#' } @neighs; + + if ($seat eq 'L' && $num_occ == 0) { + $G->[$i]->[$j] = '#'; + $did_change = 1; + } elsif ($seat eq '#' && $num_occ >= 5) { + $G->[$i]->[$j] = 'L'; + $did_change = 1; + } + } + } + + return $did_change;; +} diff --git a/README.md b/README.md @@ -1,4 +1,8 @@ # Advent of Code +Historically, I do the first 10d of so in a language that I'd like to learn / +practice! + +* [2020](./2020): All Perl * [2021](./2021): Mostly Python, some C * [2022](./2022): Attempting CHICKEN Scheme