1
0
Fork 0
aoc-2020/aoc.org

262 KiB
Raw Permalink Blame History

#+TITLE:Advent of Code 2020 #+AUTHOR:Case Duckworth

Let's do this Advent of Code, literate-style.

Day 1

A

Problem

Before you leave, the Elves in accounting just need you to fix your expense report (your puzzle input); apparently, something isn't quite adding up.

Specifically, they need you to find the two entries that sum to 2020 and then multiply those two numbers together.

For example, suppose your expense report contained the following:

1721 979 366 299 675 1456

In this list, the two entries that sum to 2020 are 1721 and 299. Multiplying them together produces 1721 * 299 = 514579, so the correct answer is 514579.

Of course, your expense report is much larger. Find the two entries that sum to 2020; what do you get if you multiply them together?

Input

  1664
  1939
  1658
  1791
  1011
  1600
  1587
  1930
  1846
  1955
  1885
  1793
  1876
  1905
  1997
  1900
  1956
  1981
  1890
  1612
  638
  1897
  1888
  1742
  1613
  1982
  1932
  1923
  1065
  1827
  1919
  1236
  1195
  1917
  1990
  1764
  1902
  1911
  1999
  1906
  1817
  1841
  368
  747
  1881
  1941
  1894
  1898
  1887
  1958
  1862
  1940
  1819
  1873
  1959
  1977
  1301
  1945
  1961
  1673
  1879
  1889
  1872
  155
  1718
  1637
  1899
  1988
  1720
  1856
  1816
  1866
  1963
  1880
  1884
  1970
  1985
  1869
  1686
  1832
  1697
  1381
  1585
  1993
  2000
  587
  1891
  1928
  1721
  1904
  1708
  1934
  1912
  1927
  1575
  1802
  2009
  1871
  1867
  1882
  1974
  1994
  784
  1868
  1967
  1842
  1771
  2001
  1843
  1621
  1926
  1978
  2003
  1921
  1815
  1757
  2005
  1699
  1960
  2007
  1626
  1944
  2008
  1611
  2004
  1991
  1924
  1875
  1915
  1920
  1810
  1805
  1936
  1968
  882
  1976
  1874
  1987
  1826
  1910
  1483
  1964
  1855
  1979
  1996
  438
  1863
  1952
  1929
  1986
  1937
  1773
  1861
  1909
  1870
  1922
  1623
  1948
  1984
  1957
  1755
  1655
  1950
  1635
  2006
  1618
  1966
  1735
  1935
  1908
  1589
  1886
  1971
  1949
  1707
  1995
  1992
  1953
  1925
  1783
  1954
  1998
  1980
  1644
  1916
  1883
  1913
  1962
  1972
  1602
  1896
  1969
  1596
  1680
  1907
  1983
  1784
  1671
  1807
  1943

Solution

  ;; Find the numbers that sum to 2020, then multiply them together
  (let* ((strlist (split-string input))
         (list (seq-map #'string-to-number strlist))
         (result 0))
    (catch 'return
      (while list
        (setq n (pop list))
        (dolist (m list result)
          (when (= (+ n m) 2020)
            (message "%d, %d" n m)
            (throw 'return (* n m)))))))
969024

B

Problem

The Elves in accounting are thankful for your help; one of them even offers you a starfish coin they had left over from a past vacation. They offer you a second one if you can find three numbers in your expense report that meet the same criteria.

Using the above example again, the three entries that sum to 2020 are 979, 366, and 675. Multiplying them together produces the answer, 241861950.

In your expense report, what is the product of the three entries that sum to 2020?

Solution

  ;; Find three numbers this time
  (let* ((strlist (split-string input))
         (list (seq-map #'string-to-number strlist)))
    (catch 'return
      (while list
        (setq n (pop list))
        (setq rest list)
        (while list
          (setq m (pop list))
          (dolist (o list)
            (when (= (+ n m o) 2020)
              (message "%d, %d, %d" n m o)
              (throw 'return (* n m o)))))
        (setq list rest))))
230057040

Commentary

Today was a decent start, if a little bumpy. I had to go with elisp because Org-Mode can't find my bash interpreter at work. Which, I mean, this is a good opportunity to get pretty good at elisp.

The hardest part of A was figuring out how to get the input to a usable state, and finding out about catch and throw. Once I realized I could walk through the list by pop-ing n off the front each time and adding it to all the others.

Once I got to B, I thought I could do the same, but I was a little naive when I pop-ed m for the inner loop, I used up the list (of course) before I was able to test for successive values of n. Saving the cdr of the list and restoring it after the inner while loop.

At some point, I'm sure, I'll need to figure out the loop (or cl-loop ?) macro.

Day 2

A

Problem

To try to debug the problem, they have created a list (your puzzle input) of passwords (according to the corrupted database) and the corporate policy when that password was set.

For example, suppose you have the following list:

1-3 a: abcde 1-3 b: cdefg 2-9 c: ccccccccc

Each line gives the password policy and then the password. The password policy indicates the lowest and highest number of times a given letter must appear for the password to be valid. For example, 1-3 a means that the password must contain a at least 1 time and at most 3 times.

In the above example, 2 passwords are valid. The middle password, cdefg, is not; it contains no instances of b, but needs at least 1. The first and third passwords are valid: they contain one a or nine c, both within the limits of their respective policies.

How many passwords are valid according to their policies?

Input

9-10 b: bbktbbbxhfbpb
2-10 x: xxnxxxwxxsx
5-7 w: ghwwdrr
4-6 z: nzzjzk
7-8 s: szsssswfs
12-13 r: rrrrrrrrwrrfh
9-11 k: vclfkkfcdbwwk
10-13 v: wcnzkqgvvgxldxl
4-10 m: mmmmqmcmlmvmm
9-10 n: nnnnxnnnnr
5-19 r: drwrmrvprrrdrrrrrkv
7-10 s: sppscfwscfsszbsf
2-6 z: zrzshvzlzkxzp
9-15 f: ffffxffrffwfffffff
4-6 q: qsqqqqgqqg
1-4 d: mddd
3-5 g: qhgsgpjdphghhjwqx
1-9 b: jqmxlrdbbbfnwtlqjbbf
2-4 q: qqqq
5-8 s: ssssswsss
5-9 n: njnnksntk
1-11 t: wtttttttttrtttttttt
1-5 r: rrwgrrck
4-10 l: jlgxxlgllql
4-16 g: hgzjhgggcgnwddkq
2-5 s: smssk
5-9 r: rqnbnrrnnrwhdrr
6-12 x: xxxrxqxxxqxxkxs
3-4 j: jjtrjj
2-4 z: cnzzt
2-8 c: ccbcbcbncxxgcngrck
12-15 v: vdvvlvvzvvvgvvv
2-3 q: pqqtbwkr
2-6 t: ttctdtdtts
5-9 c: cccclcccpcccvc
1-4 b: dbjbk
4-15 q: zgppzlxqvrdvnkkgnr
10-12 q: qpqsqqqhqslqqnnqjqqg
13-14 k: kksmtsrkrwxkkk
12-16 z: zgzvzzzzzzzzzzzz
1-2 c: cczfkcmsdnghcnmhvx
5-10 b: bbbbbjbzzbbbb
1-4 l: mllt
7-8 k: kkkkdkkkkk
1-6 k: ctprksgrdgkg
9-11 s: ssssssstsss
5-6 h: hhhhpq
6-7 r: rrrrrrkrr
2-5 x: xxqrxwrchhd
15-16 r: rrrrbrrrrrdrrrrrr
2-3 c: ccrccz
4-6 j: jbkjnjddjhjhjqbxpzf
9-10 q: zqqkqvqskqqzzqcjqq
9-16 w: wwgwwwwwhwwwwwws
11-13 b: bbbbvbbbbblbrdb
2-5 p: pppbbp
8-11 x: xxxxrxkvmxlxwp
11-15 k: kkkkkkkkkkkxkbkjk
10-11 m: smmmmmmmmmnm
3-4 s: hsssv
3-6 s: gsxznsssbbtsl
3-5 n: nngnp
16-17 t: mntvzrcdttplrfzkv
9-12 g: fgggmgggfggm
1-15 l: lclwqxcczgnktqltm
14-18 f: tfkfrbbznftcfftbmfxf
3-5 q: qqbqc
10-11 m: mmmmmmmmmmxmmm
7-9 f: ffjfffnjnff
13-20 x: sjxdxqcxxxxqxkxxxxxq
14-17 s: ssssssgsssszspssb
5-13 m: kmmctmsmmmglzxm
4-7 s: qhrhsdbsmmlstznms
13-15 j: jjjjljjjjjjjqjj
5-16 n: ncnnnsvlpndnkvvrcf
14-18 n: nnnnnnnnnnnnnknnnb
5-6 v: jvvvvvvvppvt
1-16 f: fffzkffffknfrfqqf
6-8 x: xnxxkwknxlxxbbx
8-9 l: lllllllft
6-10 b: nrbmbbrhbfrbnn
3-7 s: sssssss
7-13 k: cpmxcndgssktpkkpfkk
3-6 r: rnrnrr
10-11 n: nnnnxnngrxhnn
14-15 g: dwggggggggjvgkgqgggg
3-5 g: gkgggks
2-13 d: vddnpddsdpddd
14-15 j: jjjjjjjjjjjjjjj
12-13 m: mmmmhmmmmxmmmm
6-7 s: sdssfpwsskqbq
2-13 v: mvvvvvvdvjvvvr
4-5 d: wldddd
9-16 v: rvvvmvgsvvvvvhjvvqs
17-18 j: jjjjjjjjjjjjjjjjjj
2-13 j: jjjjjjjbjjjjj
6-16 b: rgkcwbcnrdbrqvqbbq
2-11 t: btttbttznrctwwnltvnt
2-4 d: qsdvsgtd
5-10 t: ttttttttltt
5-6 m: mmqmmm
3-6 v: zjxcgdvswnfvvvv
13-14 s: sssgssrpssssszss
15-20 k: kkkkkkkkkkkkkkkkkkkk
5-6 x: xxxxsl
5-8 s: ssjszwsts
6-10 q: qqcqqqbqqp
11-12 m: mmmmmmmmmmjm
5-7 s: jszjsgsxtzkspgs
3-5 r: rrbprp
14-18 t: ttttttttsttttttttt
2-3 c: kccc
5-8 g: ggtgfggsgggggggggggg
5-12 n: nnnnmsnnnnbz
13-15 s: svsssssslsbsssssssz
11-18 s: ssbscmdbssksswksss
3-11 g: gggjwgrggzxmxbgg
1-16 d: dsndtgbmdrdxbddddjdd
12-13 b: bbrdbkbmbvbbb
3-6 g: cxwmbgmxg
7-8 t: ttttttkrcwq
4-8 w: wwwwtwwmkw
7-13 l: llfllmlslpslltll
3-10 n: nnnnnnnnnnnnnn
3-8 w: wwwhwwwwwrdpww
2-5 x: xxqxxt
13-14 h: hhhhhhhhhhhhrth
6-7 j: jfjjnrjjj
1-6 z: zdmsjnz
1-13 t: gjbzdcntxhfmg
3-5 c: clccczc
14-17 z: gzzwtvhzgrzxzrxxhcz
1-2 n: cnnn
12-14 q: qqqqqqqqqqqdqj
9-10 v: vvvvvvvvtd
3-8 t: mxptddtdttb
8-10 t: ttpttttttw
17-20 w: wgwwjqdwwwfgsrwwwsgw
3-4 v: fsvvdv
9-10 m: zxmbtjhpmhwx
13-14 b: bbbbssbbbwjqms
4-9 j: xsfvbjdmj
2-8 r: rsrrrrrlr
8-11 j: jjjjgjcjjngjfsjs
2-4 s: swsvs
12-13 p: prpppppvpppkhp
9-10 q: qqqqqqqqqs
9-10 b: bbbbbbbkbbb
8-13 t: tttttttlttttjt
3-7 b: bbgbbkbbbbbbbjp
9-11 w: wwwwwwwwwww
14-15 t: httttttttttttpmt
11-17 k: kfkkkkkkkkqkkkkkhkk
1-8 p: phqgprxp
7-16 j: djjgjjdjbwdjzjjcjdjj
1-3 w: wdjpt
17-18 w: wwzwwwwwwwwwwwwwnpw
2-4 h: hlhxkhhh
14-17 c: mbwhtknbvrqrzxprcctd
9-10 r: rrrrrrrrgxr
15-17 k: krkkkkkkkkqkkkfks
7-9 j: jjjjjqjjrkj
4-6 p: pwtpppj
4-5 w: wwwww
10-12 l: lllllllllllll
11-13 c: zkccccdcccccxcvtc
14-17 f: nbfhblbmqzrmrfzcfn
4-9 g: xvbggpltgglvggmgnpxk
1-4 k: mwkk
2-3 c: gcpckck
2-13 x: xbxxxxxxxxxxcxx
7-10 h: hhrhhhhhhh
1-3 p: npxrvvcgjpf
15-16 x: xxxxxxxxxxxxxcxx
17-18 d: dddddddddddddddddg
3-4 v: vvpb
3-5 s: zzsss
3-4 m: mmmmmmmmmmm
2-7 s: tsxlhfvtbzkkqssmss
4-11 c: bdkskbwctpckccbzbcc
8-9 g: ggggggggg
4-8 j: jjjkjjjjjj
7-10 f: qfffgfdffzff
12-14 j: jjjjjjvjjjjjjnjjj
6-7 b: kbbkqbbbhxqcdpbvb
1-6 x: gxlqxxxx
5-14 k: xvgfkksvtccfvkmbkmz
11-13 v: nvvvvvvvvvrvv
5-6 x: xbxnvx
12-13 f: fffffcfffffnnf
5-6 z: zzzwzzz
5-9 r: rsnzrrfrrrsmlr
7-8 z: zfzzzrbzzz
7-10 x: slxvrxnlwh
12-14 p: pppppppppppdpxp
11-18 q: qqqqqqqqpbqqlfqqwq
1-5 b: bqpglwpwbzzcdxhxqwq
14-16 q: qqqqqqqqqqqqqqqqqq
13-16 j: jjjjjjjjjjjjdjjq
2-8 j: jjljjnjkjzvjjq
7-8 l: lrdlzlqjllm
2-3 n: pkjt
1-2 z: jzzz
13-16 j: jjtjjjjjjjwjjjjkj
1-8 s: jdkssbsqks
12-13 p: ppppcplbpfppppppp
1-3 r: rrrr
5-9 h: hhhhhmmhm
6-8 q: vdqqvqqqz
5-12 k: vkrkksdkslmsrkxtslk
3-5 n: sldjnxplwngpnsqm
10-11 g: ggpgggngggng
13-15 g: kgggxggggrgglglvgf
14-16 h: hhhhhrhhwghkhhhhhhh
5-6 g: qqrghgwx
17-18 c: ccccccccvcccccccgw
7-8 r: rrrxrprr
2-3 z: ptpzzvc
3-7 b: bbbbbbb
1-2 n: szbzvnlxc
4-5 t: tttrt
12-14 m: mmmmmmmmmmmmmm
7-11 c: bscccccxccc
10-20 g: nvshfzjmtgsrnhtjgzzg
2-4 l: jhlspd
2-17 j: jngjjjcjhjjjjjgjs
3-8 t: tttttsswttt
7-18 t: tttttttttttttttttw
2-10 c: ccrcjkpkccvlbckbbtc
2-3 w: wmltwwj
5-9 s: sscrspfvspssj
9-17 g: gdggghjmggsggggfgj
12-15 w: wwwwwwwwwwwfcww
1-7 x: zfgmlxxxxbcsfxxclh
5-6 p: ctslhnhphlmpppz
8-13 s: sssqrsqtsssmsssss
1-7 v: vjvvcrk
9-10 k: kkkwjkrwkkkrxkkvhkf
16-17 j: jjjjjjjjjjjjjbjvcj
6-9 r: rvvrrrrqrr
11-12 x: xwxnrxxxmzxx
1-3 q: vqqgq
4-6 g: gbgxsbprgzg
3-4 x: xxxxx
4-12 z: xjpzjzkvzzrzwz
5-7 j: qhhjmjvjv
1-6 b: bfgmbbt
5-16 t: tttctthtttptttttttt
3-5 g: gggwg
3-4 t: ztpxt
3-6 k: dkkkkk
14-15 r: rrrrjvrrrrrrrcfr
6-10 f: gvtmdfqrhft
1-5 h: wpqss
14-16 l: lllzlllblllllrllllx
5-6 k: kkkgdlc
2-6 j: mjdjlrqjjjjszqzbbv
4-13 b: bbbgbbbblbbbn
10-11 v: vvvcvvvjvhrv
3-5 w: rqffzwzdgxwjmlk
3-8 w: xwjqmpvw
3-5 q: zfqsqqxqv
3-17 f: fskfffnfjszfffwfzfcf
9-13 l: qkllllslvwpkmnlfzlll
2-3 h: hhhh
9-16 d: dddddddjdrdcddzgdd
1-3 w: wwkw
4-8 f: fkfscjff
10-12 p: hsrpgppjmpbmmv
6-11 q: pzqqdqqqnqqqtqgqsqsq
2-6 k: dkkfsxzmnckggm
4-7 d: qddpsdddddr
3-5 j: ljnhn
4-5 m: mmmmjmm
4-6 h: zhhhhq
3-5 c: ccccc
4-12 j: jjjcjjjvxjjnvjqj
6-13 d: zdwddvmddwddgp
6-7 m: mmmmmmx
5-8 t: ktwfntjtgmvpttfx
11-17 z: vzzzzzzzzzbzzzzzlz
5-6 f: ffffrc
9-20 v: vvvvvvvvvvvvvvvvvvvg
8-12 v: vvvvvvvvvvvvvvvv
14-17 s: sssssssssssssssss
5-10 x: xxnxwxxxxxqskxwgpz
10-11 j: jjkmjwjbsjsjjjjjjp
2-4 v: qzsmvvv
14-18 x: xdxxxxxxfxxxdvxxxqx
13-18 w: wwmwwwwwdwhwwxpwbw
5-8 k: kkkklknlk
2-3 z: zqzz
8-13 w: dxrbwrzwtvngwwvzr
5-14 j: djjjjjsdvcjjjjtgjrjj
10-14 l: lllllllllllllm
17-19 f: fffxpfffffffcfffffnf
4-6 w: wwwcfnsw
3-16 k: kktndqkrcfnwtkkk
4-8 t: tpttmtht
1-2 l: lllwf
4-9 x: xxxxxxdxxmxc
2-6 c: cgqqbf
5-9 p: tpppdpppzfqlfph
2-5 s: lskss
2-6 b: fxbhhzhb
4-11 h: frhhbknrmrhv
2-4 w: wwjzvs
6-7 d: ddddddr
5-14 c: rbgcpfccppccncrsc
12-17 j: jjmpjjjjjhtcjhzjp
9-12 g: gggggggsgtgggggggg
11-14 b: bbbbnbbbsbbbbvblb
2-4 q: qqqqq
7-10 d: ddfdddddcddmmd
19-20 w: wwwwwwwwwwwwwxwwwwkw
6-7 j: jbjjjqc
5-12 m: mmmmgmgmmjcxpjm
4-8 d: rdddjdljdrd
1-4 d: tdgds
1-3 s: ssszvs
7-8 g: gvgggggggggg
5-9 b: bbwbbbbmbwb
4-13 m: lmwmbmqvzxjhmlp
4-12 j: thjjjfjjjjjjjj
3-4 l: llkk
7-9 v: vvvvvvvvdd
13-15 b: bbbbbbbbbbwtbtmbwqb
3-9 d: dddddzddd
4-9 p: pfpvppppj
4-8 g: kgpgbgggmngxggwfh
4-7 f: fffffff
7-9 r: wrrrrrrrrlrgtr
18-19 s: wssssssssssssmsssvds
16-20 n: nnnnfnnnnnnnnqnznnnn
3-4 s: sssc
12-14 h: hhhhhhhthhhhlhh
10-14 c: ccrccccdcccmcccbcc
2-3 m: tdvlm
2-5 z: zdzzh
11-13 m: mjmmxmwjmjmmmmmcmmvm
7-8 f: mfffffffgbtsffdvvfl
2-3 g: gggqh
7-14 t: tttttttttttttttt
2-10 l: lcllmcnllpvtlgll
2-4 s: scqskss
4-18 l: ncqqmclxshsfkcljlll
4-14 l: qbklhcmthmllfl
3-5 t: jrgztqxsctnz
11-18 t: tttbttstxqttrrtmtt
7-8 n: nvnndthznnq
14-16 n: pnnfzdzwnscvnfnn
2-8 l: vxnkllwltllllt
13-15 q: qqqqqqdqzqsbqqgqqq
4-5 f: ffflflff
1-4 z: nzzz
4-8 r: chrrrrvrsm
3-4 f: ffff
1-7 n: mnnnnngp
2-3 h: hwxh
10-16 s: sssrssgssmsszsrrps
6-7 s: mmzwdpv
10-14 r: rrrrzrzcrvrbrzllrk
9-11 k: kkbjfbhkkglwx
3-4 f: ddrwzgcmnfxfbffpdgbh
3-10 s: qssqszxqpskrwcxsss
7-11 f: fcccqmkfxfdhznwb
10-15 c: ctccncccccdccccxcwcc
3-6 j: vjzmjjr
9-13 d: ddtkddlkddddbdttr
11-19 f: krfxmnqfhfqfksfzrgfm
4-5 x: xxxxr
13-14 p: pppppppppprpdj
5-6 x: xbnxxxxx
15-16 l: lllllllgllllllsl
3-5 s: sxrcsm
12-15 m: nfdmhmkqpgcmnxmqcvn
1-7 q: qrrhxlq
3-4 l: nlllwlmlf
5-6 f: vffffff
6-10 g: gggggvgngfgg
4-14 s: sdgsssgqlqwjszkcgsz
4-6 t: tttvtx
4-7 g: qkggvgggwgfgfgn
6-11 h: hfdzhwmhwhhhgvx
10-15 g: ggggnrgggggflggg
7-8 v: vvvvvvcvvvv
3-4 q: qqqqq
3-6 t: qsdptbvtjhcjvjntwdnx
12-13 c: cccccccccccsx
2-9 h: hhhhhhxhnh
14-15 h: hhhhhhhhhhhhqhksd
18-20 d: dndzzcdgldkmjdvvdddz
4-5 k: kkkkts
4-5 z: zjzzwwz
2-3 z: bpxzxchzzzz
5-12 k: kkkkkkkkkqkc
5-11 k: kkqkkkbkkkwkkk
3-5 c: cgfccgc
3-4 t: jthdftcsfqt
7-9 x: xxxxxxxxxkxxxxxxznxb
1-6 z: xwzkzz
13-15 j: jjjjjjjjjjjjrhj
4-6 q: qqqjzq
5-6 k: kkkkrqg
2-6 s: gffhkvzs
4-6 k: ctdqjk
4-7 v: vcvhvtr
7-19 d: rxddghsddsrpdxxdddd
5-7 r: frlkptm
2-3 b: bbhbzgvd
11-12 h: phhhhhhhhhhkhg
6-8 c: dbsgwppccnwf
8-9 m: mmmgmlpvgdmmdnm
12-19 k: kkzkkkfkkkktzkkkkkbs
1-3 j: mjjjj
4-5 h: hpzhhhvrtdrqd
2-4 m: mmmjmmd
7-8 k: kkkkkkmk
7-8 q: qqwqqqqq
9-12 q: kfqqqqqxlqgbrvqvqwq
2-8 p: dhkfkvqp
3-5 h: hhhhh
2-7 t: rtvqwkqdpjcfttvntpm
2-8 k: kkkcjczlblwgm
3-6 q: qqcqqb
4-5 z: xzzqzzz
1-8 v: vvvvxvccnvv
2-6 n: nnjnctjqnj
15-16 v: vvvtvvvvvvvvvvqv
10-14 r: rrrtrrsrrrqrrr
3-10 d: qcddgpncddwdnldjzd
5-10 n: nnnnztnjnn
6-7 s: ssssjkstsh
2-5 r: crhvhfrlfbzmcqsxcr
5-9 h: hhhlbhqhljmhh
1-2 t: txvt
2-7 k: kkvpkqlpkknkkhmb
7-10 r: rrkrrrrrrr
17-18 z: zwzzzzzzzmzzzzzzdsz
13-17 g: sgvggggbggggqbggfggg
12-14 l: lnllldllllnllxlllll
10-11 j: jjjjjjjjjcj
3-8 p: vppjpkppx
19-20 s: ssppfsswtssqssxlbsls
4-6 j: xjjsjc
7-11 g: gggsgglsgpf
14-15 m: mmmmmmmmmmmmmmm
2-6 x: rxjvbxrxxcsthxl
12-19 s: sgssssqjssssvhssscts
1-8 w: wwvwrwfwlwww
10-12 q: qqqqnqqqqtqq
13-14 j: jjjjjjjjjjjjpr
2-6 j: zjjsljzdppjhjrq
1-3 k: tkgl
10-11 p: npwhgtcgwpptxnpztxn
1-4 m: mdmj
6-7 p: pgppptp
15-16 r: rrmfrrrrrrrrzrdsgrrc
9-10 b: cbbbtbbbdqsb
11-12 w: swwwrwwwwwwwwwlwl
1-4 c: xdfp
2-4 m: mmmb
9-10 b: bbbbbhbbbb
3-4 k: rxtk
5-7 x: xxxldxxxx
1-6 h: hhhhhwhh
3-4 d: ddsz
4-7 f: ftfffffjmmhz
5-7 n: fvpfwnn
8-10 s: sssssssksc
2-11 j: jkjjjsjdbjzljcpjjmj
12-13 r: rrrrrrrrrrrqz
4-11 d: tngdgqrdddtvgdq
6-7 g: gggggtz
4-13 g: lgqkgpfgklggxznk
7-8 j: jjdjljjjghnjmbqjb
1-4 p: pgnpjtbzdlh
13-16 p: ppppwnpcpppwppprp
13-16 s: ssssssssssssssshss
5-6 k: kkkhkjfbbkxh
6-18 b: djrsdpkhrnfkmgkxqb
3-5 c: ccbgp
1-16 m: mmzmlmmqmbwmmmmm
5-6 n: vqtnnk
11-16 x: xxxxxxpnxxxxhxvxh
2-5 q: mqqsq
4-5 p: xlpppp
3-5 v: vwvvvqwv
7-11 b: bbbbmwhfbjb
1-9 l: spnvxwwlmcmpd
2-3 c: cccm
5-12 t: gpcttsvjnqkt
8-10 r: rrrrrxrbrr
8-9 t: zpsltttvv
6-15 w: wwwkvwwwwswwwwwwww
13-16 t: fttgrdcdttttnttttdtt
14-16 n: nnnnzhnnnnnnnrnrnnn
3-10 c: ncccvmmcccxkrrcspjc
8-12 b: tmkmhnhblmhbxdvqb
2-5 w: wwnww
3-4 x: vgfwxx
2-3 l: lwkl
7-10 v: vvvvvvvhvvv
15-20 j: jjjjjjjrjjfjjjjjjjjj
9-10 c: ccqrkcccpcckc
3-5 c: clcccc
3-4 v: fwhvvv
14-16 g: ggggggggggggrgggg
5-9 z: zzzzrzzzzzz
6-7 v: vvvvvkv
8-9 p: ppjpppppp
6-7 v: hvvvvwpv
2-4 l: hlllgdxltwllwn
12-13 r: rrrrrrrrrbrrdrrr
2-6 n: vwbttnnnnsnbnhnnnm
1-12 g: xkxgggggsgggggdgg
1-5 s: sssss
5-19 d: qvddqzdddddddsxpdgdd
4-5 g: tgfpgksglmcg
6-7 b: cpbgbkq
9-13 l: llllllllflllsll
1-8 k: vvdsktqkfkdqlhbwrkqc
11-15 b: qbbbhjbgnbbzvbk
10-12 f: ffffffffffft
5-7 p: fndppppdnpp
3-4 t: xttt
9-12 l: lfvclqlrlllvllzl
5-9 h: mhdjxshhhzlp
2-4 t: tttt
3-7 c: wdccccccdgscgcq
8-16 b: sqbbbbbbbbbblbbgbbxp
6-9 n: nnnnnqndv
5-6 j: vwktnjjdhjsvndjjjsfj
7-9 w: lwvwjwwwwwww
2-3 c: bdrc
3-4 h: hhhh
8-16 j: fgnjtlhjjgknmbbj
3-4 f: ffpd
8-12 h: hhhhhhhchhhnhhhhh
8-14 w: zwxrgcbjbqwghhbwwb
6-9 c: wchcccccccccccc
6-10 f: fwfffcdfffsf
1-12 c: kccccccccccccc
8-10 t: dmtjzvjttxttrtftt
4-5 s: ssbnbss
3-4 q: qqdd
5-8 q: cgcjjbtq
12-15 b: hjjqbxwbnbbbwbfl
6-10 s: sfsfqnsfslsfssssst
4-10 b: tbgbjnqbbbtcbb
2-7 c: cmctjltcz
1-5 j: jjkjjqdjjjjpjjjjjj
16-17 j: jtjjjjjjjjjjjjjjs
2-19 n: njnnnnnnnwnnnnnnnnk
8-11 v: vvvvqvjnvvgmvvtv
11-15 z: zzzgzzzzzzzgzzz
3-5 r: rxrrt
3-12 m: llmntmzdjnhmcbmm
8-9 s: ssssssspws
6-9 v: vvvvvgvvv
2-7 k: kkkkkpk
12-16 v: vfvvvvvmvrvzvvzvvv
2-12 k: shkkkjtxkkklkkkk
4-5 t: ttttvt
4-6 k: lczkck
3-11 d: ddpddsddmddddd
7-12 p: vnrftmwdphrzxjv
2-4 z: zlzqh
16-17 q: qqqhqqqqqqqqqqqqqqq
5-9 r: rrrcrgrflqh
4-5 l: xllcv
8-11 h: hhhhhhhhhhhh
16-17 l: tfhpllgsrlvlbvncl
15-16 z: zrzzkzbzszdzzzzczzzz
11-12 v: vvvvpvqvvvvvvjv
12-16 w: wwwrwwmwwwwwwwww
7-8 m: mmmgmmnpm
2-8 c: cscccccbc
4-6 l: slrklplgsl
7-10 c: qpljmtcclfqc
16-17 s: gjssssrhksfmdssssw
1-4 r: krrz
3-4 g: gjgggdgpwd
11-13 l: llllllllllvlm
10-11 z: zzzzkzzzzzs
5-10 l: llllmlljlb
9-10 j: jjjjjjjjstbj
3-7 n: ndnvmnjl
2-10 x: pxdcdsxdsxjmx
11-12 g: ggggsgggggxkp
8-12 s: sssncsjspkxssssshs
9-11 d: ddddddddddc
3-5 x: xmxxxxxx
1-5 j: vnqpwg
4-5 k: lrqkkkqf
1-7 z: gwzdzzhzzzzzz
2-4 r: nrvvxsbrhghrrtr
3-4 x: xkxx
7-13 b: bpbbbnbbrbbbh
6-10 t: tttttttttttt
13-14 n: zgpqjvrsbsfgnn
8-9 x: xxxxxxxxx
6-7 c: xccwxqcscczcc
2-9 x: dxxxxbxxx
2-3 c: lcwrncsjwzss
16-18 g: bjkzbdrfjsnbldggwrqj
6-7 l: lllllshl
7-8 x: cvtxzlxxvls
8-11 q: qtwqqqcbqqhqz
7-11 n: nngqrnnnnnhnj
4-5 q: qqqqq
5-6 c: cgcccfj
15-16 z: zzzzzzzzzzzzzzzz
7-16 c: cblsccjzgccccccvcc
4-7 k: rkkkkkk
11-12 q: qnrqlqqqqqqcqqq
4-5 f: ffzcl
14-18 m: mjmmrmmmmmmmmtmmmd
7-9 f: fffbffffg
5-11 l: lslqdpbvslplll
2-4 s: brkfmk
10-11 c: cccccccccmc
2-5 z: zzzzh
1-11 h: hhhhhhhhhhhhh
2-5 z: zgzwlz
3-5 r: rrrrg
14-15 r: rrrrrrrrrrrrzbj
1-7 q: jppwfcqmvxjqxdf
2-4 m: bmmh
12-15 m: mmmcmmmsmmmqgmm
5-13 b: bbbvbfbbdbbhb
1-13 g: cgggggggggggv
3-9 s: bgldhnxsksznscnlnhc
6-7 t: tbvtbtkjt
8-9 q: klqpmdtqqcmlnftrn
8-10 f: fffffvflgfq
10-14 f: tcpfzmffffbffvpfff
1-5 h: dhrhjd
3-4 z: zbztzgfbcf
14-18 v: vvvvvvvvvvvvvvvvvv
18-19 h: hhhhhhhhhhhhhhhhhhh
1-4 q: vdqgqwhg
6-15 g: ggggggfggbsplggggh
1-4 s: srstdtspcrqqgqsl
10-19 x: xxxxxxjtxxwxmqswxxx
3-5 s: mjdsssssssssmss
6-10 q: qkqqqpqfxq
14-18 f: fffftmfffdfffftfff
5-6 n: qnrsvnvrnnn
4-5 x: xxxfp
8-10 m: mbmmmmklmw
2-4 n: nvntn
4-5 t: ttttt
6-8 t: jdlgtttpq
4-15 h: hhhhhhhhhnhhhhthhhhh
1-7 h: wpltchhcxwhkg
1-3 j: jjjjj
7-10 t: ttchcttwvtttftrtt
3-7 q: tsvrqqmdlzxs
6-9 x: sxjxxxxxx
13-15 b: bjbbbwbbbbbbdbbbbb
15-16 j: jjjjjjjjjjjjjjjp
5-9 k: rkkkkdtkmkjkdr
6-8 x: xxxxxxxx
7-8 p: ppgpppppblrp
1-2 q: qkqqqqq
3-6 j: jjjjjz
9-15 k: kckkkktskrpkkqkwklvk
5-9 b: bltqmxbsbbvdpvsqkpk
14-15 c: cccccccccccccgzc
10-13 l: mzlhlltlllllrcl
2-10 m: mmmmbqrmqmhmqm
4-5 g: gglglx
1-7 h: hdhlhhfhh
2-12 z: hnzdxfzxpwzzz
12-13 d: ddvddfddjdddmqvdkdmr
12-16 g: ggggngrxhgghgggggtgg
12-14 w: tkwdwwbtqwzphmzklrwk
4-5 c: cmccbcg
3-12 t: ttfxjgttsntkxznct
3-6 t: xjbhzxtttb
7-8 k: kkkkkkxf
2-4 p: pfppp
4-13 l: lllcllllllllllllllll
11-13 j: jmjvjjjjjjgjw
7-11 s: sssssswsssrmb
4-10 f: fffxfqtffff
10-12 p: pppppppppdpd
3-7 n: znfdhbn
2-3 w: wwwrwsw
2-6 n: mxnnfnx
5-7 c: cccpcchcsmlhc
1-5 j: jjtnj
2-4 d: ngtbkhcdwgd
1-4 t: txctqzq
5-10 h: hhnhhghstmtcq
4-7 x: xpzrmmjxxnxlxxx
14-17 c: ncccccckccccccccqc
17-19 s: mssssssslsssssssjsq
8-10 d: dddddddkdr
2-4 d: xcdn
2-4 w: wwwgw
3-15 x: klxxxslhpzwvfbxxlx
6-9 z: qtzhzgvzfzkgzzsfz
4-7 x: xhxxrmx
2-7 k: kkknkknkjk
2-4 r: zrcwpcrfm
3-20 v: vpvwnvrtvbvkdvnvvhrd
4-9 d: gsdhddtjdjg
3-7 s: sgsnshspt
10-12 g: ggxgghbgzxztg
2-8 l: fkxzlkdlmlllnwhlt
2-5 t: tttttt
6-8 b: bbbbbbbbbb
1-3 p: fpmp
1-7 w: llvwjdjvtp
2-7 x: rmbftbcmcxxxxpttzjwb
3-7 m: mmkmmrdmh
6-8 c: cccccccc
9-11 j: jjjjjjjjwnvjkxj
17-18 q: qqqqqqqqqqqqqqqqcx
4-6 z: zzhzzlg
17-20 f: ffffffmffffffffffxff
11-16 k: kkkkckkkkkkktkknkkk
10-12 k: kkkkkkkjkzkk
10-12 l: lllllllllplt
5-12 n: xnnhkdpmnjnzqnc
3-9 f: jmhkffdhsdsf
6-9 m: bzmppmqjdmhmgmmdm
8-9 h: hhhhhhhhl
4-8 r: rrrmrrrz
7-14 x: xxxpxxxxxxxxcn
4-18 v: hvvvvjqvvvqvtjmvfvvf
9-10 x: xxxxxxxxxj
2-8 m: rttmqfkvjgq
4-6 v: bjtvvv
2-4 k: kkkk
5-6 p: ppppxc
2-5 p: jhxcptzrpfsrxj
11-15 c: cccccwcxcccckccccccc
12-16 w: pgwllwwwwwwwvtwwww
11-13 m: mmmmmlmmmmmdmm
12-16 t: tltmtttwzjtssmtt
6-11 k: spgkkxpmtkbdkmzn
10-19 m: lrzzlvfncmpplqbmxhh
8-15 t: tttttttvttttttjttt
17-18 w: wwwwwwjwwwwwwwwwfj
14-18 l: bscmdvlczsgljvlbllwp
5-12 t: tdtslpttttvttgtkkt
1-5 s: pvqqhnpvcmxrwsspvnw
13-17 j: jjxjjvnjjjjjhjdjpjpj
6-8 f: jxlfvnrwt
8-11 q: dcqqmnqqzqqqqqqqq
3-4 r: rrrj
8-9 z: zffzzzzxzzz
8-9 c: cchccccwc
3-15 l: dpxfgtznlgmptjlxhzl
2-9 f: sfprndvdptlfdwh
13-14 z: zzzzzzzzttzzzzzz
16-17 l: llllllllllllllllrl
2-3 c: cxrwvncfl
3-5 f: flhbfkbfmf
3-5 s: hdkshswvlmg
3-7 l: llcllllllll
14-17 l: llllllllllllldllcll
3-4 l: klzl
4-12 r: rrrcvrrrrwrr
8-9 m: mmmmmzmmmmm
5-10 m: bqhbgmpmmhmwhmmm
10-11 h: xhhhhhhjhghh
3-4 p: hpbpppnxppk
9-10 z: bnzjzzzzzz
2-8 d: pzdrzhdddpd
14-15 f: ffffjffffztfffzff
3-13 b: bbbbbbbxbqbbf
8-17 p: fppppbppjpfpppzcnp
6-9 w: wwjwmtwwfjs
4-8 q: qqqltrkqzqqxqc
17-18 g: gggggggggggwggggtfg
14-16 k: kkkkkkkmkkkkkkkk
11-16 v: vvbvvvhvvvvrvvvv
4-5 z: zztzz
3-8 q: qpnqjptfrqxtdncqbg
9-13 v: nvmzrnvvvqvvvgvvvtvv
1-6 k: kvxbkvmdmgdmkhkwq
2-4 v: fpvvpv
4-5 x: cdxxx
3-4 j: jkjj
4-9 s: dslxngsjssxpsssgss
3-10 l: rszlllgzbvlll
5-6 z: zmzjznzkxzr
10-11 x: xjxxxsxxxfxx
11-13 x: xxjxqxxxpxwqxxxx
4-7 d: drkkhrd
15-17 f: sfsffffffffffffxnfff
6-16 m: mmrmlzdmzxnpmhmhmmfm
2-4 h: vhthh
17-18 q: qqqqqqqqqqqqqqqqqq
2-7 h: hhhhhhh
8-14 b: lbdvsxcbzvfltl
10-13 g: ggggggqgxphggcg
10-11 c: ccccxccccbc
1-10 f: pmtffffjfgkfpjm
14-18 k: wkskkkkkkkkkkkkkkn
5-8 n: qknnnfgn
6-8 l: lxlllklll
2-3 b: bmzb
3-13 n: nvpnrnjnnnqnnmnhlnx
1-4 t: rrjg
1-2 b: rkpbg
14-19 g: zcggccgvgpjghznmvgpg
5-6 j: jjjjjj
12-15 x: pxxxxxxxxxfbxxx
3-11 m: hmcmtmqmxcmm
2-4 h: wshlhh
2-3 b: gbzzqdvhpbvfgh
6-7 d: jdddfppddvdmds
16-17 k: kkfkkkkkkkkhkkkkp
6-15 k: nqkkkhkkkkkhkkkkkzkk
4-5 j: jtwsspjj
7-8 g: mrggggfg
5-11 r: wrrrdprrrrn
3-8 c: ccccccct
1-3 s: ssss
8-9 r: rrrrrrnjdr
7-10 v: vvcvvvcvfzn
2-4 b: bzplb
5-7 w: wwwwhwtw
9-10 b: bnphxrvfbjx
2-10 p: ppjppppplpp
3-17 m: mmmmmmmmmmmmmmmmg
4-7 b: bstmbbbbbmgtqm
9-11 q: sblqqbqqglfqlqfzqqld
16-18 v: vvvvdvvvvvvvvvvlvm
7-10 v: rpvvnzpcccvvhvbvvtz
7-9 m: mmmmmmmmm
9-12 g: gggglggjgggggg
2-4 d: ndhdsddzq
8-10 q: qczgcdqbqlqlzqq
4-8 c: pknvllcbxxcs
5-6 k: xpkkkk
3-6 q: qrdqcqqqq
7-8 r: rrgrrrrr
2-3 n: vntn
4-5 r: rrkrr
2-3 c: kcgcrbcqk
2-4 r: hrmrtrs
6-7 s: gsvwsjsgssbss
1-2 n: nkwj
4-12 k: kkkqkkkknknv
17-19 k: kkkkkkkkkkkkkkdkkkhk
8-9 p: ppppjvwlpd
2-7 s: dshmwzsspls
6-7 b: wbbbbbx
1-4 w: lwnwj
3-7 f: fffkfffnkdff
2-4 l: xlwsrlclpql
1-4 w: wwwv
17-18 r: sxrnvrtswzzzwwrdrt
8-11 q: qqqqqqqqqqkqq
1-9 c: gscmdrvngstmfknsjrp
14-15 n: nnnnnnnnnnnnnnn
15-16 n: nnnnnnfnnnhnnnnnn
4-6 w: fpbwwwwcwprflnjtwl
10-12 p: pgpprmwwczxjhpvpqmpp
2-14 c: wkdjtjxccwvzwbgr
4-6 t: ttthtn
7-8 s: ssssspgsqs
13-16 t: tdttqxtttttttttm
2-3 s: wsfdwh
2-3 z: qzbr
4-5 t: htkntst
2-10 g: qgpbkxdpggfglbpvn
11-13 k: kkkkkkkkkkkkk
5-10 v: vrvfvfvvwnvs
1-10 t: bsptvbqtctmwtztgtwt
1-6 g: hzcpck
9-15 g: zggnmghgggrggxqzj
2-7 z: czzzkzzzrz
1-4 f: zmnffhprzvrbhz
1-3 j: zjmjjjj
4-6 n: nnnnnnnnnnnxnnnnn
6-7 v: vvvvvpz
15-19 r: rrfrrrnrrrrrrrrrrrr
4-11 v: vvmzvvvpvvxk
3-4 x: xxxx
5-6 k: kllvds
10-14 r: rzrnvtrfkrrrvjrr
2-6 b: frbbbtvb
3-5 g: tpgwjrr
16-18 c: tcccccccctccccctcccc
5-14 g: tggjggggggggggmgz
3-5 c: qjfndkck
19-20 v: vvvvvvnvvvvvvvvvvvvg
7-11 x: xxxxvxxxqxf
16-20 v: vzvhjvbvvtvvvvvvvgvh
5-6 h: hhbhhh
1-2 d: dxbd
1-18 r: rvzjrgfrkrxrgbrdlrr
6-9 x: xgxdlxrgnfmsmfxcwx
2-15 h: whxfjxtcxlwxchb
1-3 w: tcvttwhsjpzd
8-10 l: qlrjglllxl
8-11 q: kggqvqbvwfbqlv
2-4 d: dsdwhnj
9-10 s: sssssssscrsz
2-9 l: klgblptpqzdp
11-14 q: qqqqqkrdqxjfqcqpqqqs
8-11 k: dvhvwdpkbdnwn
3-15 c: mcvccvccccccccd
3-5 d: dmqddv
2-7 p: npnfpswbhsbgknmvlgmx
2-5 f: hffrfm
11-12 b: nbbbhbbbgbhbbglqbbm
1-4 g: rgfg
3-6 z: zzzzzhcz
1-5 n: bzvxn
10-11 l: lllllllllqrmllkllvl
14-15 j: jjjjjjjjjjjjjbw
1-8 f: fffffsngffczj
4-9 n: zswmtrnlspnxdnbnbvln
6-8 c: jjcxcjnccclc
2-4 v: rvpvsvfft
1-5 x: xxdxkxxxxgx
7-11 f: nfqdgffmwlfc
1-7 n: nttvqnn
2-4 x: xxqxx
4-8 t: rttttttt
4-5 r: ktkwwzcrv
5-9 s: sfsslssss
1-15 p: splppplppprppcppppdp
3-6 l: xllhplwhllllzqbkll
3-4 g: ggsgq
19-20 w: wwwwwwwwwwwcwwwwwwqk
11-12 m: mmmmbmmmmmmm
10-13 c: cccmccccccccpcwcc
1-6 r: xrrrrprfl
3-4 w: hwww
5-7 s: zwldstwxsh
5-8 f: zhfglzmkfnqmbbtffftf
5-11 x: cxxzvxglxrbbqqcxf
11-13 b: bbbbbbbbbbbbdbbbb
1-6 d: qddddd
7-8 k: kkkkkkkb
14-15 d: ddddddfdddddddj
12-16 m: mmmdmmmmmmwpmmmlm
3-9 m: mtmxsdmmzsmlc
3-7 q: qjxlgqd
2-4 c: wccb
8-10 h: hhhhhhhkhc
2-4 s: jjlm
5-7 z: gzzzzzzjz
1-4 s: sqss
1-2 s: ssst
1-2 f: kfhf
4-6 b: bbtrbbbb
3-4 r: grrrr
1-7 r: lrpcfdfksxrh
9-10 v: vvvvvvvvhw
7-9 k: kkkkckkkck
9-12 h: hhhhhhwhthhhh
3-4 b: bdvbdwrgcbpwblj
6-8 v: vwqcvvvvvvsvvxjv
1-3 s: ssss
13-15 x: xnxxxxkxpxxxtxwx
1-3 j: jqjj
3-6 l: vlljlbllrbztnl
4-7 n: nnnsnnnnnnnnnnrnn
1-5 z: zzzvzzz
3-4 m: qmmjmm
7-9 m: gmmrtzmmrmmcmm
5-16 x: xzxpxxxxjxqxxqms
10-11 m: mmzrmmmmmmmmm
3-5 p: cpprxp
3-4 h: hhhjq
6-7 x: xxxlqwlxxvnnvvc
15-17 s: sssbsssscsssfssspsg
11-13 s: ssssssssgsssss
3-7 f: frfshbfn
4-6 n: tnnnpnn
7-10 g: ggggggfggg
6-7 j: jjzjthj
11-14 m: mmmmmmmmmmmmmmmkmmm
12-18 c: ccccccccftccccccccc
2-10 w: wvwwwwwwwwf
1-6 q: zvqqqmzqqt
13-19 f: ffffffffffffgfffffnf
5-11 x: lfxzxxcxxxxlbwnrx
2-3 s: vxgv
1-5 p: zpppxbmj
6-14 c: cpcccgcddfzcgcccc
3-5 q: qqqqvpqq
8-9 f: fffffffff
7-10 m: xmxmmwtmmmnvcrmkrmmm
2-4 v: vvjnrxnvtdmm
5-8 k: kkqkkkkkk
7-17 n: mqhnbwxnnnmcdlkfq
18-19 m: mmmmmmmmmmmmmmmmmmm
5-6 r: rrcrvmr
2-7 b: fdbvbdb

Solution

Attempt 1
  (defun build-pw-regex (spec)
    "Turn a SPEC of the format '2-7 b' to
  b.*b.*b?.*b?.*b?.*b?.*b?"
    (let* ((thing (split-string spec "[- ]"))
           (min (string-to-number (or (car thing) "0")))
           (max (string-to-number (or (cadr thing) "0")))
           (chr (caddr thing))
           (min-regex (concat ".*" chr))
           (max-regex (concat ".*" chr "?"))
           (min-full-regex "")
           (max-full-regex ""))
      (dotimes (n min min-full-regex)
        (setq min-full-regex (concat min-full-regex min-regex)))
      (dotimes (x (- max min) max-full-regex)
        (setq max-full-regex (concat max-full-regex max-regex)))
      (concat min-full-regex max-full-regex)))

  (let* ((strlist (split-string input "\n+"))
         (alist)
         (valid-count 0))
    (dolist (line strlist alist)
      (let* ((thing (split-string line ": "))
             (regex (build-pw-regex (car thing))))
        (setq alist (cons (list regex (cadr thing)) alist))))
    ;; test the regexen
    (dolist (a alist valid-count)
      (message "'%s' '%s'" (car a) (cadr a))
      (if (string-match (or (car a) "") (or (cadr a) ""))
          (setq valid-count (1+ valid-count)))))
741

Hmmm, I'm too high. Besides, this has a lot of issues with cleaning up the input; I'll keep trying tomorrow. But for now, to bed!

Okay, I lied. I tried 740 as well since the last row was giving me such trouble I thought I could've got a false positive there. Oh well.

Attempt 2

I think I've formatted the regex wrong; I also need to throw an error if there are too many of the character! So the regex for 2-7 b should look more like … ^[^b]*b.*b.*b?.*b?.*[^b]*$

  (defun build-pw-regex (spec)
    (let* ((thing (split-string spec "[- ]"))
           (min (string-to-number (or (car thing) "0")))
           (max (string-to-number (or (cadr thing) "0")))
           (chr (caddr thing))
           (regex-begin (concat "^[^" chr "]*"))
           (regex-end (concat "[^" chr "]*$"))
           (min-regex (concat chr ".*"))
           (max-regex (concat chr "?.*"))
           (min-full-regex "")
           (max-full-regex ""))
      (dotimes (n min min-full-regex)
        (setq min-full-regex (concat min-full-regex min-regex)))
      (dotimes (x (- max min) max-full-regex)
        (setq max-full-regex (concat max-full-regex max-regex)))
      (concat regex-begin min-full-regex max-full-regex regex-end)))

  (let* ((strlist (split-string input "\n+"))
         (alist)
         (valid-count 0))
    (dolist (line strlist alist)
      (let* ((thing (split-string line ": "))
             (regex (build-pw-regex (car thing))))
        (setq alist (cons (list regex (cadr thing)) alist))))
    ;; test the regexen
    (dolist (a alist valid-count)
      (message "%s '%s' '%s'"
               (string-match (or (car a) "") (or (cadr a) ""))
               (car a) (cadr a))
      (if (string-match (or (car a) "") (or (cadr a) ""))
          (setq valid-count (1+ valid-count)))))
741

Well tits.

Okay, tomorrow (really this time!), I'm going to look for a count style function.

Attempt 3

Okay, let's see if I can find some count something.

  (defun test-pw (spec password)
    "Return whether a PASSWORD works with the SPEC.
    PASSWORD is a string.
    SPEC is a string of the form <min>-<max> <char>."
    (let* ((split-spec (split-string spec "[ -]"))
           (min-string (car split-spec))
           (max-string (cadr split-spec))
           (chr-string (caddr split-spec))
           (min (string-to-number min-string))
           (max (string-to-number max-string))
           (chr (string-to-char chr-string))
           (pw-char-count (count-occur chr password)))
      (if (<= min pw-char-count max)
          1
        0)))

  (defun count-occur (item sequence &optional eq-func)
    "Count occurences of ITEM in SEQUENCE."
    (let ((times 0)
          (eqf (or eq-func #'eq)))
      (mapcar (lambda (j)
                (if (funcall eqf item j) (incf times)))
              sequence)
      times))


  (let* ((strlist (split-string input "\n+"))
         (alist)
         (valid-count 0))
    (dolist (line strlist alist)
      (let* ((splitted-line (split-string line ": "))
             (spec (car splitted-line))
             (pw (cadr splitted-line)))
        (if (and spec pw)
            (add-to-list 'alist (list spec pw (test-pw spec pw)))))))
2-7 b fdbvbdb 1
5-6 r rrcrvmr 0
18-19 m mmmmmmmmmmmmmmmmmmm 1
7-17 n mqhnbwxnnnmcdlkfq 0
5-8 k kkqkkkkkk 1
2-4 v vvjnrxnvtdmm 1
7-10 m xmxmmwtmmmnvcrmkrmmm 1
8-9 f fffffffff 1
3-5 q qqqqvpqq 0
6-14 c cpcccgcddfzcgcccc 1
1-5 p zpppxbmj 1
2-3 s vxgv 0
5-11 x lfxzxxcxxxxlbwnrx 1
13-19 f ffffffffffffgfffffnf 1
1-6 q zvqqqmzqqt 1
2-10 w wvwwwwwwwwf 1
12-18 c ccccccccftccccccccc 1
11-14 m mmmmmmmmmmmmmmmkmmm 0
6-7 j jjzjthj 0
7-10 g ggggggfggg 1
4-6 n tnnnpnn 1
3-7 f frfshbfn 1
11-13 s ssssssssgsssss 1
15-17 s sssbsssscsssfssspsg 0
6-7 x xxxlqwlxxvnnvvc 0
3-4 h hhhjq 1
3-5 p cpprxp 1
10-11 m mmzrmmmmmmmmm 1
5-16 x xzxpxxxxjxqxxqms 1
7-9 m gmmrtzmmrmmcmm 1
3-4 m qmmjmm 1
1-5 z zzzvzzz 0
4-7 n nnnsnnnnnnnnnnrnn 0
3-6 l vlljlbllrbztnl 1
1-3 j jqjj 1
13-15 x xnxxxxkxpxxxtxwx 0
6-8 v vwqcvvvvvvsvvxjv 0
3-4 b bdvbdwrgcbpwblj 1
9-12 h hhhhhhwhthhhh 1
7-9 k kkkkckkkck 1
9-10 v vvvvvvvvhw 0
1-7 r lrpcfdfksxrh 1
3-4 r grrrr 1
4-6 b bbtrbbbb 1
1-2 f kfhf 1
1-2 s ssst 0
1-4 s sqss 1
5-7 z gzzzzzzjz 1
2-4 s jjlm 0
8-10 h hhhhhhhkhc 1
2-4 c wccb 1
3-7 q qjxlgqd 0
3-9 m mtmxsdmmzsmlc 1
12-16 m mmmdmmmmmmwpmmmlm 1
14-15 d ddddddfdddddddj 0
7-8 k kkkkkkkb 1
1-6 d qddddd 1
11-13 b bbbbbbbbbbbbdbbbb 0
5-11 x cxxzvxglxrbbqqcxf 1
5-8 f zhfglzmkfnqmbbtffftf 1
5-7 s zwldstwxsh 0
3-4 w hwww 1
1-6 r xrrrrprfl 1
10-13 c cccmccccccccpcwcc 0
11-12 m mmmmbmmmmmmm 1
19-20 w wwwwwwwwwwwcwwwwwwqk 0
3-4 g ggsgq 1
3-6 l xllhplwhllllzqbkll 0
1-15 p splppplppprppcppppdp 1
5-9 s sfsslssss 1
4-5 r ktkwwzcrv 0
4-8 t rttttttt 1
2-4 x xxqxx 1
1-7 n nttvqnn 1
7-11 f nfqdgffmwlfc 0
1-5 x xxdxkxxxxgx 0
2-4 v rvpvsvfft 1
6-8 c jjcxcjnccclc 1
4-9 n zswmtrnlspnxdnbnbvln 1
1-8 f fffffsngffczj 1
14-15 j jjjjjjjjjjjjjbw 0
10-11 l lllllllllqrmllkllvl 0
1-5 n bzvxn 1
3-6 z zzzzzhcz 1
1-4 g rgfg 1
11-12 b nbbbhbbbgbhbbglqbbm 1
2-5 f hffrfm 1
2-7 p npnfpswbhsbgknmvlgmx 1
3-5 d dmqddv 1
3-15 c mcvccvccccccccd 1
8-11 k dvhvwdpkbdnwn 0
11-14 q qqqqqkrdqxjfqcqpqqqs 1
2-9 l klgblptpqzdp 1
9-10 s sssssssscrsz 1
2-4 d dsdwhnj 1
8-11 q kggqvqbvwfbqlv 0
8-10 l qlrjglllxl 0
1-3 w tcvttwhsjpzd 1
2-15 h whxfjxtcxlwxchb 1
6-9 x xgxdlxrgnfmsmfxcwx 0
1-18 r rvzjrgfrkrxrgbrdlrr 1
1-2 d dxbd 1
5-6 h hhbhhh 1
16-20 v vzvhjvbvvtvvvvvvvgvh 0
7-11 x xxxxvxxxqxf 1
19-20 v vvvvvvnvvvvvvvvvvvvg 0
3-5 c qjfndkck 0
5-14 g tggjggggggggggmgz 1
16-18 c tcccccccctccccctcccc 1
3-5 g tpgwjrr 0
2-6 b frbbbtvb 1
10-14 r rzrnvtrfkrrrvjrr 0
5-6 k kllvds 0
3-4 x xxxx 1
4-11 v vvmzvvvpvvxk 1
15-19 r rrfrrrnrrrrrrrrrrrr 1
6-7 v vvvvvpz 0
4-6 n nnnnnnnnnnnxnnnnn 0
1-3 j zjmjjjj 0
1-4 f zmnffhprzvrbhz 1
2-7 z czzzkzzzrz 1
9-15 g zggnmghgggrggxqzj 0
1-6 g hzcpck 0
1-10 t bsptvbqtctmwtztgtwt 1
5-10 v vrvfvfvvwnvs 1
11-13 k kkkkkkkkkkkkk 1
2-10 g qgpbkxdpggfglbpvn 1
4-5 t htkntst 0
2-3 z qzbr 0
2-3 s wsfdwh 0
13-16 t tdttqxtttttttttm 0
7-8 s ssssspgsqs 1
4-6 t ttthtn 1
2-14 c wkdjtjxccwvzwbgr 1
10-12 p pgpprmwwczxjhpvpqmpp 0
4-6 w fpbwwwwcwprflnjtwl 1
15-16 n nnnnnnfnnnhnnnnnn 1
14-15 n nnnnnnnnnnnnnnn 1
1-9 c gscmdrvngstmfknsjrp 1
8-11 q qqqqqqqqqqkqq 0
17-18 r sxrnvrtswzzzwwrdrt 0
1-4 w wwwv 1
2-4 l xlwsrlclpql 1
3-7 f fffkfffnkdff 0
1-4 w lwnwj 1
6-7 b wbbbbbx 0
2-7 s dshmwzsspls 1
8-9 p ppppjvwlpd 0
17-19 k kkkkkkkkkkkkkkdkkkhk 1
4-12 k kkkqkkkknknv 1
1-2 n nkwj 1
6-7 s gsvwsjsgssbss 1
2-4 r hrmrtrs 1
2-3 c kcgcrbcqk 1
4-5 r rrkrr 1
2-3 n vntn 1
7-8 r rrgrrrrr 1
3-6 q qrdqcqqqq 1
5-6 k xpkkkk 0
4-8 c pknvllcbxxcs 0
8-10 q qczgcdqbqlqlzqq 0
2-4 d ndhdsddzq 1
9-12 g gggglggjgggggg 1
7-9 m mmmmmmmmm 1
7-10 v rpvvnzpcccvvhvbvvtz 1
16-18 v vvvvdvvvvvvvvvvlvm 0
9-11 q sblqqbqqglfqlqfzqqld 0
4-7 b bstmbbbbbmgtqm 1
3-17 m mmmmmmmmmmmmmmmmg 1
2-10 p ppjppppplpp 1
9-10 b bnphxrvfbjx 0
5-7 w wwwwhwtw 1
2-4 b bzplb 1
7-10 v vvcvvvcvfzn 0
8-9 r rrrrrrnjdr 0
1-3 s ssss 0
3-8 c ccccccct 1
5-11 r wrrrdprrrrn 1
7-8 g mrggggfg 0
4-5 j jtwsspjj 0
6-15 k nqkkkhkkkkkhkkkkkzkk 1
16-17 k kkfkkkkkkkkhkkkkp 0
6-7 d jdddfppddvdmds 1
2-3 b gbzzqdvhpbvfgh 1
2-4 h wshlhh 1
3-11 m hmcmtmqmxcmm 1
12-15 x pxxxxxxxxxfbxxx 1
5-6 j jjjjjj 1
14-19 g zcggccgvgpjghznmvgpg 0
1-2 b rkpbg 1
1-4 t rrjg 0
3-13 n nvpnrnjnnnqnnmnhlnx 1
2-3 b bmzb 1
6-8 l lxlllklll 1
5-8 n qknnnfgn 0
14-18 k wkskkkkkkkkkkkkkkn 1
1-10 f pmtffffjfgkfpjm 1
10-11 c ccccxccccbc 0
10-13 g ggggggqgxphggcg 1
8-14 b lbdvsxcbzvfltl 0
2-7 h hhhhhhh 1
17-18 q qqqqqqqqqqqqqqqqqq 1
2-4 h vhthh 1
6-16 m mmrmlzdmzxnpmhmhmmfm 1
15-17 f sfsffffffffffffxnfff 1
4-7 d drkkhrd 0
11-13 x xxjxqxxxpxwqxxxx 1
10-11 x xjxxxsxxxfxx 0
5-6 z zmzjznzkxzr 1
3-10 l rszlllgzbvlll 1
4-9 s dslxngsjssxpsssgss 1
3-4 j jkjj 1
4-5 x cdxxx 0
2-4 v fpvvpv 1
1-6 k kvxbkvmdmgdmkhkwq 1
9-13 v nvmzrnvvvqvvvgvvvtvv 1
3-8 q qpnqjptfrqxtdncqbg 1
4-5 z zztzz 1
11-16 v vvbvvvhvvvvrvvvv 1
14-16 k kkkkkkkmkkkkkkkk 1
17-18 g gggggggggggwggggtfg 0
4-8 q qqqltrkqzqqxqc 1
6-9 w wwjwmtwwfjs 0
8-17 p fppppbppjpfpppzcnp 1
3-13 b bbbbbbbxbqbbf 1
14-15 f ffffjffffztfffzff 0
2-8 d pzdrzhdddpd 1
9-10 z bnzjzzzzzz 0
3-4 p hpbpppnxppk 0
10-11 h xhhhhhhjhghh 0
5-10 m bqhbgmpmmhmwhmmm 1
8-9 m mmmmmzmmmmm 0
4-12 r rrrcvrrrrwrr 1
3-4 l klzl 0
14-17 l llllllllllllldllcll 1
3-7 l llcllllllll 0
3-5 s hdkshswvlmg 0
3-5 f flhbfkbfmf 1
2-3 c cxrwvncfl 1
16-17 l llllllllllllllllrl 1
13-14 z zzzzzzzzttzzzzzz 1
2-9 f sfprndvdptlfdwh 1
3-15 l dpxfgtznlgmptjlxhzl 1
8-9 c cchccccwc 0
8-9 z zffzzzzxzzz 1
3-4 r rrrj 1
8-11 q dcqqmnqqzqqqqqqqq 0
6-8 f jxlfvnrwt 0
13-17 j jjxjjvnjjjjjhjdjpjpj 1
1-5 s pvqqhnpvcmxrwsspvnw 1
5-12 t tdtslpttttvttgtkkt 1
14-18 l bscmdvlczsgljvlbllwp 0
17-18 w wwwwwwjwwwwwwwwwfj 0
8-15 t tttttttvttttttjttt 0
10-19 m lrzzlvfncmpplqbmxhh 0
6-11 k spgkkxpmtkbdkmzn 0
12-16 t tltmtttwzjtssmtt 0
11-13 m mmmmmlmmmmmdmm 1
12-16 w pgwllwwwwwwwvtwwww 1
11-15 c cccccwcxcccckccccccc 0
2-5 p jhxcptzrpfsrxj 1
5-6 p ppppxc 0
2-4 k kkkk 1
4-6 v bjtvvv 0
2-8 m rttmqfkvjgq 0
9-10 x xxxxxxxxxj 1
4-18 v hvvvvjqvvvqvtjmvfvvf 1
7-14 x xxxpxxxxxxxxcn 1
4-8 r rrrmrrrz 1
8-9 h hhhhhhhhl 1
6-9 m bzmppmqjdmhmgmmdm 1
3-9 f jmhkffdhsdsf 1
5-12 n xnnhkdpmnjnzqnc 1
10-12 l lllllllllplt 1
10-12 k kkkkkkkjkzkk 1
11-16 k kkkkckkkkkkktkknkkk 1
17-20 f ffffffmffffffffffxff 1
4-6 z zzhzzlg 1
17-18 q qqqqqqqqqqqqqqqqcx 0
9-11 j jjjjjjjjwnvjkxj 1
6-8 c cccccccc 1
3-7 m mmkmmrdmh 1
2-7 x rmbftbcmcxxxxpttzjwb 1
1-7 w llvwjdjvtp 1
1-3 p fpmp 1
6-8 b bbbbbbbbbb 0
2-5 t tttttt 0
2-8 l fkxzlkdlmlllnwhlt 1
10-12 g ggxgghbgzxztg 0
3-7 s sgsnshspt 1
4-9 d gsdhddtjdjg 1
3-20 v vpvwnvrtvbvkdvnvvhrd 1
2-4 r zrcwpcrfm 1
2-7 k kkknkknkjk 1
4-7 x xhxxrmx 1
6-9 z qtzhzgvzfzkgzzsfz 1
3-15 x klxxxslhpzwvfbxxlx 1
2-4 w wwwgw 1
2-4 d xcdn 0
8-10 d dddddddkdr 1
17-19 s mssssssslsssssssjsq 0
14-17 c ncccccckccccccccqc 1
4-7 x xpzrmmjxxnxlxxx 1
5-10 h hhnhhghstmtcq 1
1-4 t txctqzq 1
2-4 d ngtbkhcdwgd 1
1-5 j jjtnj 1
5-7 c cccpcchcsmlhc 1
2-6 n mxnnfnx 1
2-3 w wwwrwsw 0
3-7 n znfdhbn 0
10-12 p pppppppppdpd 1
4-10 f fffxfqtffff 1
7-11 s sssssswsssrmb 1
11-13 j jmjvjjjjjjgjw 0
4-13 l lllcllllllllllllllll 0
2-4 p pfppp 1
7-8 k kkkkkkxf 0
3-6 t xjbhzxtttb 1
3-12 t ttfxjgttsntkxznct 1
4-5 c cmccbcg 1
12-14 w tkwdwwbtqwzphmzklrwk 0
12-16 g ggggngrxhgghgggggtgg 1
12-13 d ddvddfddjdddmqvdkdmr 0
2-12 z hnzdxfzxpwzzz 1
1-7 h hdhlhhfhh 1
4-5 g gglglx 0
2-10 m mmmmbqrmqmhmqm 1
10-13 l mzlhlltlllllrcl 0
14-15 c cccccccccccccgzc 1
5-9 b bltqmxbsbbvdpvsqkpk 0
9-15 k kckkkktskrpkkqkwklvk 1
3-6 j jjjjjz 1
1-2 q qkqqqqq 0
7-8 p ppgpppppblrp 1
6-8 x xxxxxxxx 1
5-9 k rkkkkdtkmkjkdr 1
15-16 j jjjjjjjjjjjjjjjp 1
13-15 b bjbbbwbbbbbbdbbbbb 1
6-9 x sxjxxxxxx 1
3-7 q tsvrqqmdlzxs 0
7-10 t ttchcttwvtttftrtt 1
1-3 j jjjjj 0
1-7 h wpltchhcxwhkg 1
4-15 h hhhhhhhhhnhhhhthhhhh 0
6-8 t jdlgtttpq 0
4-5 t ttttt 1
2-4 n nvntn 1
8-10 m mbmmmmklmw 0
4-5 x xxxfp 0
5-6 n qnrsvnvrnnn 1
14-18 f fffftmfffdfffftfff 1
6-10 q qkqqqpqfxq 1
3-5 s mjdsssssssssmss 0
10-19 x xxxxxxjtxxwxmqswxxx 1
1-4 s srstdtspcrqqgqsl 1
6-15 g ggggggfggbsplggggh 1
1-4 q vdqgqwhg 1
18-19 h hhhhhhhhhhhhhhhhhhh 1
14-18 v vvvvvvvvvvvvvvvvvv 1
3-4 z zbztzgfbcf 1
1-5 h dhrhjd 1
10-14 f tcpfzmffffbffvpfff 1
8-10 f fffffvflgfq 0
8-9 q klqpmdtqqcmlnftrn 0
6-7 t tbvtbtkjt 0
3-9 s bgldhnxsksznscnlnhc 1
1-13 g cgggggggggggv 1
5-13 b bbbvbfbbdbbhb 1
12-15 m mmmcmmmsmmmqgmm 0
2-4 m bmmh 1
1-7 q jppwfcqmvxjqxdf 1
14-15 r rrrrrrrrrrrrzbj 0
3-5 r rrrrg 1
2-5 z zgzwlz 1
1-11 h hhhhhhhhhhhhh 0
2-5 z zzzzh 1
10-11 c cccccccccmc 1
2-4 s brkfmk 0
5-11 l lslqdpbvslplll 1
7-9 f fffbffffg 1
14-18 m mjmmrmmmmmmmmtmmmd 1
4-5 f ffzcl 0
11-12 q qnrqlqqqqqqcqqq 1
4-7 k rkkkkkk 1
7-16 c cblsccjzgccccccvcc 1
15-16 z zzzzzzzzzzzzzzzz 1
5-6 c cgcccfj 0
4-5 q qqqqq 1
7-11 n nngqrnnnnnhnj 1
8-11 q qtwqqqcbqqhqz 0
7-8 x cvtxzlxxvls 0
6-7 l lllllshl 1
16-18 g bjkzbdrfjsnbldggwrqj 0
2-3 c lcwrncsjwzss 1
2-9 x dxxxxbxxx 1
6-7 c xccwxqcscczcc 1
8-9 x xxxxxxxxx 1
13-14 n zgpqjvrsbsfgnn 0
6-10 t tttttttttttt 0
7-13 b bpbbbnbbrbbbh 1
3-4 x xkxx 1
2-4 r nrvvxsbrhghrrtr 0
1-7 z gwzdzzhzzzzzz 0
4-5 k lrqkkkqf 0
1-5 j vnqpwg 0
3-5 x xmxxxxxx 0
9-11 d ddddddddddc 1
8-12 s sssncsjspkxssssshs 1
11-12 g ggggsgggggxkp 0
2-10 x pxdcdsxdsxjmx 1
3-7 n ndnvmnjl 1
9-10 j jjjjjjjjstbj 1
5-10 l llllmlljlb 1
10-11 z zzzzkzzzzzs 0
11-13 l llllllllllvlm 1
3-4 g gjgggdgpwd 0
1-4 r krrz 1
16-17 s gjssssrhksfmdssssw 0
7-10 c qpljmtcclfqc 0
4-6 l slrklplgsl 1
2-8 c cscccccbc 1
7-8 m mmmgmmnpm 0
12-16 w wwwrwwmwwwwwwwww 1
11-12 v vvvvpvqvvvvvvjv 1
15-16 z zrzzkzbzszdzzzzczzzz 0
16-17 l tfhpllgsrlvlbvncl 0
8-11 h hhhhhhhhhhhh 0
4-5 l xllcv 0
5-9 r rrrcrgrflqh 1
16-17 q qqqhqqqqqqqqqqqqqqq 0
2-4 z zlzqh 1
7-12 p vnrftmwdphrzxjv 0
3-11 d ddpddsddmddddd 1
4-6 k lczkck 0
4-5 t ttttvt 1
2-12 k shkkkjtxkkklkkkk 1
12-16 v vfvvvvvmvrvzvvzvvv 1
2-7 k kkkkkpk 1
6-9 v vvvvvgvvv 1
8-9 s ssssssspws 1
3-12 m llmntmzdjnhmcbmm 1
3-5 r rxrrt 1
11-15 z zzzgzzzzzzzgzzz 1
8-11 v vvvvqvjnvvgmvvtv 1
2-19 n njnnnnnnnwnnnnnnnnk 1
16-17 j jtjjjjjjjjjjjjjjs 0
1-5 j jjkjjqdjjjjpjjjjjj 0
2-7 c cmctjltcz 1
4-10 b tbgbjnqbbbtcbb 1
6-10 s sfsfqnsfslsfssssst 1
12-15 b hjjqbxwbnbbbwbfl 0
5-8 q cgcjjbtq 0
3-4 q qqdd 0
4-5 s ssbnbss 1
8-10 t dmtjzvjttxttrtftt 1
1-12 c kccccccccccccc 0
6-10 f fwfffcdfffsf 1
6-9 c wchcccccccccccc 0
8-14 w zwxrgcbjbqwghhbwwb 0
8-12 h hhhhhhhchhhnhhhhh 0
3-4 f ffpd 0
8-16 j fgnjtlhjjgknmbbj 0
3-4 h hhhh 1
2-3 c bdrc 0
7-9 w lwvwjwwwwwww 1
5-6 j vwktnjjdhjsvndjjjsfj 0
6-9 n nnnnnqndv 1
8-16 b sqbbbbbbbbbblbbgbbxp 1
3-7 c wdccccccdgscgcq 0
2-4 t tttt 1
5-9 h mhdjxshhhzlp 0
9-12 l lfvclqlrlllvllzl 1
3-4 t xttt 1
5-7 p fndppppdnpp 1
10-12 f ffffffffffft 1
11-15 b qbbbhjbgnbbzvbk 0
1-8 k vvdsktqkfkdqlhbwrkqc 1
9-13 l llllllllflllsll 1
6-7 b cpbgbkq 0
4-5 g tgfpgksglmcg 1
5-19 d qvddqzdddddddsxpdgdd 1
1-5 s sssss 1
1-12 g xkxgggggsgggggdgg 1
2-6 n vwbttnnnnsnbnhnnnm 0
12-13 r rrrrrrrrrbrrdrrr 0
2-4 l hlllgdxltwllwn 0
6-7 v hvvvvwpv 0
8-9 p ppjpppppp 1
6-7 v vvvvvkv 1
5-9 z zzzzrzzzzzz 0
14-16 g ggggggggggggrgggg 1
3-4 v fwhvvv 1
3-5 c clcccc 1
9-10 c ccqrkcccpcckc 0
15-20 j jjjjjjjrjjfjjjjjjjjj 1
7-10 v vvvvvvvhvvv 1
2-3 l lwkl 1
3-4 x vgfwxx 0
2-5 w wwnww 1
8-12 b tmkmhnhblmhbxdvqb 0
3-10 c ncccvmmcccxkrrcspjc 1
14-16 n nnnnzhnnnnnnnrnrnnn 1
13-16 t fttgrdcdttttnttttdtt 0
6-15 w wwwkvwwwwswwwwwwww 1
8-9 t zpsltttvv 0
8-10 r rrrrrxrbrr 1
5-12 t gpcttsvjnqkt 0
2-3 c cccm 1
1-9 l spnvxwwlmcmpd 1
7-11 b bbbbmwhfbjb 0
3-5 v vwvvvqwv 1
4-5 p xlpppp 1
2-5 q mqqsq 1
11-16 x xxxxxxpnxxxxhxvxh 1
5-6 n vqtnnk 0
1-16 m mmzmlmmqmbwmmmmm 1
3-5 c ccbgp 0
6-18 b djrsdpkhrnfkmgkxqb 0
5-6 k kkkhkjfbbkxh 1
13-16 s ssssssssssssssshss 0
13-16 p ppppwnpcpppwppprp 0
1-4 p pgnpjtbzdlh 1
7-8 j jjdjljjjghnjmbqjb 1
4-13 g lgqkgpfgklggxznk 1
6-7 g gggggtz 0
4-11 d tngdgqrdddtvgdq 1
12-13 r rrrrrrrrrrrqz 0
2-11 j jkjjjsjdbjzljcpjjmj 1
8-10 s sssssssksc 1
5-7 n fvpfwnn 0
4-7 f ftfffffjmmhz 1
3-4 d ddsz 0
1-6 h hhhhhwhh 0
5-7 x xxxldxxxx 1
3-4 k rxtk 0
9-10 b bbbbbhbbbb 1
2-4 m mmmb 1
1-4 c xdfp 0
11-12 w swwwrwwwwwwwwwlwl 0
9-10 b cbbbtbbbdqsb 0
15-16 r rrmfrrrrrrrrzrdsgrrc 0
6-7 p pgppptp 0
1-4 m mdmj 1
10-11 p npwhgtcgwpptxnpztxn 0
1-3 k tkgl 1
2-6 j zjjsljzdppjhjrq 1
13-14 j jjjjjjjjjjjjpr 0
10-12 q qqqqnqqqqtqq 1
1-8 w wwvwrwfwlwww 1
12-19 s sgssssqjssssvhssscts 1
2-6 x rxjvbxrxxcsthxl 1
14-15 m mmmmmmmmmmmmmmm 1
7-11 g gggsgglsgpf 0
4-6 j xjjsjc 0
19-20 s ssppfsswtssqssxlbsls 0
3-8 p vppjpkppx 1
10-11 j jjjjjjjjjcj 1
12-14 l lnllldllllnllxlllll 0
13-17 g sgvggggbggggqbggfggg 1
17-18 z zwzzzzzzzmzzzzzzdsz 0
7-10 r rrkrrrrrrr 1
2-7 k kkvpkqlpkknkkhmb 1
1-2 t txvt 1
5-9 h hhhlbhqhljmhh 1
2-5 r crhvhfrlfbzmcqsxcr 1
6-7 s ssssjkstsh 1
5-10 n nnnnztnjnn 1
3-10 d qcddgpncddwdnldjzd 1
10-14 r rrrtrrsrrrqrrr 1
15-16 v vvvtvvvvvvvvvvqv 0
2-6 n nnjnctjqnj 1
1-8 v vvvvxvccnvv 1
4-5 z xzzqzzz 1
3-6 q qqcqqb 1
2-8 k kkkcjczlblwgm 1
2-7 t rtvqwkqdpjcfttvntpm 1
3-5 h hhhhh 1
2-8 p dhkfkvqp 0
9-12 q kfqqqqqxlqgbrvqvqwq 1
7-8 q qqwqqqqq 1
7-8 k kkkkkkmk 1
2-4 m mmmjmmd 0
4-5 h hpzhhhvrtdrqd 1
1-3 j mjjjj 0
12-19 k kkzkkkfkkkktzkkkkkbs 1
8-9 m mmmgmlpvgdmmdnm 0
6-8 c dbsgwppccnwf 0
11-12 h phhhhhhhhhhkhg 1
2-3 b bbhbzgvd 1
5-7 r frlkptm 0
7-19 d rxddghsddsrpdxxdddd 1
4-7 v vcvhvtr 0
4-6 k ctdqjk 0
2-6 s gffhkvzs 0
5-6 k kkkkrqg 0
4-6 q qqqjzq 1
13-15 j jjjjjjjjjjjjrhj 1
1-6 z xwzkzz 1
7-9 x xxxxxxxxxkxxxxxxznxb 0
3-4 t jthdftcsfqt 1
3-5 c cgfccgc 1
5-11 k kkqkkkbkkkwkkk 1
5-12 k kkkkkkkkkqkc 1
2-3 z bpxzxchzzzz 0
4-5 z zjzzwwz 1
4-5 k kkkkts 1
18-20 d dndzzcdgldkmjdvvdddz 0
14-15 h hhhhhhhhhhhhqhksd 0
2-9 h hhhhhhxhnh 1
12-13 c cccccccccccsx 0
3-6 t qsdptbvtjhcjvjntwdnx 1
3-4 q qqqqq 0
7-8 v vvvvvvcvvvv 0
10-15 g ggggnrgggggflggg 1
6-11 h hfdzhwmhwhhhgvx 1
4-7 g qkggvgggwgfgfgn 0
4-6 t tttvtx 1
4-14 s sdgsssgqlqwjszkcgsz 1
6-10 g gggggvgngfgg 1
5-6 f vffffff 1
3-4 l nlllwlmlf 0
1-7 q qrrhxlq 1
12-15 m nfdmhmkqpgcmnxmqcvn 0
3-5 s sxrcsm 0
15-16 l lllllllgllllllsl 0
5-6 x xbnxxxxx 1
13-14 p pppppppppprpdj 0
4-5 x xxxxr 1
11-19 f krfxmnqfhfqfksfzrgfm 0
9-13 d ddtkddlkddddbdttr 1
3-6 j vjzmjjr 1
10-15 c ctccncccccdccccxcwcc 1
7-11 f fcccqmkfxfdhznwb 0
3-10 s qssqszxqpskrwcxsss 1
3-4 f ddrwzgcmnfxfbffpdgbh 1
9-11 k kkbjfbhkkglwx 0
10-14 r rrrrzrzcrvrbrzllrk 0
6-7 s mmzwdpv 0
10-16 s sssrssgssmsszsrrps 1
2-3 h hwxh 1
1-7 n mnnnnngp 1
3-4 f ffff 1
4-8 r chrrrrvrsm 1
1-4 z nzzz 1
4-5 f ffflflff 0
13-15 q qqqqqqdqzqsbqqgqqq 1
2-8 l vxnkllwltllllt 1
14-16 n pnnfzdzwnscvnfnn 0
7-8 n nvnndthznnq 0
11-18 t tttbttstxqttrrtmtt 1
3-5 t jrgztqxsctnz 0
4-14 l qbklhcmthmllfl 1
4-18 l ncqqmclxshsfkcljlll 1
2-4 s scqskss 1
2-10 l lcllmcnllpvtlgll 1
7-14 t tttttttttttttttt 0
2-3 g gggqh 1
7-8 f mfffffffgbtsffdvvfl 0
11-13 m mjmmxmwjmjmmmmmcmmvm 1
2-5 z zdzzh 1
2-3 m tdvlm 0
10-14 c ccrccccdcccmcccbcc 1
12-14 h hhhhhhhthhhhlhh 1
3-4 s sssc 1
16-20 n nnnnfnnnnnnnnqnznnnn 1
18-19 s wssssssssssssmsssvds 0
7-9 r wrrrrrrrrlrgtr 0
4-7 f fffffff 1
4-8 g kgpgbgggmngxggwfh 1
4-9 p pfpvppppj 1
3-9 d dddddzddd 1
13-15 b bbbbbbbbbbwtbtmbwqb 1
7-9 v vvvvvvvvdd 1
3-4 l llkk 0
4-12 j thjjjfjjjjjjjj 1
4-13 m lmwmbmqvzxjhmlp 1
5-9 b bbwbbbbmbwb 1
7-8 g gvgggggggggg 0
1-3 s ssszvs 0
1-4 d tdgds 1
4-8 d rdddjdljdrd 1
5-12 m mmmmgmgmmjcxpjm 1
6-7 j jbjjjqc 0
19-20 w wwwwwwwwwwwwwxwwwwkw 0
7-10 d ddfdddddcddmmd 1
2-4 q qqqqq 0
11-14 b bbbbnbbbsbbbbvblb 1
9-12 g gggggggsgtgggggggg 0
12-17 j jjmpjjjjjhtcjhzjp 0
5-14 c rbgcpfccppccncrsc 1
6-7 d ddddddr 1
2-4 w wwjzvs 1
4-11 h frhhbknrmrhv 0
2-6 b fxbhhzhb 1
2-5 s lskss 1
5-9 p tpppdpppzfqlfph 1
2-6 c cgqqbf 0
4-9 x xxxxxxdxxmxc 1
1-2 l lllwf 0
4-8 t tpttmtht 1
3-16 k kktndqkrcfnwtkkk 1
4-6 w wwwcfnsw 1
17-19 f fffxpfffffffcfffffnf 0
10-14 l lllllllllllllm 1
5-14 j djjjjjsdvcjjjjtgjrjj 1
8-13 w dxrbwrzwtvngwwvzr 0
2-3 z zqzz 1
5-8 k kkkklknlk 1
13-18 w wwmwwwwwdwhwwxpwbw 0
14-18 x xdxxxxxxfxxxdvxxxqx 1
2-4 v qzsmvvv 1
10-11 j jjkmjwjbsjsjjjjjjp 1
5-10 x xxnxwxxxxxqskxwgpz 1
14-17 s sssssssssssssssss 1
8-12 v vvvvvvvvvvvvvvvv 0
9-20 v vvvvvvvvvvvvvvvvvvvg 1
5-6 f ffffrc 0
11-17 z vzzzzzzzzzbzzzzzlz 1
5-8 t ktwfntjtgmvpttfx 1
6-7 m mmmmmmx 1
6-13 d zdwddvmddwddgp 1
4-12 j jjjcjjjvxjjnvjqj 1
3-5 c ccccc 1
4-6 h zhhhhq 1
4-5 m mmmmjmm 0
3-5 j ljnhn 0
4-7 d qddpsdddddr 1
2-6 k dkkfsxzmnckggm 1
6-11 q pzqqdqqqnqqqtqgqsqsq 0
10-12 p hsrpgppjmpbmmv 0
4-8 f fkfscjff 1
1-3 w wwkw 1
9-16 d dddddddjdrdcddzgdd 1
2-3 h hhhh 0
9-13 l qkllllslvwpkmnlfzlll 1
3-17 f fskfffnfjszfffwfzfcf 1
3-5 q zfqsqqxqv 1
3-8 w xwjqmpvw 0
3-5 w rqffzwzdgxwjmlk 0
10-11 v vvvcvvvjvhrv 0
4-13 b bbbgbbbblbbbn 1
2-6 j mjdjlrqjjjjszqzbbv 1
5-6 k kkkgdlc 0
14-16 l lllzlllblllllrllllx 1
1-5 h wpqss 0
6-10 f gvtmdfqrhft 0
14-15 r rrrrjvrrrrrrrcfr 0
3-6 k dkkkkk 1
3-4 t ztpxt 0
3-5 g gggwg 1
5-16 t tttctthtttptttttttt 1
1-6 b bfgmbbt 1
5-7 j qhhjmjvjv 0
4-12 z xjpzjzkvzzrzwz 1
3-4 x xxxxx 0
4-6 g gbgxsbprgzg 1
1-3 q vqqgq 1
11-12 x xwxnrxxxmzxx 0
6-9 r rvvrrrrqrr 1
16-17 j jjjjjjjjjjjjjbjvcj 0
9-10 k kkkwjkrwkkkrxkkvhkf 1
1-7 v vjvvcrk 1
8-13 s sssqrsqtsssmsssss 1
5-6 p ctslhnhphlmpppz 0
1-7 x zfgmlxxxxbcsfxxclh 1
12-15 w wwwwwwwwwwwfcww 1
9-17 g gdggghjmggsggggfgj 1
5-9 s sscrspfvspssj 1
2-3 w wmltwwj 1
2-10 c ccrcjkpkccvlbckbbtc 1
7-18 t tttttttttttttttttw 1
3-8 t tttttsswttt 1
2-17 j jngjjjcjhjjjjjgjs 1
2-4 l jhlspd 0
10-20 g nvshfzjmtgsrnhtjgzzg 0
7-11 c bscccccxccc 1
12-14 m mmmmmmmmmmmmmm 1
4-5 t tttrt 1
1-2 n szbzvnlxc 1
3-7 b bbbbbbb 1
2-3 z ptpzzvc 1
7-8 r rrrxrprr 0
17-18 c ccccccccvcccccccgw 0
5-6 g qqrghgwx 0
14-16 h hhhhhrhhwghkhhhhhhh 1
13-15 g kgggxggggrgglglvgf 0
10-11 g ggpgggngggng 0
3-5 n sldjnxplwngpnsqm 1
5-12 k vkrkksdkslmsrkxtslk 1
6-8 q vdqqvqqqz 0
5-9 h hhhhhmmhm 1
1-3 r rrrr 0
12-13 p ppppcplbpfppppppp 1
1-8 s jdkssbsqks 1
13-16 j jjtjjjjjjjwjjjjkj 1
1-2 z jzzz 0
2-3 n pkjt 0
7-8 l lrdlzlqjllm 0
2-8 j jjljjnjkjzvjjq 1
13-16 j jjjjjjjjjjjjdjjq 1
14-16 q qqqqqqqqqqqqqqqqqq 0
1-5 b bqpglwpwbzzcdxhxqwq 1
11-18 q qqqqqqqqpbqqlfqqwq 1
12-14 p pppppppppppdpxp 1
7-10 x slxvrxnlwh 0
7-8 z zfzzzrbzzz 1
5-9 r rsnzrrfrrrsmlr 1
5-6 z zzzwzzz 1
12-13 f fffffcfffffnnf 0
5-6 x xbxnvx 0
11-13 v nvvvvvvvvvrvv 1
5-14 k xvgfkksvtccfvkmbkmz 0
1-6 x gxlqxxxx 1
6-7 b kbbkqbbbhxqcdpbvb 1
12-14 j jjjjjjvjjjjjjnjjj 0
7-10 f qfffgfdffzff 1
4-8 j jjjkjjjjjj 0
8-9 g ggggggggg 1
4-11 c bdkskbwctpckccbzbcc 1
2-7 s tsxlhfvtbzkkqssmss 1
3-4 m mmmmmmmmmmm 0
3-5 s zzsss 1
3-4 v vvpb 0
17-18 d dddddddddddddddddg 1
15-16 x xxxxxxxxxxxxxcxx 1
1-3 p npxrvvcgjpf 1
7-10 h hhrhhhhhhh 1
2-13 x xbxxxxxxxxxxcxx 1
2-3 c gcpckck 1
1-4 k mwkk 1
4-9 g xvbggpltgglvggmgnpxk 1
14-17 f nbfhblbmqzrmrfzcfn 0
11-13 c zkccccdcccccxcvtc 1
10-12 l lllllllllllll 0
4-5 w wwwww 1
4-6 p pwtpppj 1
7-9 j jjjjjqjjrkj 1
15-17 k krkkkkkkkkqkkkfks 0
9-10 r rrrrrrrrgxr 1
14-17 c mbwhtknbvrqrzxprcctd 0
2-4 h hlhxkhhh 0
17-18 w wwzwwwwwwwwwwwwwnpw 0
1-3 w wdjpt 1
7-16 j djjgjjdjbwdjzjjcjdjj 1
1-8 p phqgprxp 1
11-17 k kfkkkkkkkkqkkkkkhkk 1
14-15 t httttttttttttpmt 0
9-11 w wwwwwwwwwww 1
3-7 b bbgbbkbbbbbbbjp 0
8-13 t tttttttlttttjt 1
9-10 b bbbbbbbkbbb 1
9-10 q qqqqqqqqqs 1
12-13 p prpppppvpppkhp 0
2-4 s swsvs 1
8-11 j jjjjgjcjjngjfsjs 1
2-8 r rsrrrrrlr 1
4-9 j xsfvbjdmj 0
13-14 b bbbbssbbbwjqms 0
9-10 m zxmbtjhpmhwx 0
3-4 v fsvvdv 1
17-20 w wgwwjqdwwwfgsrwwwsgw 0
8-10 t ttpttttttw 1
3-8 t mxptddtdttb 1
9-10 v vvvvvvvvtd 0
12-14 q qqqqqqqqqqqdqj 1
1-2 n cnnn 0
14-17 z gzzwtvhzgrzxzrxxhcz 0
3-5 c clccczc 1
1-13 t gjbzdcntxhfmg 1
1-6 z zdmsjnz 1
6-7 j jfjjnrjjj 1
13-14 h hhhhhhhhhhhhrth 1
2-5 x xxqxxt 1
3-8 w wwwhwwwwwrdpww 0
3-10 n nnnnnnnnnnnnnn 0
7-13 l llfllmlslpslltll 1
4-8 w wwwwtwwmkw 1
7-8 t ttttttkrcwq 0
3-6 g cxwmbgmxg 0
12-13 b bbrdbkbmbvbbb 0
1-16 d dsndtgbmdrdxbddddjdd 1
3-11 g gggjwgrggzxmxbgg 1
11-18 s ssbscmdbssksswksss 0
13-15 s svsssssslsbsssssssz 1
5-12 n nnnnmsnnnnbz 1
5-8 g ggtgfggsgggggggggggg 0
2-3 c kccc 1
14-18 t ttttttttsttttttttt 1
3-5 r rrbprp 1
5-7 s jszjsgsxtzkspgs 1
11-12 m mmmmmmmmmmjm 1
6-10 q qqcqqqbqqp 1
5-8 s ssjszwsts 1
5-6 x xxxxsl 0
15-20 k kkkkkkkkkkkkkkkkkkkk 1
13-14 s sssgssrpssssszss 0
3-6 v zjxcgdvswnfvvvv 1
5-6 m mmqmmm 1
5-10 t ttttttttltt 1
2-4 d qsdvsgtd 1
2-11 t btttbttznrctwwnltvnt 1
6-16 b rgkcwbcnrdbrqvqbbq 0
2-13 j jjjjjjjbjjjjj 1
17-18 j jjjjjjjjjjjjjjjjjj 1
9-16 v rvvvmvgsvvvvvhjvvqs 1
4-5 d wldddd 1
2-13 v mvvvvvvdvjvvvr 1
6-7 s sdssfpwsskqbq 0
12-13 m mmmmhmmmmxmmmm 1
14-15 j jjjjjjjjjjjjjjj 1
2-13 d vddnpddsdpddd 1
3-5 g gkgggks 1
14-15 g dwggggggggjvgkgqgggg 1
10-11 n nnnnxnngrxhnn 0
3-6 r rnrnrr 1
7-13 k cpmxcndgssktpkkpfkk 0
3-7 s sssssss 1
6-10 b nrbmbbrhbfrbnn 0
8-9 l lllllllft 0
6-8 x xnxxkwknxlxxbbx 1
1-16 f fffzkffffknfrfqqf 1
5-6 v jvvvvvvvppvt 0
14-18 n nnnnnnnnnnnnnknnnb 1
5-16 n ncnnnsvlpndnkvvrcf 1
13-15 j jjjjljjjjjjjqjj 1
4-7 s qhrhsdbsmmlstznms 1
5-13 m kmmctmsmmmglzxm 1
14-17 s ssssssgsssszspssb 0
13-20 x sjxdxqcxxxxqxkxxxxxq 0
7-9 f ffjfffnjnff 1
10-11 m mmmmmmmmmmxmmm 0
3-5 q qqbqc 1
14-18 f tfkfrbbznftcfftbmfxf 0
1-15 l lclwqxcczgnktqltm 1
9-12 g fgggmgggfggm 0
16-17 t mntvzrcdttplrfzkv 0
3-5 n nngnp 1
3-6 s gsxznsssbbtsl 1
3-4 s hsssv 1
10-11 m smmmmmmmmmnm 1
11-15 k kkkkkkkkkkkxkbkjk 1
8-11 x xxxxrxkvmxlxwp 0
2-5 p pppbbp 1
11-13 b bbbbvbbbbblbrdb 1
9-16 w wwgwwwwwhwwwwwws 1
9-10 q zqqkqvqskqqzzqcjqq 1
4-6 j jbkjnjddjhjhjqbxpzf 1
2-3 c ccrccz 0
15-16 r rrrrbrrrrrdrrrrrr 1
2-5 x xxqrxwrchhd 1
6-7 r rrrrrrkrr 0
5-6 h hhhhpq 0
9-11 s ssssssstsss 1
1-6 k ctprksgrdgkg 1
7-8 k kkkkdkkkkk 0
1-4 l mllt 1
5-10 b bbbbbjbzzbbbb 1
1-2 c cczfkcmsdnghcnmhvx 0
12-16 z zgzvzzzzzzzzzzzz 1
13-14 k kksmtsrkrwxkkk 0
10-12 q qpqsqqqhqslqqnnqjqqg 1
4-15 q zgppzlxqvrdvnkkgnr 0
1-4 b dbjbk 1
5-9 c cccclcccpcccvc 0
2-6 t ttctdtdtts 1
2-3 q pqqtbwkr 1
12-15 v vdvvlvvzvvvgvvv 0
2-8 c ccbcbcbncxxgcngrck 1
2-4 z cnzzt 1
3-4 j jjtrjj 1
6-12 x xxxrxqxxxqxxkxs 1
5-9 r rqnbnrrnnrwhdrr 1
2-5 s smssk 1
4-16 g hgzjhgggcgnwddkq 1
4-10 l jlgxxlgllql 1
1-5 r rrwgrrck 1
1-11 t wtttttttttrtttttttt 0
5-9 n njnnksntk 0
5-8 s ssssswsss 1
2-4 q qqqq 1
1-9 b jqmxlrdbbbfnwtlqjbbf 1
3-5 g qhgsgpjdphghhjwqx 1
1-4 d mddd 1
4-6 q qsqqqqgqqg 0
9-15 f ffffxffrffwfffffff 1
2-6 z zrzshvzlzkxzp 1
7-10 s sppscfwscfsszbsf 0
5-19 r drwrmrvprrrdrrrrrkv 1
9-10 n nnnnxnnnnr 0
4-10 m mmmmqmcmlmvmm 1
10-13 v wcnzkqgvvgxldxl 0
9-11 k vclfkkfcdbwwk 0
12-13 r rrrrrrrrwrrfh 0
7-8 s szsssswfs 0
4-6 z nzzjzk 0
5-7 w ghwwdrr 0
2-10 x xxnxxxwxxsx 1
9-10 b bbktbbbxhfbpb 0
643

Damn it, still too high. Hmmmmmm.

FINALLY!!! 643 babeeee.

On to part 2.

B

Problem

While it appears you validated the passwords correctly, they don't seem to be what the Official Toboggan Corporate Authentication System is expecting.

The shopkeeper suddenly realizes that he just accidentally explained the password policy rules from his old job at the sled rental place down the street! The Official Toboggan Corporate Policy actually works a little differently.

Each policy actually describes two positions in the password, where 1 means the first character, 2 means the second character, and so on. (Be careful; Toboggan Corporate Policies have no concept of "index zero"!) Exactly one of these positions must contain the given letter. Other occurrences of the letter are irrelevant for the purposes of policy enforcement.

Given the same example list from above:

1-3 a: abcde is valid: position 1 contains a and position 3 does not. 1-3 b: cdefg is invalid: neither position 1 nor position 3 contains b. 2-9 c: ccccccccc is invalid: both position 2 and position 9 contain c.

How many passwords are valid according to the new interpretation of the policies?

Solution

Okay, I can reuse some code from part A here. Namely, the parsing part (which I should break out into its own function) of the spec.

#+NAME:solution-2b

  (defun test-pw (spec password)
    "Return whether a PASSWORD works with the SPEC.
      PASSWORD is a string.
      SPEC is a string of the form <min>-<max> <char>."
    (let* ((split-spec (split-string spec "[ -]"))
           (min-string (car split-spec))
           (max-string (cadr split-spec))
           (chr-string (caddr split-spec))
           (min (string-to-number min-string))
           (max (string-to-number max-string))
           (chr (string-to-char chr-string)))
      (if (xor (found-at chr password min)
               (found-at chr password max))
          1
        0)))

  (defun found-at (item sequence position &optional eq-func)
    "Determine whether ITEM occurs at POSITION in SEQUENCE."
    (let ((eqf (or eq-func #'eq)))
      (if (<= position (length sequence))
          (funcall eqf item (elt sequence
                                 (- position 1) ;; careful -- the spec's 1-indexed
                                 ))
        nil)))

  (let* ((strlist (split-string input "\n+"))
         (alist)
         (valid-count 0))
    (dolist (line strlist alist)
      (let* ((splitted-line (split-string line ": "))
             (spec (car splitted-line))
             (pw (cadr splitted-line)))
        (if (and spec pw)
            (add-to-list 'alist (list spec pw (test-pw spec pw)))))))
2-7 b fdbvbdb 1
5-6 r rrcrvmr 0
18-19 m mmmmmmmmmmmmmmmmmmm 0
7-17 n mqhnbwxnnnmcdlkfq 0
5-8 k kkqkkkkkk 0
2-4 v vvjnrxnvtdmm 1
7-10 m xmxmmwtmmmnvcrmkrmmm 1
8-9 f fffffffff 0
3-5 q qqqqvpqq 1
6-14 c cpcccgcddfzcgcccc 1
1-5 p zpppxbmj 0
2-3 s vxgv 0
5-11 x lfxzxxcxxxxlbwnrx 0
13-19 f ffffffffffffgfffffnf 0
1-6 q zvqqqmzqqt 0
2-10 w wvwwwwwwwwf 1
12-18 c ccccccccftccccccccc 0
11-14 m mmmmmmmmmmmmmmmkmmm 0
6-7 j jjzjthj 1
7-10 g ggggggfggg 1
4-6 n tnnnpnn 0
3-7 f frfshbfn 0
11-13 s ssssssssgsssss 0
15-17 s sssbsssscsssfssspsg 1
6-7 x xxxlqwlxxvnnvvc 0
3-4 h hhhjq 1
3-5 p cpprxp 1
10-11 m mmzrmmmmmmmmm 0
5-16 x xzxpxxxxjxqxxqms 1
7-9 m gmmrtzmmrmmcmm 1
3-4 m qmmjmm 1
1-5 z zzzvzzz 0
4-7 n nnnsnnnnnnnnnnrnn 1
3-6 l vlljlbllrbztnl 1
1-3 j jqjj 0
13-15 x xnxxxxkxpxxxtxwx 0
6-8 v vwqcvvvvvvsvvxjv 0
3-4 b bdvbdwrgcbpwblj 1
9-12 h hhhhhhwhthhhh 1
7-9 k kkkkckkkck 1
9-10 v vvvvvvvvhw 0
1-7 r lrpcfdfksxrh 0
3-4 r grrrr 0
4-6 b bbtrbbbb 1
1-2 f kfhf 1
1-2 s ssst 0
1-4 s sqss 0
5-7 z gzzzzzzjz 0
2-4 s jjlm 0
8-10 h hhhhhhhkhc 0
2-4 c wccb 1
3-7 q qjxlgqd 0
3-9 m mtmxsdmmzsmlc 1
12-16 m mmmdmmmmmmwpmmmlm 0
14-15 d ddddddfdddddddj 1
7-8 k kkkkkkkb 1
1-6 d qddddd 1
11-13 b bbbbbbbbbbbbdbbbb 1
5-11 x cxxzvxglxrbbqqcxf 0
5-8 f zhfglzmkfnqmbbtffftf 0
5-7 s zwldstwxsh 1
3-4 w hwww 0
1-6 r xrrrrprfl 0
10-13 c cccmccccccccpcwcc 1
11-12 m mmmmbmmmmmmm 0
19-20 w wwwwwwwwwwwcwwwwwwqk 0
3-4 g ggsgq 1
3-6 l xllhplwhllllzqbkll 0
1-15 p splppplppprppcppppdp 1
5-9 s sfsslssss 1
4-5 r ktkwwzcrv 0
4-8 t rttttttt 0
2-4 x xxqxx 0
1-7 n nttvqnn 0
7-11 f nfqdgffmwlfc 0
1-5 x xxdxkxxxxgx 1
2-4 v rvpvsvfft 0
6-8 c jjcxcjnccclc 1
4-9 n zswmtrnlspnxdnbnbvln 0
1-8 f fffffsngffczj 1
14-15 j jjjjjjjjjjjjjbw 0
10-11 l lllllllllqrmllkllvl 0
1-5 n bzvxn 1
3-6 z zzzzzhcz 1
1-4 g rgfg 1
11-12 b nbbbhbbbgbhbbglqbbm 1
2-5 f hffrfm 0
2-7 p npnfpswbhsbgknmvlgmx 1
3-5 d dmqddv 1
3-15 c mcvccvccccccccd 0
8-11 k dvhvwdpkbdnwn 1
11-14 q qqqqqkrdqxjfqcqpqqqs 0
2-9 l klgblptpqzdp 1
9-10 s sssssssscrsz 0
2-4 d dsdwhnj 0
8-11 q kggqvqbvwfbqlv 0
8-10 l qlrjglllxl 0
1-3 w tcvttwhsjpzd 0
2-15 h whxfjxtcxlwxchb 1
6-9 x xgxdlxrgnfmsmfxcwx 1
1-18 r rvzjrgfrkrxrgbrdlrr 0
1-2 d dxbd 1
5-6 h hhbhhh 0
16-20 v vzvhjvbvvtvvvvvvvgvh 1
7-11 x xxxxvxxxqxf 1
19-20 v vvvvvvnvvvvvvvvvvvvg 1
3-5 c qjfndkck 0
5-14 g tggjggggggggggmgz 0
16-18 c tcccccccctccccctcccc 1
3-5 g tpgwjrr 1
2-6 b frbbbtvb 0
10-14 r rzrnvtrfkrrrvjrr 1
5-6 k kllvds 0
3-4 x xxxx 0
4-11 v vvmzvvvpvvxk 0
15-19 r rrfrrrnrrrrrrrrrrrr 0
6-7 v vvvvvpz 0
4-6 n nnnnnnnnnnnxnnnnn 0
1-3 j zjmjjjj 0
1-4 f zmnffhprzvrbhz 1
2-7 z czzzkzzzrz 0
9-15 g zggnmghgggrggxqzj 1
1-6 g hzcpck 0
1-10 t bsptvbqtctmwtztgtwt 1
5-10 v vrvfvfvvwnvs 1
11-13 k kkkkkkkkkkkkk 0
2-10 g qgpbkxdpggfglbpvn 0
4-5 t htkntst 1
2-3 z qzbr 1
2-3 s wsfdwh 1
13-16 t tdttqxtttttttttm 1
7-8 s ssssspgsqs 1
4-6 t ttthtn 0
2-14 c wkdjtjxccwvzwbgr 0
10-12 p pgpprmwwczxjhpvpqmpp 0
4-6 w fpbwwwwcwprflnjtwl 0
15-16 n nnnnnnfnnnhnnnnnn 0
14-15 n nnnnnnnnnnnnnnn 0
1-9 c gscmdrvngstmfknsjrp 0
8-11 q qqqqqqqqqqkqq 1
17-18 r sxrnvrtswzzzwwrdrt 1
1-4 w wwwv 1
2-4 l xlwsrlclpql 1
3-7 f fffkfffnkdff 0
1-4 w lwnwj 1
6-7 b wbbbbbx 1
2-7 s dshmwzsspls 0
8-9 p ppppjvwlpd 1
17-19 k kkkkkkkkkkkkkkdkkkhk 1
4-12 k kkkqkkkknknv 0
1-2 n nkwj 1
6-7 s gsvwsjsgssbss 1
2-4 r hrmrtrs 0
2-3 c kcgcrbcqk 1
4-5 r rrkrr 0
2-3 n vntn 1
7-8 r rrgrrrrr 0
3-6 q qrdqcqqqq 1
5-6 k xpkkkk 0
4-8 c pknvllcbxxcs 0
8-10 q qczgcdqbqlqlzqq 0
2-4 d ndhdsddzq 0
9-12 g gggglggjgggggg 0
7-9 m mmmmmmmmm 0
7-10 v rpvvnzpcccvvhvbvvtz 0
16-18 v vvvvdvvvvvvvvvvlvm 0
9-11 q sblqqbqqglfqlqfzqqld 0
4-7 b bstmbbbbbmgtqm 1
3-17 m mmmmmmmmmmmmmmmmg 1
2-10 p ppjppppplpp 0
9-10 b bnphxrvfbjx 1
5-7 w wwwwhwtw 0
2-4 b bzplb 0
7-10 v vvcvvvcvfzn 0
8-9 r rrrrrrnjdr 0
1-3 s ssss 0
3-8 c ccccccct 1
5-11 r wrrrdprrrrn 0
7-8 g mrggggfg 1
4-5 j jtwsspjj 0
6-15 k nqkkkhkkkkkhkkkkkzkk 1
16-17 k kkfkkkkkkkkhkkkkp 1
6-7 d jdddfppddvdmds 0
2-3 b gbzzqdvhpbvfgh 1
2-4 h wshlhh 0
3-11 m hmcmtmqmxcmm 1
12-15 x pxxxxxxxxxfbxxx 1
5-6 j jjjjjj 0
14-19 g zcggccgvgpjghznmvgpg 0
1-2 b rkpbg 0
1-4 t rrjg 0
3-13 n nvpnrnjnnnqnnmnhlnx 1
2-3 b bmzb 0
6-8 l lxlllklll 1
5-8 n qknnnfgn 0
14-18 k wkskkkkkkkkkkkkkkn 1
1-10 f pmtffffjfgkfpjm 0
10-11 c ccccxccccbc 1
10-13 g ggggggqgxphggcg 1
8-14 b lbdvsxcbzvfltl 1
2-7 h hhhhhhh 0
17-18 q qqqqqqqqqqqqqqqqqq 0
2-4 h vhthh 0
6-16 m mmrmlzdmzxnpmhmhmmfm 0
15-17 f sfsffffffffffffxnfff 1
4-7 d drkkhrd 1
11-13 x xxjxqxxxpxwqxxxx 1
10-11 x xjxxxsxxxfxx 1
5-6 z zmzjznzkxzr 1
3-10 l rszlllgzbvlll 0
4-9 s dslxngsjssxpsssgss 1
3-4 j jkjj 0
4-5 x cdxxx 0
2-4 v fpvvpv 1
1-6 k kvxbkvmdmgdmkhkwq 1
9-13 v nvmzrnvvvqvvvgvvvtvv 0
3-8 q qpnqjptfrqxtdncqbg 0
4-5 z zztzz 0
11-16 v vvbvvvhvvvvrvvvv 0
14-16 k kkkkkkkmkkkkkkkk 0
17-18 g gggggggggggwggggtfg 0
4-8 q qqqltrkqzqqxqc 1
6-9 w wwjwmtwwfjs 0
8-17 p fppppbppjpfpppzcnp 1
3-13 b bbbbbbbxbqbbf 1
14-15 f ffffjffffztfffzff 1
2-8 d pzdrzhdddpd 1
9-10 z bnzjzzzzzz 0
3-4 p hpbpppnxppk 1
10-11 h xhhhhhhjhghh 1
5-10 m bqhbgmpmmhmwhmmm 0
8-9 m mmmmmzmmmmm 0
4-12 r rrrcvrrrrwrr 1
3-4 l klzl 1
14-17 l llllllllllllldllcll 0
3-7 l llcllllllll 1
3-5 s hdkshswvlmg 0
3-5 f flhbfkbfmf 1
2-3 c cxrwvncfl 0
16-17 l llllllllllllllllrl 1
13-14 z zzzzzzzzttzzzzzz 0
2-9 f sfprndvdptlfdwh 1
3-15 l dpxfgtznlgmptjlxhzl 1
8-9 c cchccccwc 1
8-9 z zffzzzzxzzz 1
3-4 r rrrj 1
8-11 q dcqqmnqqzqqqqqqqq 0
6-8 f jxlfvnrwt 0
13-17 j jjxjjvnjjjjjhjdjpjpj 0
1-5 s pvqqhnpvcmxrwsspvnw 0
5-12 t tdtslpttttvttgtkkt 1
14-18 l bscmdvlczsgljvlbllwp 1
17-18 w wwwwwwjwwwwwwwwwfj 0
8-15 t tttttttvttttttjttt 0
10-19 m lrzzlvfncmpplqbmxhh 1
6-11 k spgkkxpmtkbdkmzn 0
12-16 t tltmtttwzjtssmtt 1
11-13 m mmmmmlmmmmmdmm 0
12-16 w pgwllwwwwwwwvtwwww 0
11-15 c cccccwcxcccckccccccc 0
2-5 p jhxcptzrpfsrxj 1
5-6 p ppppxc 0
2-4 k kkkk 0
4-6 v bjtvvv 0
2-8 m rttmqfkvjgq 0
9-10 x xxxxxxxxxj 1
4-18 v hvvvvjqvvvqvtjmvfvvf 0
7-14 x xxxpxxxxxxxxcn 1
4-8 r rrrmrrrz 0
8-9 h hhhhhhhhl 1
6-9 m bzmppmqjdmhmgmmdm 1
3-9 f jmhkffdhsdsf 0
5-12 n xnnhkdpmnjnzqnc 0
10-12 l lllllllllplt 0
10-12 k kkkkkkkjkzkk 1
11-16 k kkkkckkkkkkktkknkkk 1
17-20 f ffffffmffffffffffxff 0
4-6 z zzhzzlg 1
17-18 q qqqqqqqqqqqqqqqqcx 0
9-11 j jjjjjjjjwnvjkxj 0
6-8 c cccccccc 0
3-7 m mmkmmrdmh 0
2-7 x rmbftbcmcxxxxpttzjwb 0
1-7 w llvwjdjvtp 0
1-3 p fpmp 0
6-8 b bbbbbbbbbb 0
2-5 t tttttt 0
2-8 l fkxzlkdlmlllnwhlt 1
10-12 g ggxgghbgzxztg 0
3-7 s sgsnshspt 0
4-9 d gsdhddtjdjg 1
3-20 v vpvwnvrtvbvkdvnvvhrd 1
2-4 r zrcwpcrfm 1
2-7 k kkknkknkjk 1
4-7 x xhxxrmx 0
6-9 z qtzhzgvzfzkgzzsfz 0
3-15 x klxxxslhpzwvfbxxlx 0
2-4 w wwwgw 1
2-4 d xcdn 0
8-10 d dddddddkdr 0
17-19 s mssssssslsssssssjsq 0
14-17 c ncccccckccccccccqc 1
4-7 x xpzrmmjxxnxlxxx 0
5-10 h hhnhhghstmtcq 1
1-4 t txctqzq 0
2-4 d ngtbkhcdwgd 0
1-5 j jjtnj 0
5-7 c cccpcchcsmlhc 1
2-6 n mxnnfnx 1
2-3 w wwwrwsw 0
3-7 n znfdhbn 1
10-12 p pppppppppdpd 0
4-10 f fffxfqtffff 1
7-11 s sssssswsssrmb 0
11-13 j jmjvjjjjjjgjw 0
4-13 l lllcllllllllllllllll 1
2-4 p pfppp 1
7-8 k kkkkkkxf 0
3-6 t xjbhzxtttb 0
3-12 t ttfxjgttsntkxznct 0
4-5 c cmccbcg 1
12-14 w tkwdwwbtqwzphmzklrwk 0
12-16 g ggggngrxhgghgggggtgg 1
12-13 d ddvddfddjdddmqvdkdmr 1
2-12 z hnzdxfzxpwzzz 1
1-7 h hdhlhhfhh 1
4-5 g gglglx 1
2-10 m mmmmbqrmqmhmqm 0
10-13 l mzlhlltlllllrcl 1
14-15 c cccccccccccccgzc 0
5-9 b bltqmxbsbbvdpvsqkpk 1
9-15 k kckkkktskrpkkqkwklvk 0
3-6 j jjjjjz 1
1-2 q qkqqqqq 1
7-8 p ppgpppppblrp 0
6-8 x xxxxxxxx 0
5-9 k rkkkkdtkmkjkdr 1
15-16 j jjjjjjjjjjjjjjjp 1
13-15 b bjbbbwbbbbbbdbbbbb 1
6-9 x sxjxxxxxx 0
3-7 q tsvrqqmdlzxs 0
7-10 t ttchcttwvtttftrtt 0
1-3 j jjjjj 0
1-7 h wpltchhcxwhkg 1
4-15 h hhhhhhhhhnhhhhthhhhh 1
6-8 t jdlgtttpq 1
4-5 t ttttt 0
2-4 n nvntn 0
8-10 m mbmmmmklmw 0
4-5 x xxxfp 0
5-6 n qnrsvnvrnnn 1
14-18 f fffftmfffdfffftfff 0
6-10 q qkqqqpqfxq 1
3-5 s mjdsssssssssmss 1
10-19 x xxxxxxjtxxwxmqswxxx 0
1-4 s srstdtspcrqqgqsl 1
6-15 g ggggggfggbsplggggh 0
1-4 q vdqgqwhg 0
18-19 h hhhhhhhhhhhhhhhhhhh 0
14-18 v vvvvvvvvvvvvvvvvvv 0
3-4 z zbztzgfbcf 1
1-5 h dhrhjd 0
10-14 f tcpfzmffffbffvpfff 1
8-10 f fffffvflgfq 1
8-9 q klqpmdtqqcmlnftrn 0
6-7 t tbvtbtkjt 1
3-9 s bgldhnxsksznscnlnhc 0
1-13 g cgggggggggggv 0
5-13 b bbbvbfbbdbbhb 0
12-15 m mmmcmmmsmmmqgmm 1
2-4 m bmmh 1
1-7 q jppwfcqmvxjqxdf 1
14-15 r rrrrrrrrrrrrzbj 0
3-5 r rrrrg 1
2-5 z zgzwlz 0
1-11 h hhhhhhhhhhhhh 0
2-5 z zzzzh 1
10-11 c cccccccccmc 1
2-4 s brkfmk 0
5-11 l lslqdpbvslplll 0
7-9 f fffbffffg 1
14-18 m mjmmrmmmmmmmmtmmmd 0
4-5 f ffzcl 0
11-12 q qnrqlqqqqqqcqqq 1
4-7 k rkkkkkk 0
7-16 c cblsccjzgccccccvcc 0
15-16 z zzzzzzzzzzzzzzzz 0
5-6 c cgcccfj 1
4-5 q qqqqq 0
7-11 n nngqrnnnnnhnj 1
8-11 q qtwqqqcbqqhqz 0
7-8 x cvtxzlxxvls 0
6-7 l lllllshl 0
16-18 g bjkzbdrfjsnbldggwrqj 1
2-3 c lcwrncsjwzss 1
2-9 x dxxxxbxxx 0
6-7 c xccwxqcscczcc 1
8-9 x xxxxxxxxx 0
13-14 n zgpqjvrsbsfgnn 0
6-10 t tttttttttttt 0
7-13 b bpbbbnbbrbbbh 1
3-4 x xkxx 0
2-4 r nrvvxsbrhghrrtr 1
1-7 z gwzdzzhzzzzzz 0
4-5 k lrqkkkqf 0
1-5 j vnqpwg 0
3-5 x xmxxxxxx 0
9-11 d ddddddddddc 1
8-12 s sssncsjspkxssssshs 0
11-12 g ggggsgggggxkp 0
2-10 x pxdcdsxdsxjmx 0
3-7 n ndnvmnjl 1
9-10 j jjjjjjjjstbj 0
5-10 l llllmlljlb 0
10-11 z zzzzkzzzzzs 1
11-13 l llllllllllvlm 0
3-4 g gjgggdgpwd 0
1-4 r krrz 0
16-17 s gjssssrhksfmdssssw 0
7-10 c qpljmtcclfqc 1
4-6 l slrklplgsl 0
2-8 c cscccccbc 0
7-8 m mmmgmmnpm 0
12-16 w wwwrwwmwwwwwwwww 0
11-12 v vvvvpvqvvvvvvjv 0
15-16 z zrzzkzbzszdzzzzczzzz 1
16-17 l tfhpllgsrlvlbvncl 1
8-11 h hhhhhhhhhhhh 0
4-5 l xllcv 0
5-9 r rrrcrgrflqh 1
16-17 q qqqhqqqqqqqqqqqqqqq 0
2-4 z zlzqh 0
7-12 p vnrftmwdphrzxjv 0
3-11 d ddpddsddmddddd 1
4-6 k lczkck 0
4-5 t ttttvt 1
2-12 k shkkkjtxkkklkkkk 0
12-16 v vfvvvvvmvrvzvvzvvv 1
2-7 k kkkkkpk 0
6-9 v vvvvvgvvv 1
8-9 s ssssssspws 0
3-12 m llmntmzdjnhmcbmm 0
3-5 r rxrrt 1
11-15 z zzzgzzzzzzzgzzz 0
8-11 v vvvvqvjnvvgmvvtv 0
2-19 n njnnnnnnnwnnnnnnnnk 0
16-17 j jtjjjjjjjjjjjjjjs 1
1-5 j jjkjjqdjjjjpjjjjjj 0
2-7 c cmctjltcz 0
4-10 b tbgbjnqbbbtcbb 0
6-10 s sfsfqnsfslsfssssst 0
12-15 b hjjqbxwbnbbbwbfl 1
5-8 q cgcjjbtq 1
3-4 q qqdd 0
4-5 s ssbnbss 0
8-10 t dmtjzvjttxttrtftt 1
1-12 c kccccccccccccc 1
6-10 f fwfffcdfffsf 1
6-9 c wchcccccccccccc 0
8-14 w zwxrgcbjbqwghhbwwb 0
8-12 h hhhhhhhchhhnhhhhh 0
3-4 f ffpd 0
8-16 j fgnjtlhjjgknmbbj 0
3-4 h hhhh 0
2-3 c bdrc 0
7-9 w lwvwjwwwwwww 0
5-6 j vwktnjjdhjsvndjjjsfj 1
6-9 n nnnnnqndv 0
8-16 b sqbbbbbbbbbblbbgbbxp 1
3-7 c wdccccccdgscgcq 0
2-4 t tttt 0
5-9 h mhdjxshhhzlp 1
9-12 l lfvclqlrlllvllzl 1
3-4 t xttt 0
5-7 p fndppppdnpp 0
10-12 f ffffffffffft 1
11-15 b qbbbhjbgnbbzvbk 1
1-8 k vvdsktqkfkdqlhbwrkqc 1
9-13 l llllllllflllsll 0
6-7 b cpbgbkq 0
4-5 g tgfpgksglmcg 1
5-19 d qvddqzdddddddsxpdgdd 1
1-5 s sssss 0
1-12 g xkxgggggsgggggdgg 1
2-6 n vwbttnnnnsnbnhnnnm 1
12-13 r rrrrrrrrrbrrdrrr 1
2-4 l hlllgdxltwllwn 0
6-7 v hvvvvwpv 0
8-9 p ppjpppppp 0
6-7 v vvvvvkv 1
5-9 z zzzzrzzzzzz 1
14-16 g ggggggggggggrgggg 0
3-4 v fwhvvv 1
3-5 c clcccc 0
9-10 c ccqrkcccpcckc 1
15-20 j jjjjjjjrjjfjjjjjjjjj 0
7-10 v vvvvvvvhvvv 0
2-3 l lwkl 0
3-4 x vgfwxx 0
2-5 w wwnww 0
8-12 b tmkmhnhblmhbxdvqb 0
3-10 c ncccvmmcccxkrrcspjc 0
14-16 n nnnnzhnnnnnnnrnrnnn 0
13-16 t fttgrdcdttttnttttdtt 1
6-15 w wwwkvwwwwswwwwwwww 0
8-9 t zpsltttvv 0
8-10 r rrrrrxrbrr 1
5-12 t gpcttsvjnqkt 0
2-3 c cccm 0
1-9 l spnvxwwlmcmpd 0
7-11 b bbbbmwhfbjb 1
3-5 v vwvvvqwv 0
4-5 p xlpppp 0
2-5 q mqqsq 0
11-16 x xxxxxxpnxxxxhxvxh 0
5-6 n vqtnnk 1
1-16 m mmzmlmmqmbwmmmmm 0
3-5 c ccbgp 0
6-18 b djrsdpkhrnfkmgkxqb 1
5-6 k kkkhkjfbbkxh 1
13-16 s ssssssssssssssshss 1
13-16 p ppppwnpcpppwppprp 1
1-4 p pgnpjtbzdlh 0
7-8 j jjdjljjjghnjmbqjb 0
4-13 g lgqkgpfgklggxznk 0
6-7 g gggggtz 0
4-11 d tngdgqrdddtvgdq 1
12-13 r rrrrrrrrrrrqz 0
2-11 j jkjjjsjdbjzljcpjjmj 0
8-10 s sssssssksc 0
5-7 n fvpfwnn 1
4-7 f ftfffffjmmhz 0
3-4 d ddsz 0
1-6 h hhhhhwhh 1
5-7 x xxxldxxxx 1
3-4 k rxtk 1
9-10 b bbbbbhbbbb 0
2-4 m mmmb 1
1-4 c xdfp 0
11-12 w swwwrwwwwwwwwwlwl 0
9-10 b cbbbtbbbdqsb 0
15-16 r rrmfrrrrrrrrzrdsgrrc 0
6-7 p pgppptp 1
1-4 m mdmj 1
10-11 p npwhgtcgwpptxnpztxn 0
1-3 k tkgl 0
2-6 j zjjsljzdppjhjrq 0
13-14 j jjjjjjjjjjjjpr 0
10-12 q qqqqnqqqqtqq 1
1-8 w wwvwrwfwlwww 0
12-19 s sgssssqjssssvhssscts 1
2-6 x rxjvbxrxxcsthxl 0
14-15 m mmmmmmmmmmmmmmm 0
7-11 g gggsgglsgpf 0
4-6 j xjjsjc 0
19-20 s ssppfsswtssqssxlbsls 1
3-8 p vppjpkppx 0
10-11 j jjjjjjjjjcj 1
12-14 l lnllldllllnllxlllll 1
13-17 g sgvggggbggggqbggfggg 0
17-18 z zwzzzzzzzmzzzzzzdsz 0
7-10 r rrkrrrrrrr 0
2-7 k kkvpkqlpkknkkhmb 1
1-2 t txvt 1
5-9 h hhhlbhqhljmhh 0
2-5 r crhvhfrlfbzmcqsxcr 1
6-7 s ssssjkstsh 1
5-10 n nnnnztnjnn 1
3-10 d qcddgpncddwdnldjzd 0
10-14 r rrrtrrsrrrqrrr 0
15-16 v vvvtvvvvvvvvvvqv 1
2-6 n nnjnctjqnj 1
1-8 v vvvvxvccnvv 1
4-5 z xzzqzzz 1
3-6 q qqcqqb 0
2-8 k kkkcjczlblwgm 1
2-7 t rtvqwkqdpjcfttvntpm 1
3-5 h hhhhh 0
2-8 p dhkfkvqp 1
9-12 q kfqqqqqxlqgbrvqvqwq 0
7-8 q qqwqqqqq 0
7-8 k kkkkkkmk 1
2-4 m mmmjmmd 1
4-5 h hpzhhhvrtdrqd 0
1-3 j mjjjj 1
12-19 k kkzkkkfkkkktzkkkkkbs 0
8-9 m mmmgmlpvgdmmdnm 0
6-8 c dbsgwppccnwf 1
11-12 h phhhhhhhhhhkhg 1
2-3 b bbhbzgvd 1
5-7 r frlkptm 0
7-19 d rxddghsddsrpdxxdddd 1
4-7 v vcvhvtr 0
4-6 k ctdqjk 1
2-6 s gffhkvzs 0
5-6 k kkkkrqg 0
4-6 q qqqjzq 1
13-15 j jjjjjjjjjjjjrhj 1
1-6 z xwzkzz 1
7-9 x xxxxxxxxxkxxxxxxznxb 0
3-4 t jthdftcsfqt 0
3-5 c cgfccgc 1
5-11 k kkqkkkbkkkwkkk 1
5-12 k kkkkkkkkkqkc 1
2-3 z bpxzxchzzzz 0
4-5 z zjzzwwz 1
4-5 k kkkkts 1
18-20 d dndzzcdgldkmjdvvdddz 1
14-15 h hhhhhhhhhhhhqhksd 1
2-9 h hhhhhhxhnh 1
12-13 c cccccccccccsx 0
3-6 t qsdptbvtjhcjvjntwdnx 0
3-4 q qqqqq 0
7-8 v vvvvvvcvvvv 1
10-15 g ggggnrgggggflggg 0
6-11 h hfdzhwmhwhhhgvx 1
4-7 g qkggvgggwgfgfgn 0
4-6 t tttvtx 0
4-14 s sdgsssgqlqwjszkcgsz 1
6-10 g gggggvgngfgg 0
5-6 f vffffff 0
3-4 l nlllwlmlf 0
1-7 q qrrhxlq 0
12-15 m nfdmhmkqpgcmnxmqcvn 0
3-5 s sxrcsm 1
15-16 l lllllllgllllllsl 1
5-6 x xbnxxxxx 0
13-14 p pppppppppprpdj 0
4-5 x xxxxr 1
11-19 f krfxmnqfhfqfksfzrgfm 1
9-13 d ddtkddlkddddbdttr 1
3-6 j vjzmjjr 1
10-15 c ctccncccccdccccxcwcc 0
7-11 f fcccqmkfxfdhznwb 0
3-10 s qssqszxqpskrwcxsss 0
3-4 f ddrwzgcmnfxfbffpdgbh 0
9-11 k kkbjfbhkkglwx 1
10-14 r rrrrzrzcrvrbrzllrk 0
6-7 s mmzwdpv 0
10-16 s sssrssgssmsszsrrps 0
2-3 h hwxh 0
1-7 n mnnnnngp 0
3-4 f ffff 0
4-8 r chrrrrvrsm 0
1-4 z nzzz 1
4-5 f ffflflff 1
13-15 q qqqqqqdqzqsbqqgqqq 1
2-8 l vxnkllwltllllt 1
14-16 n pnnfzdzwnscvnfnn 1
7-8 n nvnndthznnq 0
11-18 t tttbttstxqttrrtmtt 0
3-5 t jrgztqxsctnz 1
4-14 l qbklhcmthmllfl 0
4-18 l ncqqmclxshsfkcljlll 1
2-4 s scqskss 1
2-10 l lcllmcnllpvtlgll 0
7-14 t tttttttttttttttt 0
2-3 g gggqh 0
7-8 f mfffffffgbtsffdvvfl 0
11-13 m mjmmxmwjmjmmmmmcmmvm 0
2-5 z zdzzh 0
2-3 m tdvlm 0
10-14 c ccrccccdcccmcccbcc 0
12-14 h hhhhhhhthhhhlhh 0
3-4 s sssc 1
16-20 n nnnnfnnnnnnnnqnznnnn 1
18-19 s wssssssssssssmsssvds 0
7-9 r wrrrrrrrrlrgtr 0
4-7 f fffffff 0
4-8 g kgpgbgggmngxggwfh 0
4-9 p pfpvppppj 0
3-9 d dddddzddd 0
13-15 b bbbbbbbbbbwtbtmbwqb 1
7-9 v vvvvvvvvdd 1
3-4 l llkk 0
4-12 j thjjjfjjjjjjjj 0
4-13 m lmwmbmqvzxjhmlp 0
5-9 b bbwbbbbmbwb 0
7-8 g gvgggggggggg 0
1-3 s ssszvs 0
1-4 d tdgds 1
4-8 d rdddjdljdrd 1
5-12 m mmmmgmgmmjcxpjm 0
6-7 j jbjjjqc 0
19-20 w wwwwwwwwwwwwwxwwwwkw 1
7-10 d ddfdddddcddmmd 0
2-4 q qqqqq 0
11-14 b bbbbnbbbsbbbbvblb 1
9-12 g gggggggsgtgggggggg 0
12-17 j jjmpjjjjjhtcjhzjp 0
5-14 c rbgcpfccppccncrsc 1
6-7 d ddddddr 1
2-4 w wwjzvs 1
4-11 h frhhbknrmrhv 0
2-6 b fxbhhzhb 0
2-5 s lskss 0
5-9 p tpppdpppzfqlfph 0
2-6 c cgqqbf 0
4-9 x xxxxxxdxxmxc 0
1-2 l lllwf 0
4-8 t tpttmtht 0
3-16 k kktndqkrcfnwtkkk 1
4-6 w wwwcfnsw 0
17-19 f fffxpfffffffcfffffnf 1
10-14 l lllllllllllllm 1
5-14 j djjjjjsdvcjjjjtgjrjj 0
8-13 w dxrbwrzwtvngwwvzr 0
2-3 z zqzz 1
5-8 k kkkklknlk 0
13-18 w wwmwwwwwdwhwwxpwbw 0
14-18 x xdxxxxxxfxxxdvxxxqx 0
2-4 v qzsmvvv 0
10-11 j jjkmjwjbsjsjjjjjjp 1
5-10 x xxnxwxxxxxqskxwgpz 1
14-17 s sssssssssssssssss 0
8-12 v vvvvvvvvvvvvvvvv 0
9-20 v vvvvvvvvvvvvvvvvvvvg 1
5-6 f ffffrc 0
11-17 z vzzzzzzzzzbzzzzzlz 0
5-8 t ktwfntjtgmvpttfx 1
6-7 m mmmmmmx 1
6-13 d zdwddvmddwddgp 0
4-12 j jjjcjjjvxjjnvjqj 0
3-5 c ccccc 0
4-6 h zhhhhq 1
4-5 m mmmmjmm 1
3-5 j ljnhn 0
4-7 d qddpsdddddr 1
2-6 k dkkfsxzmnckggm 1
6-11 q pzqqdqqqnqqqtqgqsqsq 0
10-12 p hsrpgppjmpbmmv 1
4-8 f fkfscjff 1
1-3 w wwkw 1
9-16 d dddddddjdrdcddzgdd 1
2-3 h hhhh 0
9-13 l qkllllslvwpkmnlfzlll 0
3-17 f fskfffnfjszfffwfzfcf 0
3-5 q zfqsqqxqv 0
3-8 w xwjqmpvw 1
3-5 w rqffzwzdgxwjmlk 0
10-11 v vvvcvvvjvhrv 0
4-13 b bbbgbbbblbbbn 0
2-6 j mjdjlrqjjjjszqzbbv 1
5-6 k kkkgdlc 0
14-16 l lllzlllblllllrllllx 1
1-5 h wpqss 0
6-10 f gvtmdfqrhft 0
14-15 r rrrrjvrrrrrrrcfr 0
3-6 k dkkkkk 0
3-4 t ztpxt 0
3-5 g gggwg 0
5-16 t tttctthtttptttttttt 0
1-6 b bfgmbbt 0
5-7 j qhhjmjvjv 0
4-12 z xjpzjzkvzzrzwz 0
3-4 x xxxxx 0
4-6 g gbgxsbprgzg 0
1-3 q vqqgq 1
11-12 x xwxnrxxxmzxx 0
6-9 r rvvrrrrqrr 0
16-17 j jjjjjjjjjjjjjbjvcj 0
9-10 k kkkwjkrwkkkrxkkvhkf 0
1-7 v vjvvcrk 1
8-13 s sssqrsqtsssmsssss 1
5-6 p ctslhnhphlmpppz 0
1-7 x zfgmlxxxxbcsfxxclh 1
12-15 w wwwwwwwwwwwfcww 1
9-17 g gdggghjmggsggggfgj 0
5-9 s sscrspfvspssj 0
2-3 w wmltwwj 0
2-10 c ccrcjkpkccvlbckbbtc 0
7-18 t tttttttttttttttttw 1
3-8 t tttttsswttt 1
2-17 j jngjjjcjhjjjjjgjs 0
2-4 l jhlspd 0
10-20 g nvshfzjmtgsrnhtjgzzg 0
7-11 c bscccccxccc 0
12-14 m mmmmmmmmmmmmmm 0
4-5 t tttrt 1
1-2 n szbzvnlxc 0
3-7 b bbbbbbb 0
2-3 z ptpzzvc 0
7-8 r rrrxrprr 0
17-18 c ccccccccvcccccccgw 0
5-6 g qqrghgwx 1
14-16 h hhhhhrhhwghkhhhhhhh 0
13-15 g kgggxggggrgglglvgf 0
10-11 g ggpgggngggng 1
3-5 n sldjnxplwngpnsqm 1
5-12 k vkrkksdkslmsrkxtslk 1
6-8 q vdqqvqqqz 0
5-9 h hhhhhmmhm 1
1-3 r rrrr 0
12-13 p ppppcplbpfppppppp 0
1-8 s jdkssbsqks 0
13-16 j jjtjjjjjjjwjjjjkj 1
1-2 z jzzz 1
2-3 n pkjt 0
7-8 l lrdlzlqjllm 0
2-8 j jjljjnjkjzvjjq 1
13-16 j jjjjjjjjjjjjdjjq 0
14-16 q qqqqqqqqqqqqqqqqqq 0
1-5 b bqpglwpwbzzcdxhxqwq 1
11-18 q qqqqqqqqpbqqlfqqwq 0
12-14 p pppppppppppdpxp 0
7-10 x slxvrxnlwh 0
7-8 z zfzzzrbzzz 1
5-9 r rsnzrrfrrrsmlr 0
5-6 z zzzwzzz 0
12-13 f fffffcfffffnnf 0
5-6 x xbxnvx 1
11-13 v nvvvvvvvvvrvv 1
5-14 k xvgfkksvtccfvkmbkmz 0
1-6 x gxlqxxxx 1
6-7 b kbbkqbbbhxqcdpbvb 0
12-14 j jjjjjjvjjjjjjnjjj 1
7-10 f qfffgfdffzff 0
4-8 j jjjkjjjjjj 1
8-9 g ggggggggg 0
4-11 c bdkskbwctpckccbzbcc 1
2-7 s tsxlhfvtbzkkqssmss 1
3-4 m mmmmmmmmmmm 0
3-5 s zzsss 0
3-4 v vvpb 0
17-18 d dddddddddddddddddg 1
15-16 x xxxxxxxxxxxxxcxx 0
1-3 p npxrvvcgjpf 0
7-10 h hhrhhhhhhh 0
2-13 x xbxxxxxxxxxxcxx 0
2-3 c gcpckck 1
1-4 k mwkk 1
4-9 g xvbggpltgglvggmgnpxk 0
14-17 f nbfhblbmqzrmrfzcfn 0
11-13 c zkccccdcccccxcvtc 1
10-12 l lllllllllllll 0
4-5 w wwwww 0
4-6 p pwtpppj 0
7-9 j jjjjjqjjrkj 1
15-17 k krkkkkkkkkqkkkfks 0
9-10 r rrrrrrrrgxr 0
14-17 c mbwhtknbvrqrzxprcctd 1
2-4 h hlhxkhhh 0
17-18 w wwzwwwwwwwwwwwwwnpw 0
1-3 w wdjpt 1
7-16 j djjgjjdjbwdjzjjcjdjj 0
1-8 p phqgprxp 0
11-17 k kfkkkkkkkkqkkkkkhkk 0
14-15 t httttttttttttpmt 0
9-11 w wwwwwwwwwww 0
3-7 b bbgbbkbbbbbbbjp 1
8-13 t tttttttlttttjt 0
9-10 b bbbbbbbkbbb 0
9-10 q qqqqqqqqqs 1
12-13 p prpppppvpppkhp 0
2-4 s swsvs 0
8-11 j jjjjgjcjjngjfsjs 1
2-8 r rsrrrrrlr 0
4-9 j xsfvbjdmj 1
13-14 b bbbbssbbbwjqms 0
9-10 m zxmbtjhpmhwx 1
3-4 v fsvvdv 0
17-20 w wgwwjqdwwwfgsrwwwsgw 0
8-10 t ttpttttttw 1
3-8 t mxptddtdttb 0
9-10 v vvvvvvvvtd 0
12-14 q qqqqqqqqqqqdqj 0
1-2 n cnnn 1
14-17 z gzzwtvhzgrzxzrxxhcz 0
3-5 c clccczc 0
1-13 t gjbzdcntxhfmg 0
1-6 z zdmsjnz 1
6-7 j jfjjnrjjj 1
13-14 h hhhhhhhhhhhhrth 0
2-5 x xxqxxt 0
3-8 w wwwhwwwwwrdpww 0
3-10 n nnnnnnnnnnnnnn 0
7-13 l llfllmlslpslltll 0
4-8 w wwwwtwwmkw 1
7-8 t ttttttkrcwq 0
3-6 g cxwmbgmxg 1
12-13 b bbrdbkbmbvbbb 0
1-16 d dsndtgbmdrdxbddddjdd 0
3-11 g gggjwgrggzxmxbgg 1
11-18 s ssbscmdbssksswksss 1
13-15 s svsssssslsbsssssssz 0
5-12 n nnnnmsnnnnbz 0
5-8 g ggtgfggsgggggggggggg 0
2-3 c kccc 0
14-18 t ttttttttsttttttttt 0
3-5 r rrbprp 1
5-7 s jszjsgsxtzkspgs 0
11-12 m mmmmmmmmmmjm 1
6-10 q qqcqqqbqqp 1
5-8 s ssjszwsts 0
5-6 x xxxxsl 0
15-20 k kkkkkkkkkkkkkkkkkkkk 0
13-14 s sssgssrpssssszss 1
3-6 v zjxcgdvswnfvvvv 0
5-6 m mmqmmm 0
5-10 t ttttttttltt 0
2-4 d qsdvsgtd 0
2-11 t btttbttznrctwwnltvnt 1
6-16 b rgkcwbcnrdbrqvqbbq 0
2-13 j jjjjjjjbjjjjj 0
17-18 j jjjjjjjjjjjjjjjjjj 0
9-16 v rvvvmvgsvvvvvhjvvqs 0
4-5 d wldddd 0
2-13 v mvvvvvvdvjvvvr 0
6-7 s sdssfpwsskqbq 0
12-13 m mmmmhmmmmxmmmm 0
14-15 j jjjjjjjjjjjjjjj 0
2-13 d vddnpddsdpddd 0
3-5 g gkgggks 0
14-15 g dwggggggggjvgkgqgggg 1
10-11 n nnnnxnngrxhnn 0
3-6 r rnrnrr 0
7-13 k cpmxcndgssktpkkpfkk 0
3-7 s sssssss 0
6-10 b nrbmbbrhbfrbnn 1
8-9 l lllllllft 0
6-8 x xnxxkwknxlxxbbx 0
1-16 f fffzkffffknfrfqqf 1
5-6 v jvvvvvvvppvt 0
14-18 n nnnnnnnnnnnnnknnnb 0
5-16 n ncnnnsvlpndnkvvrcf 1
13-15 j jjjjljjjjjjjqjj 1
4-7 s qhrhsdbsmmlstznms 0
5-13 m kmmctmsmmmglzxm 0
14-17 s ssssssgsssszspssb 0
13-20 x sjxdxqcxxxxqxkxxxxxq 1
7-9 f ffjfffnjnff 0
10-11 m mmmmmmmmmmxmmm 1
3-5 q qqbqc 0
14-18 f tfkfrbbznftcfftbmfxf 0
1-15 l lclwqxcczgnktqltm 0
9-12 g fgggmgggfggm 0
16-17 t mntvzrcdttplrfzkv 0
3-5 n nngnp 0
3-6 s gsxznsssbbtsl 1
3-4 s hsssv 0
10-11 m smmmmmmmmmnm 1
11-15 k kkkkkkkkkkkxkbkjk 0
8-11 x xxxxrxkvmxlxwp 0
2-5 p pppbbp 1
11-13 b bbbbvbbbbblbrdb 0
9-16 w wwgwwwwwhwwwwwws 0
9-10 q zqqkqvqskqqzzqcjqq 1
4-6 j jbkjnjddjhjhjqbxpzf 0
2-3 c ccrccz 1
15-16 r rrrrbrrrrrdrrrrrr 0
2-5 x xxqrxwrchhd 0
6-7 r rrrrrrkrr 1
5-6 h hhhhpq 0
9-11 s ssssssstsss 0
1-6 k ctprksgrdgkg 0
7-8 k kkkkdkkkkk 0
1-4 l mllt 0
5-10 b bbbbbjbzzbbbb 0
1-2 c cczfkcmsdnghcnmhvx 0
12-16 z zgzvzzzzzzzzzzzz 0
13-14 k kksmtsrkrwxkkk 0
10-12 q qpqsqqqhqslqqnnqjqqg 1
4-15 q zgppzlxqvrdvnkkgnr 0
1-4 b dbjbk 1
5-9 c cccclcccpcccvc 0
2-6 t ttctdtdtts 0
2-3 q pqqtbwkr 0
12-15 v vdvvlvvzvvvgvvv 1
2-8 c ccbcbcbncxxgcngrck 1
2-4 z cnzzt 1
3-4 j jjtrjj 0
6-12 x xxxrxqxxxqxxkxs 1
5-9 r rqnbnrrnnrwhdrr 0
2-5 s smssk 0
4-16 g hgzjhgggcgnwddkq 0
4-10 l jlgxxlgllql 0
1-5 r rrwgrrck 0
1-11 t wtttttttttrtttttttt 0
5-9 n njnnksntk 0
5-8 s ssssswsss 0
2-4 q qqqq 0
1-9 b jqmxlrdbbbfnwtlqjbbf 1
3-5 g qhgsgpjdphghhjwqx 0
1-4 d mddd 1
4-6 q qsqqqqgqqg 0
9-15 f ffffxffrffwfffffff 0
2-6 z zrzshvzlzkxzp 0
7-10 s sppscfwscfsszbsf 0
5-19 r drwrmrvprrrdrrrrrkv 0
9-10 n nnnnxnnnnr 1
4-10 m mmmmqmcmlmvmm 0
10-13 v wcnzkqgvvgxldxl 0
9-11 k vclfkkfcdbwwk 0
12-13 r rrrrrrrrwrrfh 0
7-8 s szsssswfs 0
4-6 z nzzjzk 0
5-7 w ghwwdrr 0
2-10 x xxnxxxwxxsx 1
9-10 b bbktbbbxhfbpb 388

SUCCESS!

Debrief

Today was trickier, as of course it would be. Once I figured out the counting thing, instead of the awful regex (as cYmen said, "Some people, when confronted with a problem, will decide 'hey, i can solve this using regular expressions'. Now they have two problems."), it wasn't so bad. I need to make sure not to stay up so late tonight.

Day 3

This one is going to be tough already.

A

Problem

With the toboggan login problems resolved, you set off toward the airport. While travel by toboggan might be easy, it's certainly not safe: there's very minimal steering and the area is covered in trees. You'll need to see which angles will take you near the fewest trees.

Due to the local geology, trees in this area only grow on exact integer coordinates in a grid. You make a map (your puzzle input) of the open squares (.) and trees (#) you can see. For example:

..##.......
#...#...#..
.#....#..#.
..#.#...#.#
.#...##..#.
..#.##.....
.#.#.#....#
.#........#
#.##...#...
#...##....#
.#..#...#.#

These aren't the only trees, though; due to something you read about once involving arboreal genetics and biome stability, the same pattern repeats to the right many times:

..##.........##.........##.........##.........##.........##.......  --->
#...#...#..#...#...#..#...#...#..#...#...#..#...#...#..#...#...#..
.#....#..#..#....#..#..#....#..#..#....#..#..#....#..#..#....#..#.
..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#
.#...##..#..#...##..#..#...##..#..#...##..#..#...##..#..#...##..#.
..#.##.......#.##.......#.##.......#.##.......#.##.......#.##.....  --->
.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#
.#........#.#........#.#........#.#........#.#........#.#........#
#.##...#...#.##...#...#.##...#...#.##...#...#.##...#...#.##...#...
#...##....##...##....##...##....##...##....##...##....##...##....#
.#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.#  --->

You start on the open square (.) in the top-left corner and need to reach the bottom (below the bottom-most row on your map).

The toboggan can only follow a few specific slopes (you opted for a cheaper model that prefers rational numbers); start by counting all the trees you would encounter for the slope right 3, down 1:

From your starting position at the top-left, check the position that is right 3 and down 1. Then, check the position that is right 3 and down 1 from there, and so on until you go past the bottom of the map.

The locations you'd check in the above example are marked here with O where there was an open square and X where there was a tree:

..##.........##.........##.........##.........##.........##.......  --->
#..O#...#..#...#...#..#...#...#..#...#...#..#...#...#..#...#...#..
.#....X..#..#....#..#..#....#..#..#....#..#..#....#..#..#....#..#.
..#.#...#O#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#
.#...##..#..X...##..#..#...##..#..#...##..#..#...##..#..#...##..#.
..#.##.......#.X#.......#.##.......#.##.......#.##.......#.##.....  --->
.#.#.#....#.#.#.#.O..#.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#
.#........#.#........X.#........#.#........#.#........#.#........#
#.##...#...#.##...#...#.X#...#...#.##...#...#.##...#...#.##...#...
#...##....##...##....##...#X....##...##....##...##....##...##....#
.#..#...#.#.#..#...#.#.#..#...X.#.#..#...#.#.#..#...#.#.#..#...#.#  --->

In this example, traversing the map using this slope would cause you to encounter 7 trees.

Starting at the top-left corner of your map and following a slope of right 3 and down 1, how many trees would you encounter?

Input

.#...#.......#...#...#.#.#.....
####.....#.#..#...#...........#
.....#...........#......#....#.
......#..#......#.#..#...##.#.#
............#......#...........
...........#.#.#....#.......##.
....#.......#..............#...
........##...#.#.....##...##.#.
.#.#.....##................##..
.##................##..#...##..
....#...###...##.........#....#
.##......#.........#...........
...#.#.#....#....#...#...##...#
..#....##...#..#.#..#.....#.#..
.......#...#..#..#.....#...#..#
.....#......#.......#.....#.#..
....#..#...#..#####....##......
.#...........#......#....#....#
#......#.###.....#....#....#...
....#..#.#.#..#...........##...
..#..#..#.#...#......#....#.##.
.##....#......#...#.#..#.......
..###.#...#.........#.#.#...#.#
#....###.........#...#...#...#.
...##.#............#...##......
...#.........#............#....
......##...#...##..#...........
........##..#.#.####...#.....#.
.##.........#......#..#..#...#.
..........#...#..........#.....
#..........#........#..#..#.#..
..#....#.#.#.#.#..#.##.........
##.#.#.##.....#..#......###....
##....#...#.....#..............
.#..#...#...#....###......#....
#....#......#.#..#.#........###
.#....#..#...###....#...##.....
.#....#.....#.....#..##..#.....
#....#.##...#...#..#.##.##.#...
.#.#.#.##...#####.............#
......##..#.....##..#...####...
#.##..#.#....#..##.......###..#
..#.......##....#........#.##..
#.....#......#.....#....#..#...
.......##...#.....##.......#..#
.......#...#.#.#.........#####.
#.......#.##..##........##.....
##..#...#........##....#.......
.......#...##......##...##.##..
......#..##..#.#...#...#....##.
....#.#..#.....#.##.#.....#.#..
#..#.#.#........#...#.......##.
##...........#..#........#.....
....##....#....#.#.......#.....
....##.#.#.....#.#.....#.....#.
..........#.#..##..#..#.......#
#....#.......##...#...#.....#..
.........##.....#.#....#......#
..........#........#..#..#.#...
..#......#.....#......#......#.
..#...###..##..#.....##..#..##.
..#.#..###.........#.#...##.#.#
#.........#..#......#...##.....
...#...#.#..#...##.#...##.#..#.
#.....#.....#.##....#.#......#.
#....##..##..#.#..##....#.....#
.#..........#..#...#..#.......#
#.#.....#..##..##..#.#.........
....#..##...#.....#.....#.#.#.#
...#.#....#........#...#.#.....
.#............#.......#.##.#...
..##.......#.#...#........##..#
..................##.#...#.#..#
.#.........#.......#.....#.....
....##...##..#..........#......
..#.##..#....#..#............#.
....####...#.##....##.#....#.##
#..#....#......##........##....
..###...........##..#......#...
#..#.......#........#.......#..
.....#....#..#..##.....#.......
.###.####.#....#....#..#.......
.............#...............#.
.#..........#.#....#..#.#......
..............##....#..#....##.
.......#.#..#........#.......##
#..#...#..#.#........#..#....#.
...#.........#...#..#..........
...#....##...#..#..........#...
.#......#......##..##...#.#....
.#.........#..###..............
.................#.#.....##....
...#............#..............
#..#................#.......#..
...#.......#......#.#.#........
#.....#.##....#.....#........#.
......##.#....#........#....#..
.#..#.##...##........#.#.....#.
..#...#....#...#..#..##..#.#..#
#.................#.#.......##.
..........#........#.#.....#..#
#....##....#........##..##.#...
#...#....#.....#.....#.....#...
#..#..........#....##....#....#
..#.#..#..#....#.#....#....#..#
#....#..#.......#..........#...
.#...#.#...#..#...#.......#....
###........#......##..#...##...
...#..........##..............#
.......#........##......#.....#
.#..........#...#...##....###.#
.#...#....#..#.....##...#..##..
.#.#.#...##..........##...#...#
.#.....#...#........#........##
#.......#......##.#.#..#....#..
##..#.##........#....#..#......
...#.......................#...
..#....#..##........##.#.##.#..
.............#.......#....#.#.#
...#...........##..#.....#.....
..#....##....#.....#...........
..#.....#......#..#.###.##....#
.#.......#...........#...#....#
#............##...#...#.....#..
##...#.....#.........##...##...
...#...........#....##.........
#.##..#..........##..#......#..
.......#.#.......##.......#....
..#.....##..#...#.......#......
.#........#....##...........#..
#.......#...#.#.###...#....#...
..........##..#..#..##........#
#....#....#...#....#....#......
...........#....#...#...##.#...
.........#.#.....#.............
..####...........##..........#.
.....#...................#.....
#..##...#........#.###.#.##....
....##...#.##................#.
.#........###.#............#.#.
..............#.##.........#...
##............#.#..###....#...#
#.....#........####....#....##.
....##..#...##..##...##.....#..
##..#....#.##.....####.....#.##
##..#....#.##.##.#.#........#..
....#..........##.....#..#..#..
...#.......#........#.........#
#..##.######.......##........#.
###...#...####.......#.....#...
#......#..#.....#......#.....#.
..................##...#.......
....#.#....#......#...#.....##.
..#..#..#..#..#....#.#...#....#
......#....###.................
#.##......#...#......#.........
#..#.#...##..#.......#..#...#..
.#....#.#........#.........#...
#.......##..#..#...............
........#..##....#.....#..#....
....#......##..#....#...#..#...
#.....#...##..#...#......#.....
.....#.....#.........##...#..#.
........#...##.#...#.#....#..##
....#....#...#.....##..#...#...
#....#..#.........#.........###
..###.....##...#.#....##......#
#..#.#..#.......#..#....##.....
###...#.##..#.......#......#...
.....#.....##.......#...##..#..
......#.......#.#.#......#..#..
.................##..#.###.....
..........#....#...#..........#
...#.#...#.#..##.....#.#.##..#.
.......#..#....#...#......###..
...##..........#..#.....#....#.
.#..##..###...#....##.....#....
..#.#..............#....#...#..
.....####.......#.#.##....#....
#.#.#..##.##.#..#.##.#....#..#.
........#....#.......##........
...#...#....#...###.....###....
.....#..#..........##.#...##.##
..#.#.#..#....#...#..##...#...#
..#......#..#.#.....#....#....#
.#.....#.......#............#..
#..##....#...#....##....#......
#..#.........#...#...###.#..#..
..#.#.#..#.#..#.......##.......
...##...............#..#...#.#.
.......####.#.....#..#..#......
......#..#.....#..##....#......
....#...#.........##.......#.#.
#.#.#...#.....#...#..#.#..#....
........#..#.........#..#..##..
........###.#............#.#...
#..#.......#.#..#.......#...#.#
..##..............#.#.....#...#
..##...........................
..#.....#.......#......##......
#...#......##.#....#.#.#...##.#
#...#.#......#.#..##.........#.
.##..#...#.#.....#.#.#...#.#..#
.#..#...#.#.........#......#...
...........#...#...#...#..#.#..
.#........#...#......##...#.###
#........#..#.#..#...........##
.#...#...####.......#..........
......#...............#........
.....#.#.....#.#...#......#....
.#........#...........#..##.#..
....#..#.....###.......#...#...
#.#.........#...##..#.#.##.#...
................##.#....#.#...#
.......#.......#......#...#....
#....#.#..............#.##..###
..##.##..#.....#............#..
#....#..##........#....#.......
.#.#........#.#................
......##..#..#..........#..#.#.
.....##.#..#....##.#......##...
........###.#................#.
#..###.....#.###.#...#.#.......
.#..#.#.#.#..#..#.#.....#.#....
#....#.....#..#......##...#..##
........#...##..#.#.....#....#.
.......#..#..#..#....#.....##..
....#..##..#...#....#.........#
#.#....#..#.#...#.#...#....#...
.....#......###.......#..##.#.#
.......##.....#....#........#.#
.##.##..#..###.#....#.#.....#..
..##.#.......###.........#.....
.#...#......#..#....#..........
.....#........#.....##...#.....
..#......#.#.#..#.#....##.#...#
#.#...#...........##......#....
.................##.....#.#.##.
###..#....#..................#.
##..#.#.#...#....###.#.#...##.#
#.#.#..#....#..............#...
.....#....#......#..#.##.......
#...#...#..###.......#.......#.
.....#.#........#..#...#.#.....
.....#..........#.###.......#..
...#.##.....#....###.....#.....
####........#....#..#.#.##.#...
#......#...##.....#.#..##.#.#.#
.....##....#..#.........##.....
..##....##................##..#
#.....#...##...##.#.....#...#..
..#..#.#.#....#.#.......#......
##.....##......#...#.........#.
#..........#........#.#......#.
.#..#.......#.#.....#..........
.........#.#.......#.#..#..#..#
#......#....#....#..##..##...##
.....#..#...#.......#.....##...
..#.##........#.###...#...#...#
..#..#...........#..........#..
.#.#.#...#.##.#..............#.
....#..##.......#.....#..##..#.
.#.##.#....##........#...##.##.
...#.#...#....#....#......#####
.....#.....##...........#......
#........#.##.......#.#.......#
#...#.......##.#.......#..#.#..
#...##..#....#............#.#..
........#.#..#...#..#...##..##.
#...#....#............#........
#.#.#.#.#....##.....##.........
......##.........#.......#.#..#
...#.#....#........#...........
...#.#.......#.....#...........
##....####......##.##..#.......
#......#...#..#.#..#......#..#.
#......#.#....#....#..#........
..#.###...#.....#........#.#...
..#.....##.....###....#.....#..
#.##.#.....##....#...###.......
###.#....###.#..##.#.......##.#
#..#..##...#.#..........##.##..
.......####.#..#.....##..###...
#...#...##..#..##.......###....
#....#.........##..#.........#.
.....#.#..........#..#...#.#..#
..........#......##..#..#.#....
.#...#...#...#........###....##
#....#.##..........#.#.....#.#.
#....##.#.##..#.......#.#.....#
.##..##..#.#...#.#...........#.
....##..#...#.#.##.#.#...#.....
.#...#.##........#.##..#.#....#
.#.....##.........#.....#......
..#.....#.#..#.##.............#
##....##...#....##........#....
.#....#........#.#..#..#..#.##.
.#........#............#.......
.#..##..##..#..#..####....#....
..#.###....#..#.##......#.#...#
.###..#.#...##....##....#..##.#
....##........#....#.#.#...##..
...#..#....#.#....#...#.#.....#
...##....##..#....#.........#..
.....#..##.###..#.....####.....
...#..#.........#....#.#.##..#.
...#..#...............#..#....#
...........#.....#...####..##.#
..#......#...#....#..#...##.#..
.....#..#...........#.......#.#
##....###...#.........#....#...
...#..##.......#.#.....##....#.
#.#...#.#....#.....#...##.....#
.#...##....#.....#..##.......#.
...#........##..........#.....#
#...##..#.#....###...#..#......
............#.......#......#.#.
......#....#.#...#...#..#......
.#..#......#....#.......#....##
...#...#.......###..###...#....
.............#.#...#..###.....#
.#.....#........#...##....#..#.
.....#.......#######.#.#...#...

Solution

Okay, let's think this through first. The map loops horizontally, which means I can use modulus math for some of it. The sled will encounter a new line every 3 steps … so I think that's the … moderand? The thing I'm modding against.

  (defun calc-position (slope line-number line)
    "Calculate where we are in the line."
    (mod (* slope n) (length l)))

  (defun replace-char (line position char)
    "Replace character in LINE at POSITION with CHAR."
    (let ((pre (if (= position 0)
                   ""
                 (substring line 0 position)))
          (post (if (= position 0)
                    (substring line 1)
                  (substring line (+ 1 position)))))
      (concat pre (string char) post)))

  (defun collisionp (line position char)
    "If the character at POSITION in LINE is CHAR, return t."
    (char-equal char (elt line position)))

  (defun draw-line (line-number line position)
    "Draw a line."
    (list line-number
          (replace-char line
                        position
                        (if (collisionp line position ?#)
                            ?O
                          ?X))
          (if (collisionp line position ?#)
              1
            0)))
  <<3a-lib>>
  ;; do it
  (let* ((lines (split-string input))
         (n 0)
         (result))
    (dolist (l lines result)
      (let ((p (calc-position 3 n l)))
        (add-to-list 'result
                     (draw-line n l p)))
      (incf n))
    (reverse result))
0 X#…#…….#…#…#.#.#….. 0
1 ###O…..#.#..#…#………..# 1
2 …..#X……….#……#….#. 0
3 ……#..O……#.#..#…##.#.# 1
4 …………O……#……….. 1
5 ………..#.#.O….#…….##. 1
6 ….#…….#…..X……..#… 0
7 ……..##…#.#…..O#…##.#. 1
8 .#.#…..##………….X..##.. 0
9 .##…………….##..#…O#.. 1
10 ….#…###…##………#….O 1
11 .#O……#………#……….. 1
12 …#.O.#….#….#…#…##…# 1
13 ..#….#O…#..#.#..#…..#.#.. 1
14 …….#…O..#..#…..#…#..# 1
15 …..#……#.X…..#…..#.#.. 0
16 ….#..#…#..###O#….##…… 1
17 .#………..#……O….#….# 1
18 #……#.###…..#….#X…#… 0
19 ….#..#.#.#..#………..O#… 1
20 ..#..#..#.#…#……#….#.#O. 1
21 .O#….#……#…#.#..#……. 1
22 ..##O.#…#………#.#.#…#.# 1
23 #….##O………#…#…#…#. 1
24 …##.#…X……..#…##…… 0
25 …#………O…………#…. 1
26 ……##…#…#O..#……….. 1
27 ……..##..#.#.###O…#…..#. 1
28 .##………#……#..O..#…#. 1
29 ……….#…#……….O….. 1
30 #……….#……..#..#..#.O.. 1
31 X.#….#.#.#.#.#..#.##……… 0
32 ##.O.#.##…..#..#……###…. 1
33 ##….O…#…..#………….. 1
34 .#..#…#X..#….###……#…. 0
35 #….#……O.#..#.#……..### 1
36 .#….#..#…##O….#…##….. 1
37 .#….#…..#…..O..##..#….. 1
38 #….#.##…#…#..#.O#.##.#… 1
39 .#.#.#.##…#####…….X…..# 0
40 ……##..#…..##..#…###O… 1
41 #.##..#.#….#..##…….###..O 1
42 ..O…….##….#……..#.##.. 1
43 #….X#……#…..#….#..#… 0
44 …….#O…#…..##…….#..# 1
45 …….#…O.#.#………#####. 1
46 #…….#.##..O#……..##….. 1
47 ##..#…#……..O#….#……. 1
48 …….#…##……#O…##.##.. 1
49 ……#..##..#.#…#…O….##. 1
50 ….#.#..#…..#.##.#…..O.#.. 1
51 #..#.#.#……..#…#…….#O. 1
52 #O………..#..#……..#….. 1
53 ….O#….#….#.#…….#….. 1
54 ….##.O.#…..#.#…..#…..#. 1
55 ……….O.#..##..#..#…….# 1
56 #….#…….O#…#…#…..#.. 1
57 ………##…..O.#….#……# 1
58 ……….#……..O..#..#.#… 1
59 ..#……#…..#……O……#. 1
60 ..#…###..##..#…..##..O..##. 1
61 ..#.#..###………#.#…##.O.# 1
62 O………#..#……#…##….. 1
63 …O…#.#..#…##.#…##.#..#. 1
64 #…..O…..#.##….#.#……#. 1
65 #….##..O#..#.#..##….#…..# 1
66 .#……….O..#…#..#…….# 1
67 #.#…..#..##..O#..#.#……… 1
68 ….#..##…#…..O…..#.#.#.# 1
69 …#.#….#……..#.X.#.#….. 0
70 .#…………#…….#.O#.#… 1
71 ..##…….#.#…#……..#O..# 1
72 ………………##.#…#.#..O 1
73 .#X……..#…….#…..#….. 0
74 ….#O…##..#……….#…… 1
75 ..#.##..O….#..#…………#. 1
76 ….####…O.##….##.#….#.## 1
77 #..#….#…..X##……..##…. 0
78 ..###………..#O..#……#… 1
79 #..#…….#……..O…….#.. 1
80 …..#….#..#..##…..O……. 1
81 .###.####.#….#….#..#..X…. 0
82 ………….#……………O. 1
83 .O……….#.#….#..#.#…… 1
84 ….X………##….#..#….##. 0
85 …….O.#..#……..#…….## 1
86 #..#…#..O.#……..#..#….#. 1
87 …#………O…#..#………. 1
88 …#….##…#..O……….#… 1
89 .#……#……##..O#…#.#…. 1
90 .#………#..###…..X…….. 0
91 ……………..#.#…..O#…. 1
92 …#…………#………..X.. 0
93 O..#…………….#…….#.. 1
94 …O…….#……#.#.#…….. 1
95 #…..O.##….#…..#……..#. 1
96 ……##.O….#……..#….#.. 1
97 .#..#.##…#O……..#.#…..#. 1
98 ..#…#….#…O..#..##..#.#..# 1
99 #……………..O.#…….##. 1
100 ……….#……..#.O…..#..# 1
101 #….##….#……..##..O#.#… 1
102 #…#….#…..#…..#…..O… 1
103 #..#……….#….##….#….O 1
104 ..O.#..#..#….#.#….#….#..# 1
105 #….O..#…….#……….#… 1
106 .#…#.#X..#..#…#…….#…. 0
107 ###……..O……##..#…##… 1
108 …#……….O#…………..# 1
109 …….#……..#O……#…..# 1
110 .#……….#…#…O#….###.# 1
111 .#…#….#..#…..##..X#..##.. 0
112 .#.#.#…##……….##…O…# 1
113 .#…..#…#……..#……..O# 1
114 #X……#……##.#.#..#….#.. 0
115 ##..O.##……..#….#..#…… 1
116 …#…X……………….#… 0
117 ..#….#..O#……..##.#.##.#.. 1
118 ………….O…….#….#.#.# 1
119 …#………..#O..#…..#….. 1
120 ..#….##….#…..O……….. 1
121 ..#…..#……#..#.##O.##….# 1
122 .#…….#………..#…O….# 1
123 #…………##…#…#…..O.. 1
124 O#…#…..#………##…##… 1
125 …O………..#….##……… 1
126 #.##..O……….##..#……#.. 1
127 …….#.O…….##…….#…. 1
128 ..#…..##..O…#…….#…… 1
129 .#……..#….O#………..#.. 1
130 #…….#…#.#.##O…#….#… 1
131 ……….##..#..#..#O……..# 1
132 #….#….#…#….#….O…… 1
133 ………..#….#…#…##.O… 1
134 ………#.#…..#…………X 0
135 ..O###………..##……….#. 1
136 …..O……………….#….. 1
137 #..##…O……..#.###.#.##…. 1
138 ….##…#.O#…………….#. 1
139 .#……..###.O…………#.#. 1
140 …………..#.#O………#… 1
141 ##…………#.#..#O#….#…# 1
142 #…..#……..####….O….##. 1
143 ….##..#…##..##…##…X.#.. 0
144 ##..#….#.##…..####…..#.O# 1
145 #O..#….#.##.##.#.#……..#.. 1
146 ….O……….##…..#..#..#.. 1
147 …#…X…#……..#………# 0
148 #..##.####O#…….##……..#. 1
149 ###…#…###O…….#…..#… 1
150 #……#..#…..O……#…..#. 1
151 ………………#O…#……. 1
152 ….#.#….#……#…O…..##. 1
153 ..#..#..#..#..#….#.#…O….# 1
154 ……#….###…………..X.. 0
155 O.##……#…#……#……… 1
156 #..O.#…##..#…….#..#…#.. 1
157 .#….O.#……..#………#… 1
158 #…….#O..#..#…………… 1
159 ……..#..#O….#…..#..#…. 1
160 ….#……##..O….#…#..#… 1
161 #…..#…##..#…O……#….. 1
162 …..#…..#………O#…#..#. 1
163 ……..#…##.#…#.#..X.#..## 0
164 ….#….#…#…..##..#…O… 1
165 #….#..#………#………##O 1
166 ..O##…..##…#.#….##……# 1
167 #..#.O..#…….#..#….##….. 1
168 ###…#.O#..#…….#……#… 1
169 …..#…..O#…….#…##..#.. 1
170 ……#…….O.#.#……#..#.. 1
171 ……………..O#..#.###….. 1
172 ……….#….#…#X………# 0
173 …#.#…#.#..##…..#.O.##..#. 1
174 …….#..#….#…#……O##.. 1
175 …##……….#..#…..#….O. 1
176 .O..##..###…#….##…..#…. 1
177 ..#.O…………..#….#…#.. 1
178 …..##O#…….#.#.##….#…. 1
179 #.#.#..##.O#.#..#.##.#….#..#. 1
180 ……..#….O…….##…….. 1
181 …#…#….#…O##…..###…. 1
182 …..#..#……….O#.#…##.## 1
183 ..#.#.#..#….#…#..#O…#…# 1
184 ..#……#..#.#…..#….O….# 1
185 .#…..#…….#…………O.. 1
186 O..##….#…#….##….#…… 1
187 #..O………#…#…###.#..#.. 1
188 ..#.#.O..#.#..#…….##……. 1
189 …##….X……….#..#…#.#. 0
190 …….####.O…..#..#..#…… 1
191 ……#..#…..O..##….#…… 1
192 ….#…#………O#…….#.#. 1
193 #.#.#…#…..#…#..O.#..#…. 1
194 ……..#..#………#..O..##.. 1
195 ……..###.#…………#.O… 1
196 #..#…….#.#..#…….#…#.O 1
197 ..O#…………..#.#…..#…# 1
198 ..##.X……………………. 0
199 ..#…..O…….#……##…… 1
200 #…#……O#.#….#.#.#…##.# 1
201 #…#.#……#X#..##………#. 0
202 .##..#…#.#…..O.#.#…#.#..# 1
203 .#..#…#.#………O……#… 1
204 ………..#…#…#…O..#.#.. 1
205 .#……..#…#……##…O.### 1
206 #……..#..#.#..#………..O# 1
207 .O…#…####…….#………. 1
208 ….X.#……………#…….. 0
209 …..#.O…..#.#…#……#…. 1
210 .#……..O………..#..##.#.. 1
211 ….#..#…..O##…….#…#… 1
212 #.#………#…O#..#.#.##.#… 1
213 …………….##.O….#.#…# 1
214 …….#…….#……O…#…. 1
215 #….#.#…………..#.#O..### 1
216 ..##.##..#…..#…………O.. 1
217 O….#..##……..#….#……. 1
218 .#.O……..#.#……………. 1
219 ……O#..#..#……….#..#.#. 1
220 …..##.#X.#….##.#……##… 0
221 ……..###.O…………….#. 1
222 #..###…..#.##O.#…#.#……. 1
223 .#..#.#.#.#..#..#.O…..#.#…. 1
224 #….#…..#..#……O#…#..## 1
225 ……..#…##..#.#…..O….#. 1
226 …….#..#..#..#….#…..O#.. 1
227 ….#..##..#…#….#………O 1
228 #.O….#..#.#…#.#…#….#… 1
229 …..O……###…….#..##.#.# 1
230 …….#O…..#….#……..#.# 1
231 .##.##..#..O##.#….#.#…..#.. 1
232 ..##.#…….#O#………#….. 1
233 .#…#……#..#.X..#………. 0
234 …..#……..#…..O#…#….. 1
235 ..#……#.#.#..#.#….O#.#…# 1
236 #.#…#………..##……O…. 1
237 ……………..##…..#.#.#O. 1
238 #O#..#….#………………#. 1
239 ##..O.#.#…#….###.#.#…##.# 1
240 #.#.#..O….#…………..#… 1
241 …..#….O……#..#.##……. 1
242 #…#…#..##O…….#…….#. 1
243 …..#.#……..O..#…#.#….. 1
244 …..#……….#.#O#…….#.. 1
245 …#.##…..#….###..X..#….. 0
246 ####……..#….#..#.#.#O.#… 1
247 #……#…##…..#.#..##.#.O.# 1
248 X….##….#..#………##….. 0
249 ..#O….##…………….##..# 1
250 #…..O…##…##.#…..#…#.. 1
251 ..#..#.#.O….#.#…….#…… 1
252 ##…..##…X..#…#………#. 0
253 #……….#…X….#.#……#. 0
254 .#..#…….#.#…X.#………. 0
255 ………#.#…….#.O..#..#..# 1
256 #……#….#….#..##..O#…## 1
257 …..#..#…#…….#…..#O… 1
258 ..#.##……..#.###…#…#…O 1
259 ..O..#………..#……….#.. 1
260 .#.#.O…#.##.#…………..#. 1
261 ….#..#O…….#…..#..##..#. 1
262 .#.##.#….O#……..#…##.##. 1
263 …#.#…#….O….#……##### 1
264 …..#…..##….X……#…… 0
265 #……..#.##…….O.#…….# 1
266 #…#…….##.#…….O..#.#.. 1
267 #…##..#….#…………O.#.. 1
268 ……..#.#..#…#..#…##..#O. 1
269 #X..#….#…………#…….. 0
270 #.#.O.#.#….##…..##……… 1
271 ……#O………#…….#.#..# 1
272 …#.#….O……..#……….. 1
273 …#.#…….O…..#……….. 1
274 ##….####……O#.##..#……. 1
275 #……#…#..#.#..O……#..#. 1
276 #……#.#….#….#..O…….. 1
277 ..#.###…#…..#……..O.#… 1
278 ..#…..##…..###….#…..O.. 1
279 O.##.#…..##….#…###……. 1
280 ###X#….###.#..##.#…….##.# 0
281 #..#..O#…#.#……….##.##.. 1
282 …….##O#.#..#…..##..###… 1
283 #…#…##..O..##…….###…. 1
284 #….#………O#..#………#. 1
285 …..#.#……….O..#…#.#..# 1
286 ……….#……##..O..#.#…. 1
287 .#…#…#…#……..##O….## 1
288 #….#.##……….#.#…..O.#. 1
289 #….##.#.##..#…….#.#…..O 1
290 .#O..##..#.#…#.#………..#. 1
291 ….#O..#…#.#.##.#.#…#….. 1
292 .#…#.#O……..#.##..#.#….# 1
293 .#…..##..X……#…..#…… 0
294 ..#…..#.#..#X##………….# 0
295 ##….##…#….#O……..#…. 1
296 .#….#……..#.#..O..#..#.##. 1
297 .#……..#…………O……. 1
298 .#..##..##..#..#..####….O…. 1
299 ..#.###….#..#.##……#.#..X# 0
300 .O##..#.#…##….##….#..##.# 1
301 ….O#……..#….#.#.#…##.. 1
302 …#..#X…#.#….#…#.#…..# 0
303 …##….#O..#….#………#.. 1
304 …..#..##.##O..#…..####….. 1
305 …#..#………O….#.#.##..#. 1
306 …#..#…………X..#..#….# 0
307 ………..#…..#…#O##..##.# 1
308 ..#……#…#….#..#…O#.#.. 1
309 …..#..#………..#…….O.# 1
310 O#….###…#………#….#… 1
311 …O..##…….#.#…..##….#. 1
312 #.#…O.#….#…..#…##…..# 1
313 .#…##..X.#…..#..##…….#. 0
314 …#……..O#……….#…..# 1
315 #…##..#.#….O##…#..#…… 1
316 …………#…..X.#……#.#. 0
317 ……#….#.#…#…O..#…… 1
318 .#..#……#….#…….O….## 1
319 …#…#…….###..###…#X… 0
320 ………….#.#…#..###…..O 1
321 .#X….#……..#…##….#..#. 0
322 …..O…….#######.#.#…#… 1
272

SUCCESS!!! FIRST TRY!!!

B

Problem

Time to check the rest of the slopes - you need to minimize the probability of a sudden arboreal stop, after all.

Determine the number of trees you would encounter if, for each of the following slopes, you start at the top-left corner and traverse the map all the way to the bottom:

  • Right 1, down 1.
  • Right 3, down 1. (This is the slope you already checked.)
  • Right 5, down 1.
  • Right 7, down 1.
  • Right 1, down 2.

In the above example, these slopes would find 2, 7, 3, 4, and 2 tree(s) respectively; multiplied together, these produce the answer 336.

What do you get if you multiply together the number of trees encountered on each of the listed slopes?

Solution

Okay, my solution so far is general enough that I can easily figure out the answers for 1-1, 5-1, and 7-1. 1-2 will be trickier though, since I'm skipping rows. Still, shouldn't be too too difficult. It has to do with n, I think.

Right 1, down 1
  <<3a-lib>>

  (let* ((lines (split-string input))
         (n 0)
         (result 0))
    (dolist (l lines result)
      (let ((p (calc-position 1 n l)))
        (if (collisionp l p ?#)
            (incf result)))
      (incf n))
    result)
85
Right 3, down 1

Though this was done above, let's do it again, short-style.

  <<3a-lib>>

  (let* ((lines (split-string input))
         (n 0)
         (result 0))
    (dolist (l lines result)
      (let ((p (calc-position 3 n l)))
        (if (collisionp l p ?#)
            (incf result)))
      (incf n))
    result)
272
Right 5, down 1
  <<3a-lib>>

  (let* ((lines (split-string input))
         (n 0)
         (result 0))
    (dolist (l lines result)
      (let ((p (calc-position 5 n l)))
        (if (collisionp l p ?#)
            (incf result)))
      (incf n))
    result)
66
Right 7, down 1
  <<3a-lib>>

  (let* ((lines (split-string input))
         (n 0)
         (result 0))
    (dolist (l lines result)
      (let ((p (calc-position 7 n l)))
        (if (collisionp l p ?#)
            (incf result)))
      (incf n))
    result)
73
Right 1, down 2

Okay, here's the tricky one. I need to go down two when I go over one. So every step, we'll skip a line.

ORhear me out … we'll just … skip every other line. Then the slope is 1.

  <<3a-lib>>

  (let* ((lines (split-string input))
         (n 0)
         (result 0))
    (dolist (l lines result)
      (when (= (mod n 2) 0)
        (let ((p (calc-position 1 n l)))
          (if (collisionp l p ?#)
              (incf result))))
      (incf n))
    result)
50
Multiplying them together

I'm sure there's a way to grab all the results and multply them together, but I don't know what it is. For now, I'll just look at them all and .. multiply em.

(* 50 73 66 272 85)
3898725600

Shit, that's too high. Damn damn damn.

Attempt 2

I'm going to be honest, I'm not sure what the problem is here. I think I'm going to have to draw everything…

And, to make it easier, let's add another function.

  <<3a-lib>>

  (defun sled (i x y)
    "Draw a sled path over INPUT with slope of X and Y."
    (let* ((ls (split-string i))
           (n 0)
           (result))
      (dolist (l ls result)
        (let ((p (calc-position x n l)))
          (add-to-list 'result
                       (draw-line n l p)))
        (incf n))
      (reverse result)))
Right 1, down 1
  <<3b-lib>>
  (sled input 1 1)
Right 3, down 1

Though this was done above, let's do it again, short-style.

  <<3a-lib>>

  (let* ((lines (split-string input))
         (n 0)
         (result 0))
    (dolist (l lines result)
      (let ((p (calc-position 3 n l)))
        (if (collisionp l p ?#)
            (incf result)))
      (incf n))
    result)
Right 5, down 1
  <<3a-lib>>

  (let* ((lines (split-string input))
         (n 0)
         (result 0))
    (dolist (l lines result)
      (let ((p (calc-position 5 n l)))
        (if (collisionp l p ?#)
            (incf result)))
      (incf n))
    result)
Right 7, down 1
  <<3a-lib>>

  (let* ((lines (split-string input))
         (n 0)
         (result 0))
    (dolist (l lines result)
      (let ((p (calc-position 7 n l)))
        (if (collisionp l p ?#)
            (incf result)))
      (incf n))
    result)
Right 1, down 2

Okay, here's the tricky one. I need to go down two when I go over one. So every step, we'll skip a line.

ORhear me out … we'll just … skip every other line. Then the slope is 1.

  <<3a-lib>>

  (let* ((lines (split-string input))
         (n 0)
         (result 0))
    (dolist (l lines result)
      (when (= (mod n 2) 0)
        (let ((p (calc-position 1 n l)))
          (if (collisionp l p ?#)
              (incf result))))
      (incf n))
    result)

ACTUALLY

I was about to really do a lot, but then I realized something. I had the wrong number to test for mod. Here's the real right 1, down 2 code:

  <<3a-lib>>

  (let* ((lines (split-string input))
         (n 0)
         (result 0))
    (dolist (l lines result)
      (when (= (mod n 2) 1) ;; NOTE the mod should be 1, not 0
        (let ((p (calc-position 1 n l)))
          (if (collisionp l p ?#)
              (incf result))))
      (incf n))
    result)
35

NOW we can multiply everything:

(* 35 73 66 272 85)
3898725600

AND THAT IS CORRECT 😎

Interlude: A Macro

I need to write a macro to reduce boilerplate

  (defmacro aoc (input split &rest body)
    "Reduce boilerplate for AoC challenges."
    `(let ((lines (split-string ,input ,(or split "\n+"))))
       ,@body))

testing it

  <<aoc>>
  (aoc input nil
       (let ((list (seq-map #'string-to-number lines))
             (result 0))
         (catch 'return
           (while list
             (setq n (pop list))
             (dolist (m list result)
               (when (= (+ n m) 2020)
                 (throw 'return (* n m))))))))
969024

Cool, it works ^_^

Day 4

Passports!

Input

ecl:grn
cid:315 iyr:2012 hgt:192cm eyr:2023 pid:873355140 byr:1925 hcl:#cb2c03

byr:2027 hcl:ec0cfd ecl:blu cid:120
eyr:1937 pid:106018766 iyr:2010 hgt:154cm

byr:1965 eyr:2028 hgt:157cm
cid:236 iyr:2018 ecl:brn
hcl:#cfa07d pid:584111467

eyr:2029 ecl:hzl
iyr:1972 byr:1966
pid:2898897192
hgt:59cm hcl:z

pid:231652013 hcl:#602927 hgt:166
ecl:grn eyr:2025
byr:2008 iyr:1986

byr:1928 hgt:167cm
hcl:#18171d iyr:2012
ecl:oth pid:237657808 eyr:1944

hgt:73in ecl:grn byr:1931 pid:358388825 iyr:2020
hcl:#602927 eyr:2020

hcl:#efcc98 eyr:2024 ecl:hzl
byr:2030 hgt:192cm
iyr:2013 pid:7479289410

pid:053467220 iyr:2012 hgt:169cm
cid:149 hcl:#866857
eyr:2030
byr:1995 ecl:oth

hgt:162cm hcl:#efcc98 ecl:grn byr:1985 pid:419840766
eyr:2022
iyr:2020

pid:22086957 hcl:c69235 ecl:#c458c5 eyr:1986 byr:2014 hgt:72cm iyr:1934

hcl:#866857
ecl:brn eyr:2024
iyr:2017
pid:505225484 cid:144
byr:1980
hgt:170cm

hcl:#866857 ecl:gry
byr:1972 iyr:2019 eyr:2023
cid:234 pid:721290041 hgt:191cm

pid:346301363
eyr:2020
hcl:#733820 iyr:2019 hgt:177cm
byr:1998

hgt:157cm byr:1963
pid:898055805
hcl:#fffffd ecl:blu iyr:2017 cid:87
eyr:2030

pid:605900764 iyr:2011
hgt:73in ecl:hzl eyr:2024
hcl:#888785
cid:281

iyr:2010 eyr:2026 hcl:#4f7e76 pid:883386029 byr:1946 ecl:brn

hcl:z
iyr:2020 pid:9121928466 byr:2014 ecl:zzz eyr:2025
hgt:172in

hgt:151cm cid:163 pid:670884417 iyr:2012
ecl:oth hcl:#ceb3a1
eyr:2028

hcl:z cid:92 hgt:69cm
byr:2008 pid:492284612
eyr:2020 iyr:2023
ecl:hzl

byr:1933
hcl:#7d3b0c eyr:2020 hgt:170cm
pid:949064511 iyr:2010
ecl:oth

eyr:2025 byr:1989 ecl:oth cid:100 hgt:182cm
pid:629190040 iyr:2017 hcl:#b6652a

ecl:hzl cid:76 hcl:#e71392 eyr:2021 iyr:2013 byr:1995
pid:762177473
hgt:179cm

pid:198500564 eyr:2029 hcl:#733820 cid:51 iyr:2012
hgt:70in byr:1938 ecl:oth

hgt:190cm ecl:brn byr:1952 iyr:2015 hcl:#623a2f
eyr:2023

hgt:169cm hcl:#602927 byr:2001 pid:823979592 iyr:2016 eyr:2029

iyr:2010 ecl:gry
eyr:2022 hgt:156cm byr:1953 pid:434063393
hcl:#733820

pid:091724580 hcl:a7069e eyr:1984 ecl:#95d01e byr:2012 iyr:2005

eyr:2022 byr:1972 hcl:#866857 ecl:hzl pid:227453248
hgt:153cm cid:324 iyr:2018

cid:195 pid:049871343
eyr:2024 hgt:169cm
byr:1952 iyr:2010 ecl:grn

eyr:2035 pid:189cm
hgt:77 iyr:1973 ecl:#dc83d5
hcl:z byr:2004

byr:2027
pid:89338932 hcl:1de39e ecl:grn hgt:159in eyr:2034 iyr:1937

pid:076534920
hgt:152cm
byr:1969
ecl:blu
hcl:#866857 iyr:2011 eyr:2024

iyr:2019 eyr:2028
ecl:blu hgt:169cm
hcl:#888785 pid:332202163 byr:1923

hgt:65in byr:1964 iyr:2019
pid:287612987 ecl:hzl cid:213 eyr:2023 hcl:#ceb3a1

hcl:#623a2f pid:182484027
iyr:2016 ecl:brn byr:1943
hgt:71in eyr:2021 cid:344

hcl:#cdee64 iyr:2011 ecl:brn eyr:2026 hgt:176cm
byr:1985 pid:978641227

eyr:2029 ecl:brn hgt:173cm byr:1920 cid:211
hcl:#866857
iyr:2016 pid:289769625

hcl:#7d3b0c pid:770938833 iyr:2010 byr:1941 ecl:oth eyr:2029 hgt:161cm

hgt:172cm iyr:2015 ecl:gry byr:1948
eyr:2029
pid:466359109 hcl:#341e13

cid:74 pid:405199325 ecl:blu
hcl:#6b5442
eyr:1980 byr:2024 hgt:174cm iyr:2011

hgt:183cm pid:075760048 cid:78 byr:1960 ecl:hzl eyr:2030 hcl:#6b5442 iyr:2014

cid:264 hcl:#7d3b0c
ecl:blu iyr:2011 eyr:2020 hgt:182cm
byr:1929

pid:435338286 byr:1931
hcl:z ecl:amb iyr:2013 hgt:73in
cid:165 eyr:2027

pid:511898552 eyr:2025 hgt:184cm hcl:#602927
iyr:2018 byr:1989 ecl:hzl

iyr:2016
hgt:168in
hcl:#623a2f
eyr:2025 pid:310738569 ecl:#0c3039
byr:2027

pid:158cm byr:1946 ecl:grt
iyr:1920 cid:189
hcl:389bce hgt:165cm

pid:973732906 hcl:#cfa07d iyr:2010 eyr:2020 hgt:180cm
byr:1930
ecl:brn

pid:930994364 byr:1967 hgt:151cm
iyr:2011 eyr:2022

eyr:1968 hgt:75cm cid:241
iyr:2011 pid:5493866745
ecl:grt
byr:1976 hcl:#a97842

eyr:2026 ecl:oth
iyr:2016 hcl:#c0946f
byr:1929
hgt:175cm
pid:9421898537

eyr:2028 iyr:2016 byr:1962
ecl:grn hgt:186cm hcl:#cfa07d pid:432962396

iyr:2010 byr:1934 eyr:2023 hgt:180cm hcl:#cfa07d ecl:gry

cid:168
byr:1978
eyr:2027 hgt:189cm pid:802710287
hcl:#2f980b iyr:2014
ecl:grn

eyr:1970
pid:576329104
ecl:xry iyr:1954 hcl:#341e13 byr:2026
hgt:74in

eyr:2027 hgt:153cm
ecl:oth
hcl:#866857
pid:290407832 byr:1956 iyr:2017

iyr:2011
cid:128
ecl:amb hcl:#7d3b0c hgt:68in pid:743606119 eyr:2020

ecl:oth hcl:#cfa07d
byr:2016 pid:#de98ae iyr:1984 cid:194
hgt:170cm
eyr:2034

pid:526098672 hgt:168cm
hcl:#7d3b0c cid:167 byr:1923 ecl:blu iyr:2016
eyr:2030

pid:495569197 hcl:#866857 hgt:193cm
iyr:2013 eyr:2021 byr:1921 ecl:amb

ecl:amb
hcl:#a97842 pid:862249915 iyr:2012 byr:1964
cid:325
eyr:2021

iyr:1958
byr:2003
hgt:160 hcl:#18171d
ecl:hzl eyr:2020

iyr:2019 byr:1997 ecl:brn
pid:342735713 hcl:#efcc98
hgt:181cm cid:307
eyr:2027

pid:817121616 eyr:2020
iyr:2012
hgt:185cm
hcl:#18171d byr:1969 ecl:hzl

pid:381399203
ecl:oth byr:1930
iyr:2014 hcl:#6b5442 hgt:71in cid:156 eyr:2025

byr:2002 hcl:#18171d iyr:2017
pid:398245854 hgt:64in ecl:gry eyr:2025 cid:127

eyr:2028 hcl:#341e13
ecl:amb iyr:2012
pid:079796480 hgt:69cm
byr:1995

cid:315 iyr:2028
pid:775929239
hgt:162cm ecl:dne byr:1940 eyr:1952 hcl:#c0946f

iyr:2015
hgt:154cm byr:1997
ecl:grn
cid:125 eyr:2024 pid:834780229
hcl:#18171d

ecl:hzl hcl:#a97842 pid:553710574 eyr:2028
hgt:183cm cid:196
iyr:2014

pid:377912488 hgt:159cm ecl:amb eyr:2024 byr:1974
iyr:2014
hcl:#ceb3a1

eyr:2024
byr:1947 hgt:63in ecl:brn
cid:69
pid:185228911 hcl:#b6652a iyr:2016

eyr:2024
hgt:168cm hcl:#602927
iyr:2013
byr:1993
pid:681091728 ecl:gry cid:203

pid:037922164 iyr:2020
byr:1990 hgt:156cm eyr:2023 hcl:#866857
cid:97 ecl:grn

hgt:170cm pid:980455250
iyr:2011 ecl:hzl byr:1957
eyr:2030 hcl:#cfa07d

hgt:158cm
hcl:#602927
byr:2002 ecl:hzl iyr:2013
cid:99
eyr:2020 pid:48646993

byr:1955 pid:814033843 eyr:2030 hcl:#a97842
hgt:191cm iyr:2019

pid:111196491 hgt:191cm iyr:2012 ecl:blu hcl:#a97842
eyr:2026 cid:131 byr:1979

hcl:#fffffd hgt:68in
cid:121 ecl:oth eyr:2024 pid:343836937
byr:1955
iyr:2020

eyr:2025 byr:1954
pid:737517118
cid:343 hcl:#b6652a
iyr:2017 ecl:hzl
hgt:175cm

ecl:brn
iyr:2011 hgt:171cm cid:102 pid:066348279 byr:1981

ecl:oth iyr:2018 byr:1975
eyr:2029
hgt:185cm cid:226
pid:978243407 hcl:#341e13

iyr:2015 pid:918017915 hcl:#3e52b7
byr:1999 ecl:brn cid:314
eyr:2025 hgt:192cm

hcl:#19d1fa byr:1984 ecl:dne hgt:76in
iyr:2015 cid:118 pid:417075672
eyr:2020

iyr:2019
cid:120 hgt:186cm
hcl:#733820 eyr:2024 pid:423238982 ecl:brn byr:1968

hgt:70cm cid:173 pid:767014975
hcl:#866857 eyr:2039 ecl:brn byr:1985

pid:340424924
eyr:2027 hcl:#7d3b0c
hgt:168cm ecl:hzl iyr:2016
byr:1994

ecl:hzl byr:1933 pid:580425691
iyr:2010 hcl:#c0946f eyr:2024
hgt:64in

hcl:#9fe6b0 pid:913184461 ecl:grn eyr:2030
cid:262 iyr:2014

ecl:amb pid:640007768 eyr:2030 byr:2017 iyr:1988 hcl:z

byr:1977 cid:54
eyr:1939 pid:882762394 iyr:2030 hcl:#ceb3a1 ecl:blu

iyr:2011 hcl:#7d3b0c byr:1928
pid:340969354 cid:199 hgt:168cm eyr:2029 ecl:hzl

pid:729464282
iyr:2012 hcl:baae60
eyr:2026 ecl:hzl hgt:166cm byr:2019

pid:930997801 iyr:2019 eyr:2030
hcl:#866857 ecl:oth byr:1960 cid:235 hgt:73in

ecl:brn
byr:1988 hgt:179cm iyr:2017
pid:864768439 cid:305 hcl:#c0946f
eyr:2029

hcl:#7d3b0c ecl:grn
hgt:182cm eyr:2021 pid:719891314
byr:1920 iyr:2017

hgt:62cm
cid:71 ecl:brn hcl:#fffffd iyr:2025 eyr:1997
pid:175cm byr:2022

hcl:#cfa07d cid:239 eyr:2025 ecl:hzl hgt:189in byr:1980 iyr:2020
pid:703047050

byr:1951
eyr:2030
ecl:hzl
pid:130992467 hgt:157cm hcl:#341e13

hgt:175cm
hcl:#623a2f
cid:68 eyr:2025
byr:2001 ecl:oth pid:253618704 iyr:2016

hcl:#fffffd pid:379344553 ecl:grn
eyr:2026
hgt:72in byr:1974 iyr:2013

ecl:#b4e952 byr:1970 hcl:z
eyr:2039 pid:6056894636 iyr:2021 hgt:165cm
cid:328

hcl:#602927 iyr:2014 pid:890429537 byr:1957 hgt:68in eyr:2020 ecl:hzl

cid:265 byr:1961 hcl:#ceb3a1 eyr:2022 iyr:2016 hgt:184cm pid:921615309

byr:1951 eyr:2024
hcl:#341e13
ecl:amb pid:414644982
iyr:2010 hgt:159cm

iyr:2015 cid:319
eyr:2029 ecl:brn pid:380237898
hcl:#efcc98 hgt:157cm byr:1972

pid:237156579 ecl:#312a91
hgt:167cm iyr:2011 hcl:#c0946f eyr:2021 byr:1953

ecl:hzl iyr:2015 pid:10160221 eyr:2025 hgt:175cm hcl:z byr:1939

hgt:59in hcl:#18171d byr:1962 ecl:hzl
iyr:2019 eyr:2025
cid:337 pid:491938615

ecl:utc hgt:82 pid:51674655 byr:2020
eyr:1954 iyr:2029 hcl:z

pid:119530189
cid:103
iyr:2010 byr:1979
hgt:168cm hcl:#a97842 ecl:brn eyr:2029

hgt:177cm ecl:brn
byr:1990
pid:015089628 eyr:2028 hcl:#733820 iyr:2020

ecl:blu iyr:2020 hgt:189cm
hcl:#efcc98 byr:1982 pid:346500376 eyr:2021 cid:160

ecl:brn hgt:173cm iyr:2011 cid:259 hcl:#6b5442 eyr:2026
byr:1995
pid:654875035

ecl:grn eyr:2025 pid:147155222 byr:1942
cid:341 hcl:#602927
hgt:165cm
iyr:2016

pid:543171646
hgt:153cm
iyr:2019 hcl:#fffffd byr:1985 cid:266
eyr:2027
ecl:hzl

ecl:blu
eyr:2022
pid:667939101 byr:1974
cid:259 hcl:#888785

eyr:2030 byr:2016 iyr:2022
pid:86902982
ecl:zzz hgt:72 hcl:ceb867

hcl:#fffffd
ecl:grn pid:046978329
byr:1924
eyr:2025 hgt:158cm iyr:2011

hgt:150cm eyr:2028 byr:1985 ecl:gry hcl:#866857 pid:340615189
iyr:2017
cid:50

cid:171 hcl:#18171d pid:009562218 byr:1981 hgt:175cm eyr:2024 ecl:oth iyr:2017

iyr:2019
eyr:2022
ecl:brn hcl:#cfa07d pid:050270380 cid:159
hgt:151cm
byr:1951

hcl:#7d3b0c hgt:176cm iyr:2015 byr:1923 pid:348188421 ecl:blu eyr:2029

byr:1997 hgt:162cm eyr:2023 pid:445685977
iyr:2012 ecl:amb hcl:#efcc98

iyr:2017 ecl:oth eyr:2028 pid:791977055 hgt:170cm byr:1991
hcl:#623a2f

byr:1998 hcl:#fffffd
eyr:2020
ecl:gry pid:039483695 hgt:163cm iyr:2020
cid:165

ecl:hzl hgt:74in iyr:2016 pid:026214321
cid:152 hcl:#a1f179
eyr:2036 byr:2001

pid:257900949 cid:80 byr:1956 iyr:2012 hgt:165cm eyr:2030

pid:918371363
ecl:xry
iyr:2012
byr:2012 hgt:65cm
eyr:2029

pid:041789006 iyr:2018 byr:1945 eyr:2024 ecl:blu
hcl:#5ab31e hgt:171cm

ecl:gry
byr:1956 cid:318 iyr:2020 hcl:#623a2f
eyr:2030 pid:020576506 hgt:184cm

hgt:173cm iyr:2025
eyr:2023
ecl:amb pid:958983168 hcl:#866857 byr:1935

byr:1974
eyr:2040 pid:57104308 iyr:1980 hcl:z
hgt:192in cid:295 ecl:amb

pid:180cm hcl:1109f7 eyr:2039 byr:2020
ecl:dne hgt:189in iyr:1921

iyr:2013 byr:1961
hcl:#866857
eyr:2025 hgt:158cm ecl:gry

ecl:brn iyr:2013 eyr:2021 pid:978650418 byr:1980
hcl:#ceb3a1 cid:110
hgt:166cm

pid:864880558 ecl:hzl hcl:#c0946f byr:1955 eyr:2027 hgt:169cm iyr:2011

eyr:2023 hgt:191cm hcl:#866857
pid:454509887
ecl:grn byr:1938 iyr:2015

pid:793008846 eyr:2025 ecl:grn hcl:#341e13
hgt:187cm
byr:1973 cid:224
iyr:2013

hcl:#866857 eyr:2022 pid:802335395 hgt:171cm ecl:amb
iyr:2015 byr:1991

hcl:#888785 pid:768625886
hgt:180cm
eyr:2026 ecl:oth cid:178 byr:1958

pid:921387245 cid:82 hgt:190cm hcl:#c0946f ecl:grn
iyr:2015 eyr:2023

pid:0704550258 hcl:1ba8f6 iyr:2010 byr:1978 cid:130
eyr:2030 ecl:dne hgt:66cm

pid:626293279 hcl:#7d3b0c hgt:185cm ecl:oth
eyr:2020 byr:1937 iyr:2012

hgt:175
eyr:1933 ecl:gry
hcl:#7d3b0c byr:2003 pid:#5d8fcc
iyr:2012

eyr:2027
byr:1927 cid:154
ecl:gry pid:683668809 hgt:164cm
hcl:#a97842 iyr:2011

byr:1940 iyr:2014 hgt:172cm eyr:2024 pid:033678324 hcl:#10fded
cid:292 ecl:oth

iyr:1970 ecl:#201515 pid:#4cd485 eyr:2034 hgt:162
byr:2005 cid:67
hcl:#c0946f

cid:306
byr:1948
hcl:#efcc98
eyr:2024 hgt:171cm pid:440657854 iyr:2015 ecl:brn

hgt:172cm ecl:brn byr:1958 pid:054926969 hcl:#4b8065 iyr:2019

pid:45977569 ecl:amb byr:2002 hgt:71cm hcl:z iyr:1983

pid:811407848 hcl:#866857 cid:112 hgt:180cm byr:1986
ecl:brn eyr:2026

ecl:amb
byr:1992
cid:288 pid:417117245 hcl:#623a2f
iyr:2011 hgt:181cm
eyr:2021

byr:1974 hgt:192cm cid:172
eyr:2022
ecl:blu
hcl:#cfa07d iyr:2014

eyr:2024 ecl:gry
pid:874569675 byr:1960 iyr:2017 hgt:186cm
hcl:#6b5442

byr:1988 eyr:2024 iyr:2020 ecl:oth hcl:#866857 pid:227304269 hgt:170cm

ecl:grn iyr:2019 byr:2002 cid:150 hcl:#efcc98
pid:600740993
hgt:167cm eyr:2027

pid:553824537 iyr:2019 ecl:blu eyr:2025 hcl:#e21269 hgt:193cm
byr:1923

byr:2030 iyr:2019 ecl:#cb0911
hcl:#cfa07d hgt:74in eyr:2012
pid:7647207386

cid:289 hgt:128 pid:178cm iyr:2025 ecl:#4ad977 byr:2020 eyr:2036 hcl:#efcc98

cid:119 hgt:150in
hcl:z
iyr:2012
ecl:brn eyr:1975
byr:2007 pid:#0dcd32

hcl:8a1ce7 pid:0434291854
eyr:2034 iyr:2005
hgt:62cm byr:2029 ecl:utc

ecl:gry hcl:#ceb3a1 byr:1976 eyr:2024 iyr:2010 hgt:188cm
pid:636312902

hcl:#888785 byr:2027 hgt:178in iyr:2017 pid:973095872 eyr:1952

hgt:179cm iyr:2015 hcl:#ceb3a1
byr:1944 pid:182079308 cid:317
eyr:2025 ecl:hzl

hcl:#6b5442 ecl:grn eyr:2023 hgt:71in pid:829794667 byr:2000
iyr:2014 cid:192

iyr:2014 pid:096659610 hcl:#c0946f ecl:oth byr:1991 cid:180
hgt:177cm
eyr:2023

byr:2017
eyr:2036 iyr:1933
cid:225 ecl:gmt hgt:179in
hcl:b5c44d pid:99932231

hcl:#18171d
hgt:187cm eyr:2023 byr:1934 cid:286 pid:878541119 iyr:2020 ecl:amb

hgt:185cm
pid:754207134 ecl:oth eyr:2023
hcl:#a97842 cid:313 byr:1966
iyr:2015

hcl:#ceb3a1 byr:1921 eyr:2022 pid:799265846 cid:285
hgt:67in iyr:2015

iyr:2011 byr:1941
hcl:#341e13 cid:65 pid:413556937
hgt:169cm
ecl:amb eyr:2020

iyr:2016
hgt:158cm ecl:grn byr:1931 hcl:#7d3b0c

pid:574299170 iyr:2013 byr:1961 ecl:hzl hcl:#866857 hgt:168cm eyr:2022

eyr:2022 pid:245416405
iyr:2019 hgt:173cm hcl:#c0946f
ecl:brn
byr:1965

byr:1980 hgt:162cm ecl:brn pid:239318191
hcl:#fffffd
cid:58 eyr:2025 iyr:2020

pid:892646915
iyr:2012 hcl:#733820 byr:1991 eyr:2021
hgt:157cm ecl:oth

pid:310597466 eyr:2025
hcl:#cfa07d byr:1944 iyr:2018 ecl:oth
hgt:183cm

iyr:2010 hgt:187cm ecl:oth
pid:975763328
hcl:#866857 eyr:2023 cid:283 byr:1997

iyr:2020 cid:225 hcl:#efcc98 pid:424680047 ecl:blu
hgt:154cm
byr:1968 eyr:2027

ecl:oth eyr:2020 hgt:183cm hcl:#623a2f
pid:771851807
byr:1990
iyr:2017

hcl:#efcc98 ecl:blu byr:1991 hgt:191cm pid:266021118
cid:124
eyr:2025

byr:1993
ecl:hzl eyr:2020
hgt:163cm
iyr:2015 pid:831538073 hcl:#18171d

hgt:74in hcl:#420afb eyr:2028
ecl:grn pid:264469103
byr:1993

eyr:2020
cid:79
byr:1972
pid:084953331 hcl:#a97842 ecl:brn iyr:2010
hgt:170cm

iyr:2014 ecl:gry pid:094812116 eyr:2026 hgt:190cm byr:1965 hcl:#944667

hcl:#fffffd byr:1953 iyr:2014 ecl:hzl hgt:164cm
cid:123 eyr:2023 pid:546394433

iyr:2012 hgt:155cm byr:1998 pid:#2c9be6 eyr:2023 hcl:#ceb3a1 ecl:gry

eyr:2029 ecl:gry pid:752489331 iyr:2015 hgt:167cm hcl:#18171d cid:70 byr:2002

byr:1938
ecl:gry
pid:764937909 iyr:2014
hcl:#7d3b0c
eyr:2022 cid:145 hgt:184cm

cid:340
byr:1924 hgt:169cm eyr:2026
iyr:2013 ecl:amb
pid:499844992 hcl:#18171d

pid:838417672 hgt:175cm
ecl:grt iyr:2017 eyr:2025 hcl:17aa1a

eyr:2020
byr:1925 hcl:#341e13
ecl:brn cid:342 pid:047426814 hgt:156cm iyr:2012

iyr:2011 hcl:#341e13 byr:1959
ecl:amb pid:969679865

byr:1978 cid:320 hgt:180cm hcl:#435ceb pid:363518544 eyr:2023 iyr:2016 ecl:blu

iyr:2010 eyr:2028
pid:183cm byr:1948
ecl:oth cid:133
hcl:#8d3298 hgt:190cm

hcl:#6b5442 byr:1929 iyr:2019 pid:207713865 eyr:2029
hgt:166cm ecl:gry

ecl:blu iyr:2019
byr:1985 eyr:2030 hcl:#866857 hgt:155cm pid:659180287

ecl:hzl
eyr:2020 iyr:2016 pid:440624039
cid:147
hgt:61in byr:1976 hcl:#733820

hcl:#341e13 pid:178082907 eyr:2023
iyr:2015 byr:1956
ecl:amb hgt:163cm

eyr:2023
iyr:2011 hcl:#cfa07d hgt:164cm
pid:291621559 byr:1960 ecl:gry

hcl:#efcc98 byr:1976
iyr:2017 pid:394566091 cid:248
hgt:176cm ecl:hzl eyr:2026

iyr:2013 eyr:2029 hgt:152cm ecl:gry byr:1984 hcl:#623a2f pid:511780941

pid:953716819 iyr:2010 hgt:156cm ecl:amb
byr:1947
hcl:#18171d eyr:2025

eyr:2025 ecl:amb
iyr:2016
hcl:#cfa07d byr:1925 pid:322787273 hgt:168cm

hgt:59in iyr:2012
pid:916978929 byr:1959
hcl:#c0946f eyr:2021
ecl:brn

byr:2018 eyr:1929 hgt:187in
hcl:z
iyr:2003 pid:0377361331 ecl:utc

byr:1949 hcl:#fffffd pid:071791776 eyr:2030 iyr:2015 hgt:71in ecl:hzl

hcl:#341e13
hgt:154cm byr:1927 eyr:2023 ecl:blu iyr:2017
pid:639867283

hcl:z pid:315276249 byr:2026
hgt:151cm
iyr:2028 eyr:2020
ecl:hzl

hcl:#341e13 eyr:2027 byr:1981 cid:342 pid:999898177 hgt:187cm
ecl:blu iyr:2011

byr:2009
hgt:73cm iyr:1921 hcl:z
pid:181cm
ecl:xry

ecl:hzl
byr:1925
pid:034183103 hcl:#341e13 hgt:158cm eyr:2029 iyr:2010

byr:1976
iyr:2011 hgt:177cm pid:833479839 hcl:#dcab9d ecl:blu eyr:2020

cid:230 hcl:#7d3b0c byr:1954
iyr:2014 eyr:2026 pid:122150889
ecl:brn hgt:182cm

hcl:#a97842
ecl:brn hgt:187cm
eyr:2028
pid:427631634 iyr:2002 byr:2004

pid:912516995 ecl:hzl iyr:2017 hcl:#ceb3a1 byr:1929 eyr:2028
hgt:155cm

pid:019809181
cid:128 iyr:2013 hcl:#f5b9f7 byr:1931
hgt:161cm
ecl:amb

hgt:64in byr:1924
iyr:2016 eyr:2029 ecl:hzl pid:474940085 hcl:#c0946f

pid:172419213
ecl:grn
hgt:193cm iyr:2010 byr:1973 hcl:#6b5442
eyr:2027

ecl:#7b5cfd iyr:2019
byr:2016
eyr:2040 hgt:191in
cid:187 hcl:z pid:#c61084

eyr:2032 iyr:2014 pid:430247344 byr:1967
hcl:#ceb3a1
cid:241
ecl:brn hgt:178in

hcl:#623a2f iyr:2017 cid:235
eyr:2020 byr:1978 ecl:blu hgt:175cm

iyr:2013 ecl:amb hgt:174cm hcl:#866857 pid:285533942 byr:1954

hgt:152cm ecl:blu pid:952587262 eyr:2024
iyr:2019 cid:268 hcl:#602927 byr:1947

hgt:176in cid:245 byr:2011 iyr:2018
eyr:1987
hcl:z
pid:346518170
ecl:utc

hgt:180cm
iyr:2015 ecl:brn eyr:2027 pid:807494368 cid:324 byr:1980

byr:1936 hcl:#866857 ecl:blu
eyr:2021 hgt:187cm
iyr:2016 pid:244556968

byr:1950 cid:125
iyr:2020 hgt:168cm hcl:#c0946f eyr:2030 pid:758313758 ecl:blu

eyr:2021
pid:618915663 hcl:#cfa07d iyr:2018 byr:2002
hgt:157cm ecl:blu

byr:1967
ecl:brn hcl:#c0946f pid:200495802 eyr:2021 iyr:2020
cid:335
hgt:181cm

byr:1996
ecl:brn iyr:2015
eyr:2030
hcl:#fffffd cid:207
pid:022460311 hgt:158cm

eyr:2022 hgt:59cm iyr:2023
byr:1974 pid:354098699 hcl:b244f7
ecl:#219505

hcl:#866857 eyr:2025
pid:370874666
byr:1947
cid:162 ecl:oth hgt:186cm iyr:2011

ecl:hzl eyr:2029
byr:1981
iyr:2012 pid:433430792 cid:252
hgt:171cm

pid:512473844 hgt:186cm iyr:2012 eyr:2028 byr:1949 ecl:hzl hcl:#18171d

hgt:60cm iyr:1934
ecl:#4a4017 pid:3067366202 hcl:1161df
eyr:1938 byr:2008

pid:119509757 hcl:#cfa07d eyr:2022 hgt:174cm byr:1983
iyr:2015
ecl:blu

byr:1955 eyr:2023
cid:114
hcl:f1aa8a pid:609049659 ecl:grn hgt:177cm
iyr:2015

eyr:2027 cid:284
pid:654627982 byr:1964 iyr:2018 hgt:168cm
hcl:#fffffd ecl:oth

iyr:1988
hgt:191cm hcl:b87a62 byr:1990 ecl:xry
pid:996624367 eyr:1960

pid:641466821 eyr:2028 hcl:#7d3b0c
iyr:2010 hgt:175cm ecl:gry

hcl:#b6652a
ecl:oth
byr:1926 eyr:2030 iyr:2019 hgt:183cm
pid:057196056

iyr:2017
eyr:2022 pid:936841429
ecl:blu hcl:#6b5442 cid:179 byr:1927 hgt:161cm

eyr:2021
cid:289 hgt:174cm iyr:2013
ecl:grn pid:329574701 byr:1970

eyr:2021 byr:1939 ecl:gry pid:933505139 iyr:2014 hgt:173cm hcl:#7d3b0c

cid:116 hcl:045bff eyr:2030 iyr:1920
ecl:brn
byr:2030
pid:#38f7f3
hgt:155in

eyr:2028
pid:225829241 byr:1928 hcl:#cfa07d iyr:2019
ecl:oth
hgt:166cm

cid:80 byr:1936
iyr:2017
hgt:94 hcl:#2e7503 ecl:oth eyr:2030
pid:597284996

ecl:oth
iyr:2019 hgt:76in
byr:1956 pid:821874039

eyr:2026 hgt:168cm
pid:019015588
iyr:2010
ecl:amb byr:2009 hcl:#623a2f cid:159

iyr:1980 hgt:167in
pid:380644909 eyr:1966 ecl:blu byr:2004 hcl:z

eyr:2020 iyr:2013
hcl:#08ad66 pid:540886868
ecl:oth byr:1980 hgt:158cm

eyr:2026 hgt:186cm byr:1995
cid:275
hcl:z iyr:1958 ecl:blu

eyr:2026 iyr:2012
hgt:61in byr:1936 pid:390833536 cid:298 ecl:grn hcl:#623a2f

pid:393878498 eyr:2023 ecl:gry byr:1943 iyr:2010 hcl:#888785 hgt:158cm

hgt:191cm cid:197 iyr:2014 byr:1945
hcl:#fffffd
eyr:2020
pid:183948344 ecl:amb

ecl:gmt hgt:88
cid:260 iyr:2024 byr:2022 eyr:2031 hcl:z pid:#532c6e

hcl:#a97842
hgt:160cm eyr:2024 ecl:blu iyr:2015 byr:1970

byr:1964 hgt:178cm
eyr:2025
pid:813643223 ecl:brn iyr:2014
hcl:#ceb3a1

byr:1965 eyr:2024 iyr:2018
hgt:165cm hcl:#18171d ecl:grn pid:475669993

hgt:116
iyr:2024 eyr:1974 hcl:504345 byr:2010 cid:206 pid:166cm ecl:zzz

iyr:2014 eyr:2020 pid:096460673 byr:1948
hgt:153cm
ecl:blu hcl:#341e13

hcl:#ceb3a1
iyr:2017 hgt:67cm
pid:178cm byr:2028 ecl:brn
cid:293

hgt:157cm
hcl:#602927 byr:1941
iyr:2012 pid:611003211 eyr:2029

iyr:2019 byr:2000 pid:083917767 eyr:2024 hgt:172cm
cid:248 hcl:#7e4d15

byr:1946
hgt:160cm iyr:2020 hcl:#559278 pid:989139577
ecl:amb eyr:2020

pid:165cm byr:1927 cid:178 hcl:#733820 iyr:2017 hgt:156in
eyr:2029 ecl:brn

hcl:#18171d hgt:163cm eyr:2022 byr:1962 pid:639124940 cid:258 ecl:hzl
iyr:2015

cid:123 pid:4542006033
eyr:1987 byr:2010 iyr:2029 ecl:amb
hgt:191cm hcl:#18171d

hcl:z
byr:1928 iyr:1965
eyr:2022 hgt:75 ecl:oth pid:400765046

hcl:#c0946f hgt:62in
ecl:blu byr:1978 iyr:1923
cid:260 eyr:2021 pid:404628742

pid:#bf1611 ecl:grn
iyr:2018 cid:146 byr:1948
eyr:2025 hcl:#fffffd hgt:87

pid:767547618
iyr:2018 hcl:#b6652a eyr:2029 hgt:165cm ecl:hzl byr:1937

ecl:blu iyr:2019 pid:960083875 eyr:2027 hgt:71in hcl:#c0946f
byr:1921

iyr:2011
pid:9562042482
hcl:z hgt:59cm
eyr:1994 cid:258 ecl:#6c1bcc byr:2025

eyr:2028 pid:494999718 byr:1928 hgt:176cm
iyr:2015 ecl:oth hcl:#733820

cid:78 eyr:2020 hgt:160cm byr:1947 ecl:blu
hcl:#b6652a iyr:2016 pid:069457741

hcl:#6b5442 iyr:2010
byr:1971
eyr:2028 hgt:169cm ecl:brn pid:528961949

eyr:2028
hcl:#7d3b0c
byr:1952
ecl:hzl
cid:317 iyr:2016
pid:832169844

hcl:#c0946f
ecl:brn
iyr:2017 eyr:2028
pid:161390075 byr:1993 cid:50
hgt:171cm

ecl:#ae12d3 hgt:74cm cid:239 hcl:z pid:345439730 iyr:1924 byr:2029 eyr:2031

A

Problem

You arrive at the airport only to realize that you grabbed your North Pole Credentials instead of your passport. While these documents are extremely similar, North Pole Credentials aren't issued by a country and therefore aren't actually valid documentation for travel in most of the world.

It seems like you're not the only one having problems, though; a very long line has formed for the automatic passport scanners, and the delay could upset your travel itinerary.

Due to some questionable network security, you realize you might be able to solve both of these problems at the same time.

The automatic passport scanners are slow because they're having trouble detecting which passports have all required fields. The expected fields are as follows:

byr (Birth Year)
iyr (Issue Year)
eyr (Expiration Year)
hgt (Height)
hcl (Hair Color)
ecl (Eye Color)
pid (Passport ID)
cid (Country ID)

Passport data is validated in batch files (your puzzle input). Each passport is represented as a sequence of key:value pairs separated by spaces or newlines. Passports are separated by blank lines.

Here is an example batch file containing four passports:

ecl:gry pid:860033327 eyr:2020 hcl:#fffffd
byr:1937 iyr:2017 cid:147 hgt:183cm

iyr:2013 ecl:amb cid:350 eyr:2023 pid:028048884
hcl:#cfa07d byr:1929

hcl:#ae17e1 iyr:2013
eyr:2024
ecl:brn pid:760753108 byr:1931
hgt:179cm

hcl:#cfa07d eyr:2025 pid:166559648
iyr:2011 ecl:brn hgt:59in

The first passport is valid - all eight fields are present. The second passport is invalid - it is missing hgt (the Height field).

The third passport is interesting; the only missing field is cid, so it looks like data from North Pole Credentials, not a passport at all! Surely, nobody would mind if you made the system temporarily ignore missing cid fields. Treat this "passport" as valid.

The fourth passport is missing two fields, cid and byr. Missing cid is fine, but missing any other field is not, so this passport is invalid.

According to the above rules, your improved system would report 2 valid passports.

Count the number of valid passports - those that have all required fields. Treat cid as optional. In your batch file, how many passports are valid?

Solution

I'm thinking the best way to do this is to split each passport into a… alist ? Let's try it!

  <<aoc>>
  ;; required fields
  (setq *rqfs*
        '(byr
          iyr
          eyr
          hgt
          hcl
          ecl
          pid))
  ;; optional fields
  (setq *opfs*
        '(cid))

  (defun parse-record (rec)
    "Parse a record of form KEY:VAL [KEY:VAL]... into an alist."
    (let ((fields (split-string rec))
          (result))
      (dolist (f fields result)
        (let ((p (split-string f ":")))
          (add-to-list 'result (cons (car p) (cadr p)))))))

  (defun validate-record (record)
    "Validate a RECORD -- does it have all required fields?"
    (let ((result t))
      (dolist (required-field *rqfs* result)
        (unless (assoc-string required-field record t)
          (setq result nil)))
      result))

  (aoc
   input "\n\n"
   (let ((records)
         (result 0))
     (dolist (record lines result)
       (let ((rec (parse-record record)))
         (if (validate-record rec)
             (incf result))))))

So far, biggest lesson is: USE assoc-string !!!!

226

Huh I did a table-based solution before, and got 224, too low. But with this incf one, I got the right answer. Who knows ̅\_(ツ)_/̅1

B

Problem

The line is moving more quickly now, but you overhear airport security talking about how passports with invalid data are getting through. Better add some data validation, quick!

You can continue to ignore the cid field, but each other field has strict rules about what values are valid for automatic validation:

byr (Birth Year) - four digits; at least 1920 and at most 2002.
iyr (Issue Year) - four digits; at least 2010 and at most 2020.
eyr (Expiration Year) - four digits; at least 2020 and at most 2030.
hgt (Height) - a number followed by either cm or in:
    If cm, the number must be at least 150 and at most 193.
    If in, the number must be at least 59 and at most 76.
hcl (Hair Color) - a # followed by exactly six characters 0-9 or a-f.
ecl (Eye Color) - exactly one of: amb blu brn gry grn hzl oth.
pid (Passport ID) - a nine-digit number, including leading zeroes.
cid (Country ID) - ignored, missing or not.

Your job is to count the passports where all required fields are both present and valid according to the above rules. Here are some example values:

byr valid:   2002
byr invalid: 2003

hgt valid:   60in
hgt valid:   190cm
hgt invalid: 190in
hgt invalid: 190

hcl valid:   #123abc
hcl invalid: #123abz
hcl invalid: 123abc

ecl valid:   brn
ecl invalid: wat

pid valid:   000000001
pid invalid: 0123456789

Here are some invalid passports:

eyr:1972 cid:100
hcl:#18171d ecl:amb hgt:170 pid:186cm iyr:2018 byr:1926

iyr:2019
hcl:#602927 eyr:1967 hgt:170cm
ecl:grn pid:012533040 byr:1946

hcl:dab227 iyr:2012
ecl:brn hgt:182cm pid:021572410 eyr:2020 byr:1992 cid:277

hgt:59cm ecl:zzz
eyr:2038 hcl:74454a iyr:2023
pid:3556412378 byr:2007

Here are some valid passports:

pid:087499704 hgt:74in ecl:grn iyr:2012 eyr:2030 byr:1980
hcl:#623a2f

eyr:2029 ecl:blu cid:129 byr:1989
iyr:2014 pid:896056539 hcl:#a97842 hgt:165cm

hcl:#888785
hgt:164cm byr:2001 iyr:2015 cid:88
pid:545766238 ecl:hzl
eyr:2022

iyr:2010 hgt:158cm hcl:#b6652a ecl:blu byr:1944 eyr:2021 pid:093154719

Count the number of valid passports - those that have all required fields and valid values. Continue to treat cid as optional. In your batch file, how many passports are valid?

Solution

Okay, this shouldn't be too bad. I just need to add to my validate-record function.

  <<aoc>>
  ;; required fields
  (setq *rqfs*
        '(byr
          iyr
          eyr
          hgt
          hcl
          ecl
          pid))
  ;; optional fields
  (setq *opfs*
        '(cid))

  (defun parse-record (rec)
    "Parse a record of form KEY:VAL [KEY:VAL]... into an alist."
    (let ((fields (split-string rec))
          (result))
      (dolist (f fields result)
        (let ((p (split-string f ":")))
          (add-to-list 'result (cons (car p) (cadr p)))))))

  (defun validate-byr (byr)
    "BYR should be four digits; between 1920 and 2002."
    (<= 1920 (string-to-number byr) 2002))

  (defun validate-iyr (iyr)
    "IYR should be four digits; between 2010 and 2020."
    (<= 2010 (string-to-number iyr) 2020))

  (defun validate-eyr (eyr)
    "EYR should be four digits; between 2020 and 2030."
    (<= 2020 (string-to-number eyr) 2030))

  (defun validate-hgt (hgt)
    "HGT should be a number followed by CM or IN.
        If CM, the number should be between 150 and 193.
        If IN, the number should be between 59 and 76."
    (cond ((string-match (rx "cm" eos) hgt)
           (<= 150 (string-to-number hgt) 193))
          ((string-match (rx "in" eos) hgt)
           (<= 59 (string-to-number hgt) 76))
          (t nil)))

  (defun validate-hcl (hcl)
    "HCL should be six hexadecimal digits preceded by a #."
    (string-match (rx bos "#" (repeat 6 hex-digit) eos) hcl))

  (defun validate-ecl (ecl)
    "ECL should be one of AMB BLU BRN GRY GRN HZL OTH."
    (string-match (rx bos
                      (or "amb"
                          "blu"
                          "brn"
                          "gry"
                          "grn"
                          "hzl"
                          "oth")
                      eos) ecl))

  (defun validate-pid (pid)
    "PID should be nine decimal digits."
    (string-match (rx bos (repeat 9 digit) eos) pid))

  (defun validate-record (record)
    "Validate a RECORD -- does it have all required fields?"
    (let ((result '()))
      (dolist (required-field *rqfs* result)
        (if-let ((field (car (assoc-string required-field record t)))
                 (value (cdr (assoc-string required-field record t))))
            (progn
              (push (cond ((string= field "byr")
                           (message "%S %S %S" field value (validate-byr value))
                           (validate-byr value))
                          ((string= field "iyr")
                           (message "%S %S %S" field value (validate-iyr value))
                           (validate-iyr value))
                          ((string= field "eyr")
                           (message "%S %S %S" field value (validate-eyr value))
                           (validate-eyr value))
                          ((string= field "hgt")
                           (message "%S %S %S" field value (validate-hgt value))
                           (validate-hgt value))
                          ((string= field "hcl")
                           (message "%S %S %S" field value (validate-hcl value))
                           (validate-hcl value))
                          ((string= field "ecl")
                           (message "%S %S %S" field value (validate-ecl value))
                           (validate-ecl value))
                          ((string= field "pid")
                           (message "%S %S %S" field value (validate-pid value))
                           (validate-pid value))
                          (t "WHAT"))
                    result))
          (push nil result)))
      (every (lambda (i) (not (eq i nil))) result)))

  (aoc
   input "\n\n"
   (let ((records)
         (result 0))
     (dolist (record lines result)
       (let ((rec (parse-record record)))
         (if (validate-record rec)
             (incf result))))))
160

Damn, 203 is too high. At least I'm getting a somewhat meaningful number; it turns out regexen in Emacs are totally fucked. That's why there's a whole macro to make them easier to write, I guess.

Okay, too high that means that I'm getting false positives somewhere.

SUCCESS

OMG. I just had to (push nil result) on failure — duh. I had removed that because I'd had (push result nil) earlier, which of course isn't the right order of operations. But that was allowing some bad things to be ignored, which made my answer too high. Ah well.

Day 5

Input

  FFFBFBFLRR
  FFBBFFFRLL
  FBFBFFBRLR
  FFFBBFBRRL
  BFFFBBFRRL
  FFBFBFFLLR
  FBFBBFFRLL
  FFBBFBBLLL
  BFFFBBFLLR
  FBBFFBBRLR
  FBFBBBBLLL
  BFFBBBFLLR
  BBFFBFBLRR
  FBBBFFBRRL
  FFFBFBBLRL
  FFBFBFBRLR
  FBBBBFFRRL
  FBBBBFBLLR
  BFBBBBFRRR
  BFBFFBBLRL
  FBBFBBFRLL
  FFBBBFBRLR
  FBBFFFBRLL
  FBFBBFBLRR
  FFFBBBFLLL
  FBFFBBFLRL
  BFFFBFFLLR
  FBFBBBBLRL
  FBBFBFFRLR
  FBFBBBBRLL
  FFBFFBFLLR
  BFFBFFBRLL
  FBBBBFFLRL
  BFFBFBBRLR
  FFBFFFFLLR
  BBFFBBFRLR
  BFBFBBBRRL
  BFFBBBBLRR
  FFBBBBBRLL
  FFFBBFFRLR
  BBFFFFBLRL
  BFBBFBFRRL
  BBFFBBFRRL
  FBFFFFBRLR
  FBBFBBBRLR
  BBFBFFFLLL
  BFBFBBBRLL
  BFFFFFFLRL
  FBFBFBFRRR
  BBFFFFFLRR
  FFFBBFBLLR
  FBFFBFBRLL
  BFBBFBFLLR
  FFBFBFFLRL
  BFBFFBFRRR
  FBBBBBFRLR
  FBBFFBBLLR
  FBFBBFFLRL
  FBFFFBFRRL
  BFFBFFFLRR
  FFBFBFBLRL
  FBFFBBBLRR
  BFBBFFFLLR
  FBFBBBBRLR
  FBFFFBBRRL
  FFFBBBFRRL
  FBBBBBBLRR
  FBBBFBBRRL
  FBBBFBBRRR
  BFFFBFBLRL
  FBBBFFBRLR
  BFBFFFBRRR
  BFBBFBBLRL
  BBFFBBFLRR
  FFFBFBFLLR
  FFBBBBFRRL
  BFBFBFFRRR
  FBFBBBBRRR
  BFFFBFFRLL
  BFBBFBBLLL
  FBFBFBBRLR
  BFFFBFBRLL
  FFBBFFBRLL
  FBFFBBFRLL
  FBFBFFFRRR
  FFBFBBBLLL
  BBFFBBBLRR
  FBBFFBBRLL
  BFFFFFBRRL
  FBBFFBFLLL
  FBFBFBFLRL
  BFFFFBBLRL
  BFFBBFBRLL
  BFBFFBFRRL
  BFBFFFFLRR
  FBFFFBFRRR
  BBFFBBBLLR
  FBFBFBFRRL
  BFFBFBBLRL
  FFFBFBBRLR
  BBFFFBFLRL
  BFBFFBFLLR
  BBFFBFBRRL
  FBBFFFBRRL
  FFBFFFFLLL
  BFBFBFFLLL
  BFBFFFBLRR
  FBBBFFBLRR
  FFBBFFBLLR
  BBFFFBBLRR
  BBFBFFBLRL
  BFFFBBFRLL
  FBFFBFFRRR
  FFBBBFBLRL
  FFBFBFFRRR
  BFFFFFFLLR
  BFFFFBBRRL
  FBFBBBFLRL
  BFFFFBFLRL
  FBFBBBFRLL
  FFBFBFBRRR
  FFFBFBBRRR
  FBBBFFBRLL
  FBFFBBFRLR
  FFBFBBFRLR
  FBBFFFBLLL
  BBFFBBBRLR
  FBBFFFFLRR
  BBFFFBFRLL
  FBBBBBBRLR
  BFBBFFBLLR
  BFBFBBBLRR
  FFBBFBBRLL
  FFFBFBBLLL
  BFBBBFFRLR
  FBFBFFFLRL
  BFFBBFBLLR
  BFBBFFFLRL
  BFBBFFBLRR
  FBFFFFBLRL
  FBFBFBFLRR
  FBBFFFFLRL
  FFBFBBBLLR
  FBFBFBBRRR
  BFBBBBFLRL
  BFBFBFBLRL
  BFFBFBFLRL
  BBFFFFBRRL
  FFBFFFBLRR
  BBFBFFBRRL
  FFBBBFFLRR
  BFFBBBBLRL
  FBBBFFFLLR
  FFFBBBFRLR
  BBFBFBFLLR
  BFBFBFFRRL
  FBFBFFBRRR
  FBFFBFFLRL
  FFBBFFFLLL
  BFFBBFBLLL
  BBFFFFFLRL
  FFBFBBBRRR
  FFBFFBFLLL
  FFBBBBFLRL
  FFBBFFFRLR
  BFBFFFBLLL
  FBFFFFFRRR
  FBBFFBBLRL
  BFFFFBFRRL
  BFFFFBFRLR
  FFBFBFFRLL
  BBFFBFFRRL
  FBFFBBBRRR
  FFBBBFFRRR
  BFFBBBBRLR
  FFBBFBBRLR
  BFBBFBBRLR
  FBFFBBBLLR
  BFFFFBBLRR
  FBBFBFBRRL
  FBBFBFBRLR
  FBBBBFFLRR
  FBFFFFBLRR
  FFBFBBFLLL
  FBBFFBBLRR
  FBFBFFFLLL
  FBFFFBBLRR
  FBBFBFFLLL
  FBBBFBFRLL
  FFBBFBBLRL
  BFBFFBBRRR
  BFFBBBBLLR
  FBFFBFBLRR
  FBBBBBBLLR
  FBBFBBFLRL
  BFBFBFBRLR
  FBBFFFFRLR
  BFFBFBBLLL
  BFBFFFBRLL
  BFFBBBBRLL
  BFBFBBFLLR
  FBFFBFFRLR
  BFFBBFBRRR
  FBBBFFFLLL
  BFFBFBFRRL
  FBFFBFFRLL
  FFBBBFFLRL
  FBFFBFFRRL
  BBFFBFBRLR
  FBBFBBBRLL
  FBFBBFBRRL
  FBFBBFFLLR
  BFFBFFBLRR
  FFBBFBFRRR
  BFFBBBFRRL
  FFBFBFBRRL
  BBFFBFFLLR
  FBBBBFFLLR
  FBBFBFBLLL
  BFBBBBFRLL
  FFBBBBFLLL
  FBBBFBBRLL
  BFFBFBFLLR
  FBFFFFFLLR
  FBBFBFBRLL
  FBFBBBFLLR
  FBFBFBBLLL
  FFFBBBBLLR
  FFBBBBFRRR
  FBBFFFBLRL
  BBFFBFBLLR
  BFBBFFFRLR
  BBFBFFBRLL
  BFBBBFBLRL
  BFBBBFFRRL
  FBFBFFBRLL
  BBFBFFFLRL
  BFBFBFBRRL
  BFFFBFFLLL
  FBFFFFFLLL
  FBFBBBBRRL
  FBFFBFBRRL
  BFBFBFFRLR
  FBFBFFFRRL
  BFBBBBFLLR
  FBBBBBFLRL
  FBBBFFBLLL
  FBBBFFFRRL
  BBFBFBFRRR
  FFBFFBBRRL
  FFBFBBFRRR
  BBFFFBFLLL
  BBFFBFBRRR
  BFFBBBFLRR
  FBFFFFBRLL
  FBFFBBBLLL
  FFFBBBFLLR
  BBFBFFBLLL
  FBFBFBFRLR
  BFBFBFBLLL
  BBFFFFBRRR
  FBBBBFBRRR
  FBFFFBBRLR
  FFFBBFFLLL
  FBBFFBFLRR
  BFFFBBBRLL
  FBBFBFBLRL
  FFBFFFFLRL
  FFBFFFBLLR
  FBBFBBBRRL
  BFBBFBFRLL
  FFBBBBBLRR
  BFFBBFFLRR
  FFBFFFBRRR
  BFFFFFFRLL
  BFFBFFBRRR
  FFFBBBFLRL
  FFBFBFBRLL
  BBFFBBBRRL
  BBFBFFFRRR
  BBFBFBFLRL
  FBBFBBBLRR
  FFBBFBFRLR
  BFBFBFBLRR
  FFFBBBBRRL
  BFFFFBBLLL
  FFFBBBFLRR
  FFBBFFBRRL
  FBFFBFFLRR
  FBFFBBFRRL
  BFBBFBBRRL
  BBFFBFBRLL
  FBBFFFFRRL
  FFBBFFBRLR
  BBFFFFBRLR
  BBFBFBFRLL
  FBBFBBBRRR
  BFFBBBBRRL
  BFFBBBBLLL
  BFBBFBBRLL
  BFFBBBFLRL
  FBFFBFBLRL
  BFFBBFFLLL
  BFBFBBFRLL
  FBBFFFBRRR
  FFBFFBFLRL
  FFBFFFFRLR
  BFBBFBBLLR
  BFBFBFBRRR
  FBBFFFFLLR
  FFBBFBBRRL
  BFFBFFFRRL
  FBFBBBFRRL
  FBBFFFFLLL
  BFFFFFFRRL
  BFBFFFBLLR
  BFBBFFBRRR
  BFFBFFFLLR
  FFBBBFBLLL
  BFFBBBFLLL
  FBFFFBBRRR
  FBBBBBFLLL
  BFBFFFFRRL
  FFBBFFBRRR
  BFBFBFFLLR
  FFFBFBBLLR
  BFBBFFBLRL
  FBFBBFFRRR
  BFBBBFFLLR
  FBBFFFBLLR
  BFFFBBFLRR
  BFFFFBBRLR
  FBFFFBBLRL
  BFBBBFBLRR
  FBFFBFBLLR
  BFBBFFFRLL
  FFBBFBFLLL
  FFBFFFBRRL
  FFBBFBBLRR
  FFBFBBFLRL
  FFFBBFFRRR
  BFBFFBFLRR
  BBFFFFBLRR
  FFBFBBFLRR
  FFFBBFFRLL
  FBBBFBBRLR
  BBFFFBBRRL
  FFFBFBFRRL
  FBBBBBBRRR
  FFBBBFBLRR
  FBBFBFFLRL
  FBBBFFFRRR
  FBBFFBBRRR
  BFFFFBBRRR
  FBBFFBFRLR
  BFFBFBFRLR
  BFBBBFFLRR
  FFBFFBFLRR
  BFBFFFBLRL
  BFFBFBFRLL
  FBBBBFBLLL
  BBFBFFFRRL
  FFBBFFBLLL
  FFBFFBBRLR
  FFBBBFBRRL
  FFBBFFFLRR
  BBFFBFFLRR
  BFFFBFFRRL
  FBFBBFBRRR
  FBFFFBFLRL
  BBFBFFBLRR
  BFFBFBFRRR
  BFFFFFFLLL
  FBBBFFBLRL
  FBBBFBFRRL
  BFFBFFBRLR
  BFBBBFFRRR
  BFFBFFFRRR
  FFFBBBBLLL
  FFBBBFBRRR
  FFBBFBFLLR
  BFBBBFBLLL
  FBBFBBBLLL
  BBFBFBFLLL
  BFBBBFBRRR
  BFBFBBFRLR
  FBFFBFBRLR
  BFFBFFFRLL
  BFBBFFBRRL
  FFBBFBFLRR
  FFBBBFBLLR
  BBFBFFFRLR
  FFBBFBBLLR
  FBFFFBBLLR
  FBBFBFBLLR
  FFBBFBFRLL
  BFFFFFBLLR
  BFBFBFBLLR
  BFBBFFBLLL
  FBBBBFBLRR
  BFBBBBFLLL
  BFFBBFFLLR
  FBFBFFFRLL
  FBBBBBFLLR
  BBFBFFBLLR
  BFBFBFFLRR
  FBBBBFFRLR
  FFFBFBBRRL
  FFFBBFBLLL
  BFBBBBFLRR
  BFBBBBBLRR
  FBBFBBFLLL
  BFFFBFBRLR
  FBBFBFFLRR
  FBFFFBBRLL
  BFFFFFBRRR
  BFFBBBFRLL
  FFBFBFBLLL
  BFBBFBFLRL
  FBBBBFFLLL
  FBBFBFFRRR
  FFFBBBBRLR
  BFBFBFFLRL
  FFBBBFFRRL
  BBFFBFFLRL
  BFFFBBBRRL
  FBFFFFFLRL
  BBFFBFFRLL
  BFFFBBFRLR
  BFBFFBBRLR
  FBFBFBBLLR
  FBBFFBBRRL
  BBFFBFFRLR
  FFBFFBBRRR
  BBFFFBBRLL
  BFBFBFBRLL
  FBFBBBBLLR
  FBFBFBFLLL
  FFBFBBBLRL
  BFFBFBBLRR
  BBFFFFFRRR
  FFFBBFFLRL
  BBFFFBFLRR
  FFBFFBFRLL
  FBFFBBFLLR
  FBFFFFBLLR
  FFBBBBFRLL
  FFFBBFFLRR
  BBFFFFFLLL
  BBFBFBFLRR
  FFBBBBFRLR
  BBFFFBBLLL
  FFBFBBFRLL
  BFFFFFFLRR
  FFBFFFBRLL
  FBFFFFFRRL
  BBFFFBBLLR
  FFFBBFBRLR
  BFFBBFFRRL
  FBBBBFFRLL
  BFBBFFBRLR
  BFFFBFBLRR
  BFBFFBBLLR
  BFFBFBBRRR
  BBFFFBFRRR
  FFBBBFFRLL
  BFBBFBBRRR
  FFBBBBBRLR
  BFFFBBBRLR
  BFFFBBFLLL
  FFBFFBBLRL
  FFBBFBFLRL
  FBFBFBBLRL
  BFFBBFBRLR
  FBBBBFBRRL
  FBFBBBFRRR
  BBFBFFBRRR
  BBFBFBFRRL
  FBBBBFBRLL
  FBFFFBBLLL
  BFBFBBFLLL
  FBBBBFFRRR
  FBBFBBFLRR
  FFBFFFFRRL
  FFFBFBFRLL
  FBFBBFBRLR
  FFBBBFFLLR
  FBFFBBFLLL
  FFFBBBBRRR
  BFFFFBFRRR
  BFBFFFFLRL
  FBFBFFBLLL
  BFFBBBBRRR
  BFFBFBFLLL
  FBFBBFFLLL
  FBBFBBFLLR
  FBBFBFFLLR
  BBFFBFFRRR
  FBBBBBFLRR
  FFBFBBBRLL
  FBBBBBBLLL
  BFBBFBBLRR
  FBFBFFFRLR
  FFBBBBBRRL
  FBFFFFBRRR
  FBBFFBFRRR
  FFFBBBBRLL
  FBBFFFFRRR
  BFFBFFBLRL
  FFFBBBBLRR
  BFBBBBFRRL
  BFFFFBBLLR
  BFFFFFFRLR
  BFFBBFFRLR
  BFFBBFBLRL
  BBFFFFBLLL
  BFFFFBBRLL
  FBBFFBFRLL
  FFFBBFBLRR
  BBFBFFBRLR
  BFFFBBBLRL
  BFBBFFFRRL
  BFBFFBFRLL
  BFFBFBBRRL
  FBFFBFFLLL
  BFBBFFBRLL
  BFBBBFFLRL
  FFFBFBFRLR
  BFFBFFBLLR
  BBFFFFBLLR
  FFBBFBBRRR
  FBBFBBFRRR
  FFBBBFFLLL
  BFBBFFFLRR
  FFBFFBFRRR
  FBBFBBFRLR
  FBFBFFBLRL
  BBFFBFBLRL
  BFFFFBFLRR
  FBBBFFFRLL
  FFFBBFFRRL
  FFBFBFFRLR
  FFBBBBBLLR
  BFFBBFBRRL
  BFFBFBFLRR
  FFFBFBBRLL
  FBFBBBBLRR
  BFBFFFBRRL
  FFBFBBBRRL
  FFBFBFFLRR
  FFBFBFBLRR
  BFFBBFBLRR
  FFFBFBFLRL
  BFFBFBBRLL
  BFFBFFFRLR
  FFBBFFBLRR
  FBBBBBFRLL
  FBFBFBFRLL
  BFBBBBBRRR
  BBFBFFFLLR
  FFBFFFFRLL
  FFFBBFFLLR
  BFBBFFFRRR
  FBBBFBFLLR
  BFBBBBBRRL
  FBBBBBBLRL
  FBBBFBFLLL
  BFFBFFBLLL
  BFFBFFBRRL
  FBFFBFBRRR
  FBFBFBBLRR
  BFFFBFFRLR
  FBFBFBBRRL
  BFBBBBBLLL
  FBFFBBFLRR
  BBFFFBBRRR
  FFFBFBBLRR
  FBBFFBBLLL
  BFFFFFBRLL
  BBFBFBFRLR
  BFFFBFFLRR
  FBFBFFBLRR
  BFBBBFBRLR
  BBFFBFBLLL
  FFBBBBFLLR
  FBBBFBFRLR
  FBBBBBFRRL
  FBBBFFBRRR
  FFBBBBFLRR
  BBFFBBBRRR
  BFFFFBFLLR
  FBFFBBFRRR
  BBFFFFFRRL
  BBFFBBBRLL
  FBFFFFBRRL
  FBFFBBBLRL
  BFFFFFFRRR
  BFFFBBBLLR
  FBFBBFBLRL
  BFBFBBBLRL
  FFBBFBFRRL
  FBFFBBBRLR
  BFFBBBFRLR
  FFBFBBBLRR
  BFFBFFFLLL
  FBBBFFBLLR
  BFBFBBFRRL
  FFBFFBBLRR
  BBFFFBBRLR
  FFBFFBBRLL
  FBFFFFFRLR
  FBBBFBBLRL
  BBFFFBFLLR
  FBBFFFFRLL
  BFFFBBFLRL
  BFBBBBBRLR
  BFFBFBBLLR
  FFBBFFBLRL
  BFBBBFBRLL
  BFBBFBFRRR
  FFBBFFFLRL
  FFBFFFBLLL
  FFBFFBBLLR
  BBFFFBFRRL
  BFFBBFFLRL
  FBBFFBFLRL
  BFFFBBBRRR
  FFBBFFFRRL
  FFBFBFFRRL
  FBBBBFBLRL
  BBFFBBFLLR
  FBBBBFBRLR
  BFBFFBFRLR
  FFBFFBBLLL
  FFBBBBBLLL
  BFBFBBFRRR
  BBFFFFFRLL
  FBFFFBFRLR
  BFBBBBFRLR
  FBBFFFBRLR
  BFFFFFBLRR
  FBFFBBBRRL
  FBBBFBFLRL
  BFFFBFFLRL
  BFBFBBFLRR
  BFBBFBFRLR
  FFBFFBFRLR
  BBFFFBBLRL
  BFBFFBFLLL
  BBFFBBFRLL
  FBBBBBBRRL
  FFBBFFFLLR
  FFFBBBBLRL
  BBFFBFFLLL
  FBBBFFFLRR
  FBFBFBFLLR
  FFBFBFFLLL
  FFBFFFBLRL
  BFBFFBBLLL
  FBFBFFFLRR
  BBFFBBFLRL
  BFFFBFFRRR
  FBFFBBBRLL
  FFFBBBFRLL
  FBFFFBFLLL
  BBFFFBFRLR
  BBFFBBFLLL
  BBFBFFFRLL
  BBFFBBBLLL
  FBFBBFBLLL
  FBBFBBBLRL
  FBFFFFFLRR
  FBFBBFBRLL
  FFFBBFBRLL
  FBBBFBFLRR
  FBFBFFFLLR
  FFBFFFFRRR
  BFFBBFFRLL
  BBFFFFBRLL
  BFBBBFBLLR
  BFBBFBFLLL
  FBBBBBFRRR
  FFBFBBBRLR
  BFFFFBFLLL
  BFFFFFBRLR
  BFBFFFFLLL
  BFBFFBBRRL
  FFBFFBFRRL
  FBBBFBBLRR
  BFBFFBFLRL
  FBBBBBBRLL
  FFFBBFBLRL
  FFBFBBFLLR
  BFBFBBBLLR
  FBFBBFFRLR
  FBFBFFBLLR
  BBFFBBBLRL
  BFBFFBBLRR
  FFBBFFFRRR
  FBFBBBFRLR
  BFBBFBFLRR
  FBBFBFFRRL
  FBFBBFFLRR
  FBBFBFBRRR
  FBFBBBFLRR
  BFBBBBBLLR
  FBFFFBFLLR
  FBFBBFBLLR
  FFBFFFFLRR
  BFBFBBBRLR
  FBFFFFFRLL
  FFBBBBBLRL
  BFBBBFFLLL
  BBFFFFFLLR
  BFFFBBFRRR
  FBFBFFBRRL
  FFFBBFBRRR
  FBBBFBBLLR
  BFFFFBFRLL
  BFBFBFFRLL
  BFBFBBFLRL
  FFBBBFFRLR
  BFBFBBBLLL
  BFFFBBBLRR
  BFBBFFFLLL
  FBFBFBBRLL
  BFFFFFBLLL
  BBFBFFFLRR
  BFBFFBBRLL
  FFBFBBFRRL
  FBFBBBFLLL
  FBFFFFBLLL
  FBFFBFFLLR
  FBBFBBFRRL
  BBFFBBFRRR
  BFFFBFBRRL
  BFBFFFBRLR
  FBBFFBFLLR
  BFBFFFFRLL
  BFBFBBBRRR
  BFBFFFFRLR
  FFBFBFBLLR
  FBFFFBFLRR
  FFBBBBBRRR
  FBBFFFBLRR
  FFBFFFBRLR
  BFFFBFBRRR
  FBBFBBBLLR
  BFBBBBBLRL
  FBBBFFFLRL
  BFFBBFFRRR
  BFBBBFFRLL
  BFBFFFFLLR
  BFFBFFFLRL
  BFBFFFFRRR
  BBFFFFFRLR
  FBFFFBFRLL
  FFFBBBFRRR
  BFFFBFBLLR
  FBBFBFFRLL
  FBBBFBBLLL
  BFBBBBBRLL
  BFFBBBFRRR
  FFFBFBFRRR
  BFBBBFBRRL
  FBFFBFBLLL
  FBBBFFFRLR
  FBFBBFFRRL
  FBBFFBFRRL
  FBBFBFBLRR
  BFFFFFBLRL
  FBBBFBFRRR
  BFFFBBBLLL
  FFBBBFBRLL

Part 1

Problem

— Day 5: Binary Boarding —

You board your plane only to discover a new problem: you dropped your boarding pass! You aren't sure which seat is yours, and all of the flight attendants are busy with the flood of people that suddenly made it through passport control.

You write a quick program to use your phone's camera to scan all of the nearby boarding passes (your puzzle input); perhaps you can find your seat through process of elimination.

Instead of zones or groups, this airline uses binary space partitioning to seat people. A seat might be specified like FBFBBFFRLR, where F means "front", B means "back", L means "left", and R means "right".

The first 7 characters will either be F or B; these specify exactly one of the 128 rows on the plane (numbered 0 through 127). Each letter tells you which half of a region the given seat is in. Start with the whole list of rows; the first letter indicates whether the seat is in the front (0 through 63) or the back (64 through 127). The next letter indicates which half of that region the seat is in, and so on until you're left with exactly one row.

For example, consider just the first seven characters of FBFBBFFRLR:

Start by considering the whole range, rows 0 through 127.
F means to take the lower half, keeping rows 0 through 63.
B means to take the upper half, keeping rows 32 through 63.
F means to take the lower half, keeping rows 32 through 47.
B means to take the upper half, keeping rows 40 through 47.
B keeps rows 44 through 47.
F keeps rows 44 through 45.
The final F keeps the lower of the two, row 44.

The last three characters will be either L or R; these specify exactly one of the 8 columns of seats on the plane (numbered 0 through 7). The same process as above proceeds again, this time with only three steps. L means to keep the lower half, while R means to keep the upper half.

For example, consider just the last 3 characters of FBFBBFFRLR:

Start by considering the whole range, columns 0 through 7.
R means to take the upper half, keeping columns 4 through 7.
L means to take the lower half, keeping columns 4 through 5.
The final R keeps the upper of the two, column 5.

So, decoding FBFBBFFRLR reveals that it is the seat at row 44, column 5.

Every seat also has a unique seat ID: multiply the row by 8, then add the column. In this example, the seat has ID 44 * 8 + 5 = 357.

Here are some other boarding passes:

BFFFBBFRRR: row 70, column 7, seat ID 567.
FFFBBBFRRR: row 14, column 7, seat ID 119.
BBFFBBFRLL: row 102, column 4, seat ID 820.

As a sanity check, look through your list of boarding passes. What is the highest seat ID on a boarding pass?

Solution

Okay, so I might've got a few spoiler-y ideas from #adventofcode … though I don't understand them. Let me think on this problem a bit. I'm definitely doing a binary search thing.

I think I get the binary code thing now … basically, you can encode the F as 0 and the B as 1 .. let's see.

   BFFFBBFRRR

  BFFFBBF

  B 1 - 128
  F 0 - 64
  F 0 - 32
  F 0 - 16
  B 1 - 8
  B 1 - 4
  F 0 - 2

  1000110 = 70. CORRECT

  FFFBBBFRRR
  FFFBBBF
  0001110 => 14. CORRECT

DOPE! Also, I'm looking at the seat ID … "multiply the row by 8, then add the column." Multiplying a number by 8 is the same as shifting it by 3, right?

  0001 -> 1000
  1    -> 8

  000100101010 -> 100101010000
  298          -> 2384
  x8 = 2384

DOPE

I think I'm ready for the solution now.

  <<aoc>>

  (defun notation-to-binary (notation)
    "Convert notation of seat to binary."
    (let ((result)
          (list (string-to-list notation)))
      (dolist (c list result)
        (push (cond ((eq c ?F)
                     ?0)
                    ((eq c ?B)
                     ?1)
                    ((eq c ?L)
                     ?0)
                    ((eq c ?R)
                     ?1))
              result))
      (concat (reverse result))))

  (aoc
   input nil
   (let ((result))
     (dolist (line lines result)
       (let ((binary-string (notation-to-binary line)))
         (push (list line
                     binary-string
                     (string-to-number binary-string 2))
               result)))
     (reverse result)))
FFFBFBFLRR 0001010011 83
FFBBFFFRLL 0011000100 196
FBFBFFBRLR 0101001101 333
FFFBBFBRRL 0001101110 110
BFFFBBFRRL 1000110110 566
FFBFBFFLLR 0010100001 161
FBFBBFFRLL 0101100100 356
FFBBFBBLLL 0011011000 216
BFFFBBFLLR 1000110001 561
FBBFFBBRLR 0110011101 413
FBFBBBBLLL 0101111000 376
BFFBBBFLLR 1001110001 625
BBFFBFBLRR 1100101011 811
FBBBFFBRRL 0111001110 462
FFFBFBBLRL 0001011010 90
FFBFBFBRLR 0010101101 173
FBBBBFFRRL 0111100110 486
FBBBBFBLLR 0111101001 489
BFBBBBFRRR 1011110111 759
BFBFFBBLRL 1010011010 666
FBBFBBFRLL 0110110100 436
FFBBBFBRLR 0011101101 237
FBBFFFBRLL 0110001100 396
FBFBBFBLRR 0101101011 363
FFFBBBFLLL 0001110000 112
FBFFBBFLRL 0100110010 306
BFFFBFFLLR 1000100001 545
FBFBBBBLRL 0101111010 378
FBBFBFFRLR 0110100101 421
FBFBBBBRLL 0101111100 380
FFBFFBFLLR 0010010001 145
BFFBFFBRLL 1001001100 588
FBBBBFFLRL 0111100010 482
BFFBFBBRLR 1001011101 605
FFBFFFFLLR 0010000001 129
BBFFBBFRLR 1100110101 821
BFBFBBBRRL 1010111110 702
BFFBBBBLRR 1001111011 635
FFBBBBBRLL 0011111100 252
FFFBBFFRLR 0001100101 101
BBFFFFBLRL 1100001010 778
BFBBFBFRRL 1011010110 726
BBFFBBFRRL 1100110110 822
FBFFFFBRLR 0100001101 269
FBBFBBBRLR 0110111101 445
BBFBFFFLLL 1101000000 832
BFBFBBBRLL 1010111100 700
BFFFFFFLRL 1000000010 514
FBFBFBFRRR 0101010111 343
BBFFFFFLRR 1100000011 771
FFFBBFBLLR 0001101001 105
FBFFBFBRLL 0100101100 300
BFBBFBFLLR 1011010001 721
FFBFBFFLRL 0010100010 162
BFBFFBFRRR 1010010111 663
FBBBBBFRLR 0111110101 501
FBBFFBBLLR 0110011001 409
FBFBBFFLRL 0101100010 354
FBFFFBFRRL 0100010110 278
BFFBFFFLRR 1001000011 579
FFBFBFBLRL 0010101010 170
FBFFBBBLRR 0100111011 315
BFBBFFFLLR 1011000001 705
FBFBBBBRLR 0101111101 381
FBFFFBBRRL 0100011110 286
FFFBBBFRRL 0001110110 118
FBBBBBBLRR 0111111011 507
FBBBFBBRRL 0111011110 478
FBBBFBBRRR 0111011111 479
BFFFBFBLRL 1000101010 554
FBBBFFBRLR 0111001101 461
BFBFFFBRRR 1010001111 655
BFBBFBBLRL 1011011010 730
BBFFBBFLRR 1100110011 819
FFFBFBFLLR 0001010001 81
FFBBBBFRRL 0011110110 246
BFBFBFFRRR 1010100111 679
FBFBBBBRRR 0101111111 383
BFFFBFFRLL 1000100100 548
BFBBFBBLLL 1011011000 728
FBFBFBBRLR 0101011101 349
BFFFBFBRLL 1000101100 556
FFBBFFBRLL 0011001100 204
FBFFBBFRLL 0100110100 308
FBFBFFFRRR 0101000111 327
FFBFBBBLLL 0010111000 184
BBFFBBBLRR 1100111011 827
FBBFFBBRLL 0110011100 412
BFFFFFBRRL 1000001110 526
FBBFFBFLLL 0110010000 400
FBFBFBFLRL 0101010010 338
BFFFFBBLRL 1000011010 538
BFFBBFBRLL 1001101100 620
BFBFFBFRRL 1010010110 662
BFBFFFFLRR 1010000011 643
FBFFFBFRRR 0100010111 279
BBFFBBBLLR 1100111001 825
FBFBFBFRRL 0101010110 342
BFFBFBBLRL 1001011010 602
FFFBFBBRLR 0001011101 93
BBFFFBFLRL 1100010010 786
BFBFFBFLLR 1010010001 657
BBFFBFBRRL 1100101110 814
FBBFFFBRRL 0110001110 398
FFBFFFFLLL 0010000000 128
BFBFBFFLLL 1010100000 672
BFBFFFBLRR 1010001011 651
FBBBFFBLRR 0111001011 459
FFBBFFBLLR 0011001001 201
BBFFFBBLRR 1100011011 795
BBFBFFBLRL 1101001010 842
BFFFBBFRLL 1000110100 564
FBFFBFFRRR 0100100111 295
FFBBBFBLRL 0011101010 234
FFBFBFFRRR 0010100111 167
BFFFFFFLLR 1000000001 513
BFFFFBBRRL 1000011110 542
FBFBBBFLRL 0101110010 370
BFFFFBFLRL 1000010010 530
FBFBBBFRLL 0101110100 372
FFBFBFBRRR 0010101111 175
FFFBFBBRRR 0001011111 95
FBBBFFBRLL 0111001100 460
FBFFBBFRLR 0100110101 309
FFBFBBFRLR 0010110101 181
FBBFFFBLLL 0110001000 392
BBFFBBBRLR 1100111101 829
FBBFFFFLRR 0110000011 387
BBFFFBFRLL 1100010100 788
FBBBBBBRLR 0111111101 509
BFBBFFBLLR 1011001001 713
BFBFBBBLRR 1010111011 699
FFBBFBBRLL 0011011100 220
FFFBFBBLLL 0001011000 88
BFBBBFFRLR 1011100101 741
FBFBFFFLRL 0101000010 322
BFFBBFBLLR 1001101001 617
BFBBFFFLRL 1011000010 706
BFBBFFBLRR 1011001011 715
FBFFFFBLRL 0100001010 266
FBFBFBFLRR 0101010011 339
FBBFFFFLRL 0110000010 386
FFBFBBBLLR 0010111001 185
FBFBFBBRRR 0101011111 351
BFBBBBFLRL 1011110010 754
BFBFBFBLRL 1010101010 682
BFFBFBFLRL 1001010010 594
BBFFFFBRRL 1100001110 782
FFBFFFBLRR 0010001011 139
BBFBFFBRRL 1101001110 846
FFBBBFFLRR 0011100011 227
BFFBBBBLRL 1001111010 634
FBBBFFFLLR 0111000001 449
FFFBBBFRLR 0001110101 117
BBFBFBFLLR 1101010001 849
BFBFBFFRRL 1010100110 678
FBFBFFBRRR 0101001111 335
FBFFBFFLRL 0100100010 290
FFBBFFFLLL 0011000000 192
BFFBBFBLLL 1001101000 616
BBFFFFFLRL 1100000010 770
FFBFBBBRRR 0010111111 191
FFBFFBFLLL 0010010000 144
FFBBBBFLRL 0011110010 242
FFBBFFFRLR 0011000101 197
BFBFFFBLLL 1010001000 648
FBFFFFFRRR 0100000111 263
FBBFFBBLRL 0110011010 410
BFFFFBFRRL 1000010110 534
BFFFFBFRLR 1000010101 533
FFBFBFFRLL 0010100100 164
BBFFBFFRRL 1100100110 806
FBFFBBBRRR 0100111111 319
FFBBBFFRRR 0011100111 231
BFFBBBBRLR 1001111101 637
FFBBFBBRLR 0011011101 221
BFBBFBBRLR 1011011101 733
FBFFBBBLLR 0100111001 313
BFFFFBBLRR 1000011011 539
FBBFBFBRRL 0110101110 430
FBBFBFBRLR 0110101101 429
FBBBBFFLRR 0111100011 483
FBFFFFBLRR 0100001011 267
FFBFBBFLLL 0010110000 176
FBBFFBBLRR 0110011011 411
FBFBFFFLLL 0101000000 320
FBFFFBBLRR 0100011011 283
FBBFBFFLLL 0110100000 416
FBBBFBFRLL 0111010100 468
FFBBFBBLRL 0011011010 218
BFBFFBBRRR 1010011111 671
BFFBBBBLLR 1001111001 633
FBFFBFBLRR 0100101011 299
FBBBBBBLLR 0111111001 505
FBBFBBFLRL 0110110010 434
BFBFBFBRLR 1010101101 685
FBBFFFFRLR 0110000101 389
BFFBFBBLLL 1001011000 600
BFBFFFBRLL 1010001100 652
BFFBBBBRLL 1001111100 636
BFBFBBFLLR 1010110001 689
FBFFBFFRLR 0100100101 293
BFFBBFBRRR 1001101111 623
FBBBFFFLLL 0111000000 448
BFFBFBFRRL 1001010110 598
FBFFBFFRLL 0100100100 292
FFBBBFFLRL 0011100010 226
FBFFBFFRRL 0100100110 294
BBFFBFBRLR 1100101101 813
FBBFBBBRLL 0110111100 444
FBFBBFBRRL 0101101110 366
FBFBBFFLLR 0101100001 353
BFFBFFBLRR 1001001011 587
FFBBFBFRRR 0011010111 215
BFFBBBFRRL 1001110110 630
FFBFBFBRRL 0010101110 174
BBFFBFFLLR 1100100001 801
FBBBBFFLLR 0111100001 481
FBBFBFBLLL 0110101000 424
BFBBBBFRLL 1011110100 756
FFBBBBFLLL 0011110000 240
FBBBFBBRLL 0111011100 476
BFFBFBFLLR 1001010001 593
FBFFFFFLLR 0100000001 257
FBBFBFBRLL 0110101100 428
FBFBBBFLLR 0101110001 369
FBFBFBBLLL 0101011000 344
FFFBBBBLLR 0001111001 121
FFBBBBFRRR 0011110111 247
FBBFFFBLRL 0110001010 394
BBFFBFBLLR 1100101001 809
BFBBFFFRLR 1011000101 709
BBFBFFBRLL 1101001100 844
BFBBBFBLRL 1011101010 746
BFBBBFFRRL 1011100110 742
FBFBFFBRLL 0101001100 332
BBFBFFFLRL 1101000010 834
BFBFBFBRRL 1010101110 686
BFFFBFFLLL 1000100000 544
FBFFFFFLLL 0100000000 256
FBFBBBBRRL 0101111110 382
FBFFBFBRRL 0100101110 302
BFBFBFFRLR 1010100101 677
FBFBFFFRRL 0101000110 326
BFBBBBFLLR 1011110001 753
FBBBBBFLRL 0111110010 498
FBBBFFBLLL 0111001000 456
FBBBFFFRRL 0111000110 454
BBFBFBFRRR 1101010111 855
FFBFFBBRRL 0010011110 158
FFBFBBFRRR 0010110111 183
BBFFFBFLLL 1100010000 784
BBFFBFBRRR 1100101111 815
BFFBBBFLRR 1001110011 627
FBFFFFBRLL 0100001100 268
FBFFBBBLLL 0100111000 312
FFFBBBFLLR 0001110001 113
BBFBFFBLLL 1101001000 840
FBFBFBFRLR 0101010101 341
BFBFBFBLLL 1010101000 680
BBFFFFBRRR 1100001111 783
FBBBBFBRRR 0111101111 495
FBFFFBBRLR 0100011101 285
FFFBBFFLLL 0001100000 96
FBBFFBFLRR 0110010011 403
BFFFBBBRLL 1000111100 572
FBBFBFBLRL 0110101010 426
FFBFFFFLRL 0010000010 130
FFBFFFBLLR 0010001001 137
FBBFBBBRRL 0110111110 446
BFBBFBFRLL 1011010100 724
FFBBBBBLRR 0011111011 251
BFFBBFFLRR 1001100011 611
FFBFFFBRRR 0010001111 143
BFFFFFFRLL 1000000100 516
BFFBFFBRRR 1001001111 591
FFFBBBFLRL 0001110010 114
FFBFBFBRLL 0010101100 172
BBFFBBBRRL 1100111110 830
BBFBFFFRRR 1101000111 839
BBFBFBFLRL 1101010010 850
FBBFBBBLRR 0110111011 443
FFBBFBFRLR 0011010101 213
BFBFBFBLRR 1010101011 683
FFFBBBBRRL 0001111110 126
BFFFFBBLLL 1000011000 536
FFFBBBFLRR 0001110011 115
FFBBFFBRRL 0011001110 206
FBFFBFFLRR 0100100011 291
FBFFBBFRRL 0100110110 310
BFBBFBBRRL 1011011110 734
BBFFBFBRLL 1100101100 812
FBBFFFFRRL 0110000110 390
FFBBFFBRLR 0011001101 205
BBFFFFBRLR 1100001101 781
BBFBFBFRLL 1101010100 852
FBBFBBBRRR 0110111111 447
BFFBBBBRRL 1001111110 638
BFFBBBBLLL 1001111000 632
BFBBFBBRLL 1011011100 732
BFFBBBFLRL 1001110010 626
FBFFBFBLRL 0100101010 298
BFFBBFFLLL 1001100000 608
BFBFBBFRLL 1010110100 692
FBBFFFBRRR 0110001111 399
FFBFFBFLRL 0010010010 146
FFBFFFFRLR 0010000101 133
BFBBFBBLLR 1011011001 729
BFBFBFBRRR 1010101111 687
FBBFFFFLLR 0110000001 385
FFBBFBBRRL 0011011110 222
BFFBFFFRRL 1001000110 582
FBFBBBFRRL 0101110110 374
FBBFFFFLLL 0110000000 384
BFFFFFFRRL 1000000110 518
BFBFFFBLLR 1010001001 649
BFBBFFBRRR 1011001111 719
BFFBFFFLLR 1001000001 577
FFBBBFBLLL 0011101000 232
BFFBBBFLLL 1001110000 624
FBFFFBBRRR 0100011111 287
FBBBBBFLLL 0111110000 496
BFBFFFFRRL 1010000110 646
FFBBFFBRRR 0011001111 207
BFBFBFFLLR 1010100001 673
FFFBFBBLLR 0001011001 89
BFBBFFBLRL 1011001010 714
FBFBBFFRRR 0101100111 359
BFBBBFFLLR 1011100001 737
FBBFFFBLLR 0110001001 393
BFFFBBFLRR 1000110011 563
BFFFFBBRLR 1000011101 541
FBFFFBBLRL 0100011010 282
BFBBBFBLRR 1011101011 747
FBFFBFBLLR 0100101001 297
BFBBFFFRLL 1011000100 708
FFBBFBFLLL 0011010000 208
FFBFFFBRRL 0010001110 142
FFBBFBBLRR 0011011011 219
FFBFBBFLRL 0010110010 178
FFFBBFFRRR 0001100111 103
BFBFFBFLRR 1010010011 659
BBFFFFBLRR 1100001011 779
FFBFBBFLRR 0010110011 179
FFFBBFFRLL 0001100100 100
FBBBFBBRLR 0111011101 477
BBFFFBBRRL 1100011110 798
FFFBFBFRRL 0001010110 86
FBBBBBBRRR 0111111111 511
FFBBBFBLRR 0011101011 235
FBBFBFFLRL 0110100010 418
FBBBFFFRRR 0111000111 455
FBBFFBBRRR 0110011111 415
BFFFFBBRRR 1000011111 543
FBBFFBFRLR 0110010101 405
BFFBFBFRLR 1001010101 597
BFBBBFFLRR 1011100011 739
FFBFFBFLRR 0010010011 147
BFBFFFBLRL 1010001010 650
BFFBFBFRLL 1001010100 596
FBBBBFBLLL 0111101000 488
BBFBFFFRRL 1101000110 838
FFBBFFBLLL 0011001000 200
FFBFFBBRLR 0010011101 157
FFBBBFBRRL 0011101110 238
FFBBFFFLRR 0011000011 195
BBFFBFFLRR 1100100011 803
BFFFBFFRRL 1000100110 550
FBFBBFBRRR 0101101111 367
FBFFFBFLRL 0100010010 274
BBFBFFBLRR 1101001011 843
BFFBFBFRRR 1001010111 599
BFFFFFFLLL 1000000000 512
FBBBFFBLRL 0111001010 458
FBBBFBFRRL 0111010110 470
BFFBFFBRLR 1001001101 589
BFBBBFFRRR 1011100111 743
BFFBFFFRRR 1001000111 583
FFFBBBBLLL 0001111000 120
FFBBBFBRRR 0011101111 239
FFBBFBFLLR 0011010001 209
BFBBBFBLLL 1011101000 744
FBBFBBBLLL 0110111000 440
BBFBFBFLLL 1101010000 848
BFBBBFBRRR 1011101111 751
BFBFBBFRLR 1010110101 693
FBFFBFBRLR 0100101101 301
BFFBFFFRLL 1001000100 580
BFBBFFBRRL 1011001110 718
FFBBFBFLRR 0011010011 211
FFBBBFBLLR 0011101001 233
BBFBFFFRLR 1101000101 837
FFBBFBBLLR 0011011001 217
FBFFFBBLLR 0100011001 281
FBBFBFBLLR 0110101001 425
FFBBFBFRLL 0011010100 212
BFFFFFBLLR 1000001001 521
BFBFBFBLLR 1010101001 681
BFBBFFBLLL 1011001000 712
FBBBBFBLRR 0111101011 491
BFBBBBFLLL 1011110000 752
BFFBBFFLLR 1001100001 609
FBFBFFFRLL 0101000100 324
FBBBBBFLLR 0111110001 497
BBFBFFBLLR 1101001001 841
BFBFBFFLRR 1010100011 675
FBBBBFFRLR 0111100101 485
FFFBFBBRRL 0001011110 94
FFFBBFBLLL 0001101000 104
BFBBBBFLRR 1011110011 755
BFBBBBBLRR 1011111011 763
FBBFBBFLLL 0110110000 432
BFFFBFBRLR 1000101101 557
FBBFBFFLRR 0110100011 419
FBFFFBBRLL 0100011100 284
BFFFFFBRRR 1000001111 527
BFFBBBFRLL 1001110100 628
FFBFBFBLLL 0010101000 168
BFBBFBFLRL 1011010010 722
FBBBBFFLLL 0111100000 480
FBBFBFFRRR 0110100111 423
FFFBBBBRLR 0001111101 125
BFBFBFFLRL 1010100010 674
FFBBBFFRRL 0011100110 230
BBFFBFFLRL 1100100010 802
BFFFBBBRRL 1000111110 574
FBFFFFFLRL 0100000010 258
BBFFBFFRLL 1100100100 804
BFFFBBFRLR 1000110101 565
BFBFFBBRLR 1010011101 669
FBFBFBBLLR 0101011001 345
FBBFFBBRRL 0110011110 414
BBFFBFFRLR 1100100101 805
FFBFFBBRRR 0010011111 159
BBFFFBBRLL 1100011100 796
BFBFBFBRLL 1010101100 684
FBFBBBBLLR 0101111001 377
FBFBFBFLLL 0101010000 336
FFBFBBBLRL 0010111010 186
BFFBFBBLRR 1001011011 603
BBFFFFFRRR 1100000111 775
FFFBBFFLRL 0001100010 98
BBFFFBFLRR 1100010011 787
FFBFFBFRLL 0010010100 148
FBFFBBFLLR 0100110001 305
FBFFFFBLLR 0100001001 265
FFBBBBFRLL 0011110100 244
FFFBBFFLRR 0001100011 99
BBFFFFFLLL 1100000000 768
BBFBFBFLRR 1101010011 851
FFBBBBFRLR 0011110101 245
BBFFFBBLLL 1100011000 792
FFBFBBFRLL 0010110100 180
BFFFFFFLRR 1000000011 515
FFBFFFBRLL 0010001100 140
FBFFFFFRRL 0100000110 262
BBFFFBBLLR 1100011001 793
FFFBBFBRLR 0001101101 109
BFFBBFFRRL 1001100110 614
FBBBBFFRLL 0111100100 484
BFBBFFBRLR 1011001101 717
BFFFBFBLRR 1000101011 555
BFBFFBBLLR 1010011001 665
BFFBFBBRRR 1001011111 607
BBFFFBFRRR 1100010111 791
FFBBBFFRLL 0011100100 228
BFBBFBBRRR 1011011111 735
FFBBBBBRLR 0011111101 253
BFFFBBBRLR 1000111101 573
BFFFBBFLLL 1000110000 560
FFBFFBBLRL 0010011010 154
FFBBFBFLRL 0011010010 210
FBFBFBBLRL 0101011010 346
BFFBBFBRLR 1001101101 621
FBBBBFBRRL 0111101110 494
FBFBBBFRRR 0101110111 375
BBFBFFBRRR 1101001111 847
BBFBFBFRRL 1101010110 854
FBBBBFBRLL 0111101100 492
FBFFFBBLLL 0100011000 280
BFBFBBFLLL 1010110000 688
FBBBBFFRRR 0111100111 487
FBBFBBFLRR 0110110011 435
FFBFFFFRRL 0010000110 134
FFFBFBFRLL 0001010100 84
FBFBBFBRLR 0101101101 365
FFBBBFFLLR 0011100001 225
FBFFBBFLLL 0100110000 304
FFFBBBBRRR 0001111111 127
BFFFFBFRRR 1000010111 535
BFBFFFFLRL 1010000010 642
FBFBFFBLLL 0101001000 328
BFFBBBBRRR 1001111111 639
BFFBFBFLLL 1001010000 592
FBFBBFFLLL 0101100000 352
FBBFBBFLLR 0110110001 433
FBBFBFFLLR 0110100001 417
BBFFBFFRRR 1100100111 807
FBBBBBFLRR 0111110011 499
FFBFBBBRLL 0010111100 188
FBBBBBBLLL 0111111000 504
BFBBFBBLRR 1011011011 731
FBFBFFFRLR 0101000101 325
FFBBBBBRRL 0011111110 254
FBFFFFBRRR 0100001111 271
FBBFFBFRRR 0110010111 407
FFFBBBBRLL 0001111100 124
FBBFFFFRRR 0110000111 391
BFFBFFBLRL 1001001010 586
FFFBBBBLRR 0001111011 123
BFBBBBFRRL 1011110110 758
BFFFFBBLLR 1000011001 537
BFFFFFFRLR 1000000101 517
BFFBBFFRLR 1001100101 613
BFFBBFBLRL 1001101010 618
BBFFFFBLLL 1100001000 776
BFFFFBBRLL 1000011100 540
FBBFFBFRLL 0110010100 404
FFFBBFBLRR 0001101011 107
BBFBFFBRLR 1101001101 845
BFFFBBBLRL 1000111010 570
BFBBFFFRRL 1011000110 710
BFBFFBFRLL 1010010100 660
BFFBFBBRRL 1001011110 606
FBFFBFFLLL 0100100000 288
BFBBFFBRLL 1011001100 716
BFBBBFFLRL 1011100010 738
FFFBFBFRLR 0001010101 85
BFFBFFBLLR 1001001001 585
BBFFFFBLLR 1100001001 777
FFBBFBBRRR 0011011111 223
FBBFBBFRRR 0110110111 439
FFBBBFFLLL 0011100000 224
BFBBFFFLRR 1011000011 707
FFBFFBFRRR 0010010111 151
FBBFBBFRLR 0110110101 437
FBFBFFBLRL 0101001010 330
BBFFBFBLRL 1100101010 810
BFFFFBFLRR 1000010011 531
FBBBFFFRLL 0111000100 452
FFFBBFFRRL 0001100110 102
FFBFBFFRLR 0010100101 165
FFBBBBBLLR 0011111001 249
BFFBBFBRRL 1001101110 622
BFFBFBFLRR 1001010011 595
FFFBFBBRLL 0001011100 92
FBFBBBBLRR 0101111011 379
BFBFFFBRRL 1010001110 654
FFBFBBBRRL 0010111110 190
FFBFBFFLRR 0010100011 163
FFBFBFBLRR 0010101011 171
BFFBBFBLRR 1001101011 619
FFFBFBFLRL 0001010010 82
BFFBFBBRLL 1001011100 604
BFFBFFFRLR 1001000101 581
FFBBFFBLRR 0011001011 203
FBBBBBFRLL 0111110100 500
FBFBFBFRLL 0101010100 340
BFBBBBBRRR 1011111111 767
BBFBFFFLLR 1101000001 833
FFBFFFFRLL 0010000100 132
FFFBBFFLLR 0001100001 97
BFBBFFFRRR 1011000111 711
FBBBFBFLLR 0111010001 465
BFBBBBBRRL 1011111110 766
FBBBBBBLRL 0111111010 506
FBBBFBFLLL 0111010000 464
BFFBFFBLLL 1001001000 584
BFFBFFBRRL 1001001110 590
FBFFBFBRRR 0100101111 303
FBFBFBBLRR 0101011011 347
BFFFBFFRLR 1000100101 549
FBFBFBBRRL 0101011110 350
BFBBBBBLLL 1011111000 760
FBFFBBFLRR 0100110011 307
BBFFFBBRRR 1100011111 799
FFFBFBBLRR 0001011011 91
FBBFFBBLLL 0110011000 408
BFFFFFBRLL 1000001100 524
BBFBFBFRLR 1101010101 853
BFFFBFFLRR 1000100011 547
FBFBFFBLRR 0101001011 331
BFBBBFBRLR 1011101101 749
BBFFBFBLLL 1100101000 808
FFBBBBFLLR 0011110001 241
FBBBFBFRLR 0111010101 469
FBBBBBFRRL 0111110110 502
FBBBFFBRRR 0111001111 463
FFBBBBFLRR 0011110011 243
BBFFBBBRRR 1100111111 831
BFFFFBFLLR 1000010001 529
FBFFBBFRRR 0100110111 311
BBFFFFFRRL 1100000110 774
BBFFBBBRLL 1100111100 828
FBFFFFBRRL 0100001110 270
FBFFBBBLRL 0100111010 314
BFFFFFFRRR 1000000111 519
BFFFBBBLLR 1000111001 569
FBFBBFBLRL 0101101010 362
BFBFBBBLRL 1010111010 698
FFBBFBFRRL 0011010110 214
FBFFBBBRLR 0100111101 317
BFFBBBFRLR 1001110101 629
FFBFBBBLRR 0010111011 187
BFFBFFFLLL 1001000000 576
FBBBFFBLLR 0111001001 457
BFBFBBFRRL 1010110110 694
FFBFFBBLRR 0010011011 155
BBFFFBBRLR 1100011101 797
FFBFFBBRLL 0010011100 156
FBFFFFFRLR 0100000101 261
FBBBFBBLRL 0111011010 474
BBFFFBFLLR 1100010001 785
FBBFFFFRLL 0110000100 388
BFFFBBFLRL 1000110010 562
BFBBBBBRLR 1011111101 765
BFFBFBBLLR 1001011001 601
FFBBFFBLRL 0011001010 202
BFBBBFBRLL 1011101100 748
BFBBFBFRRR 1011010111 727
FFBBFFFLRL 0011000010 194
FFBFFFBLLL 0010001000 136
FFBFFBBLLR 0010011001 153
BBFFFBFRRL 1100010110 790
BFFBBFFLRL 1001100010 610
FBBFFBFLRL 0110010010 402
BFFFBBBRRR 1000111111 575
FFBBFFFRRL 0011000110 198
FFBFBFFRRL 0010100110 166
FBBBBFBLRL 0111101010 490
BBFFBBFLLR 1100110001 817
FBBBBFBRLR 0111101101 493
BFBFFBFRLR 1010010101 661
FFBFFBBLLL 0010011000 152
FFBBBBBLLL 0011111000 248
BFBFBBFRRR 1010110111 695
BBFFFFFRLL 1100000100 772
FBFFFBFRLR 0100010101 277
BFBBBBFRLR 1011110101 757
FBBFFFBRLR 0110001101 397
BFFFFFBLRR 1000001011 523
FBFFBBBRRL 0100111110 318
FBBBFBFLRL 0111010010 466
BFFFBFFLRL 1000100010 546
BFBFBBFLRR 1010110011 691
BFBBFBFRLR 1011010101 725
FFBFFBFRLR 0010010101 149
BBFFFBBLRL 1100011010 794
BFBFFBFLLL 1010010000 656
BBFFBBFRLL 1100110100 820
FBBBBBBRRL 0111111110 510
FFBBFFFLLR 0011000001 193
FFFBBBBLRL 0001111010 122
BBFFBFFLLL 1100100000 800
FBBBFFFLRR 0111000011 451
FBFBFBFLLR 0101010001 337
FFBFBFFLLL 0010100000 160
FFBFFFBLRL 0010001010 138
BFBFFBBLLL 1010011000 664
FBFBFFFLRR 0101000011 323
BBFFBBFLRL 1100110010 818
BFFFBFFRRR 1000100111 551
FBFFBBBRLL 0100111100 316
FFFBBBFRLL 0001110100 116
FBFFFBFLLL 0100010000 272
BBFFFBFRLR 1100010101 789
BBFFBBFLLL 1100110000 816
BBFBFFFRLL 1101000100 836
BBFFBBBLLL 1100111000 824
FBFBBFBLLL 0101101000 360
FBBFBBBLRL 0110111010 442
FBFFFFFLRR 0100000011 259
FBFBBFBRLL 0101101100 364
FFFBBFBRLL 0001101100 108
FBBBFBFLRR 0111010011 467
FBFBFFFLLR 0101000001 321
FFBFFFFRRR 0010000111 135
BFFBBFFRLL 1001100100 612
BBFFFFBRLL 1100001100 780
BFBBBFBLLR 1011101001 745
BFBBFBFLLL 1011010000 720
FBBBBBFRRR 0111110111 503
FFBFBBBRLR 0010111101 189
BFFFFBFLLL 1000010000 528
BFFFFFBRLR 1000001101 525
BFBFFFFLLL 1010000000 640
BFBFFBBRRL 1010011110 670
FFBFFBFRRL 0010010110 150
FBBBFBBLRR 0111011011 475
BFBFFBFLRL 1010010010 658
FBBBBBBRLL 0111111100 508
FFFBBFBLRL 0001101010 106
FFBFBBFLLR 0010110001 177
BFBFBBBLLR 1010111001 697
FBFBBFFRLR 0101100101 357
FBFBFFBLLR 0101001001 329
BBFFBBBLRL 1100111010 826
BFBFFBBLRR 1010011011 667
FFBBFFFRRR 0011000111 199
FBFBBBFRLR 0101110101 373
BFBBFBFLRR 1011010011 723
FBBFBFFRRL 0110100110 422
FBFBBFFLRR 0101100011 355
FBBFBFBRRR 0110101111 431
FBFBBBFLRR 0101110011 371
BFBBBBBLLR 1011111001 761
FBFFFBFLLR 0100010001 273
FBFBBFBLLR 0101101001 361
FFBFFFFLRR 0010000011 131
BFBFBBBRLR 1010111101 701
FBFFFFFRLL 0100000100 260
FFBBBBBLRL 0011111010 250
BFBBBFFLLL 1011100000 736
BBFFFFFLLR 1100000001 769
BFFFBBFRRR 1000110111 567
FBFBFFBRRL 0101001110 334
FFFBBFBRRR 0001101111 111
FBBBFBBLLR 0111011001 473
BFFFFBFRLL 1000010100 532
BFBFBFFRLL 1010100100 676
BFBFBBFLRL 1010110010 690
FFBBBFFRLR 0011100101 229
BFBFBBBLLL 1010111000 696
BFFFBBBLRR 1000111011 571
BFBBFFFLLL 1011000000 704
FBFBFBBRLL 0101011100 348
BFFFFFBLLL 1000001000 520
BBFBFFFLRR 1101000011 835
BFBFFBBRLL 1010011100 668
FFBFBBFRRL 0010110110 182
FBFBBBFLLL 0101110000 368
FBFFFFBLLL 0100001000 264
FBFFBFFLLR 0100100001 289
FBBFBBFRRL 0110110110 438
BBFFBBFRRR 1100110111 823
BFFFBFBRRL 1000101110 558
BFBFFFBRLR 1010001101 653
FBBFFBFLLR 0110010001 401
BFBFFFFRLL 1010000100 644
BFBFBBBRRR 1010111111 703
BFBFFFFRLR 1010000101 645
FFBFBFBLLR 0010101001 169
FBFFFBFLRR 0100010011 275
FFBBBBBRRR 0011111111 255
FBBFFFBLRR 0110001011 395
FFBFFFBRLR 0010001101 141
BFFFBFBRRR 1000101111 559
FBBFBBBLLR 0110111001 441
BFBBBBBLRL 1011111010 762
FBBBFFFLRL 0111000010 450
BFFBBFFRRR 1001100111 615
BFBBBFFRLL 1011100100 740
BFBFFFFLLR 1010000001 641
BFFBFFFLRL 1001000010 578
BFBFFFFRRR 1010000111 647
BBFFFFFRLR 1100000101 773
FBFFFBFRLL 0100010100 276
FFFBBBFRRR 0001110111 119
BFFFBFBLLR 1000101001 553
FBBFBFFRLL 0110100100 420
FBBBFBBLLL 0111011000 472
BFBBBBBRLL 1011111100 764
BFFBBBFRRR 1001110111 631
FFFBFBFRRR 0001010111 87
BFBBBFBRRL 1011101110 750
FBFFBFBLLL 0100101000 296
FBBBFFFRLR 0111000101 453
FBFBBFFRRL 0101100110 358
FBBFFBFRRL 0110010110 406
FBBFBFBLRR 0110101011 427
BFFFFFBLRL 1000001010 522
FBBBFBFRRR 0111010111 471
BFFFBBBLLL 1000111000 568
FFBBBFBRLL 0011101100 236
0
855

AWESOME it worked :) Now for part 2.

Part 2

Problem

— Part Two —

Ding! The "fasten seat belt" signs have turned on. Time to find your seat.

It's a completely full flight, so your seat should be the only missing boarding pass in your list. However, there's a catch: some of the seats at the very front and back of the plane don't exist on this aircraft, so they'll be missing from your list as well.

Your seat wasn't at the very front or back, though; the seats with IDs +1 and -1 from yours will be in your list.

What is the ID of your seat?

Solution

Of course we can't just see the one number that's missing; that'd be too easy, lol. I do need to slurp up the list from earlier though. Of course … I don't think that's super easy, lol. Or rather, I don't know how to do it. Let's just do that here.

  <<aoc>>
  (defun notation-to-binary (notation)
    "Convert notation of seat to binary."
    (let ((result)
          (list (string-to-list notation)))
      (dolist (c list result)
        (push (cond ((eq c ?F)
                     ?0)
                    ((eq c ?B)
                     ?1)
                    ((eq c ?L)
                     ?0)
                    ((eq c ?R)
                     ?1))
              result))
      (concat (reverse result))))

  (defun list-of-ids (input)
    "Return a list of all seat IDs."
    (let ((result))
      (dolist (line lines result)
        (let ((binary-string (notation-to-binary line)))
          (push (string-to-number binary-string 2) result)))))

  (defun day5-part2 (input)
    "Solve day 5, part 2."
    (let ((seats (list-of-ids input))
          (result))
      ;; fuck it, we're being really inefficient
      (dolist (s seats result)
        (if (not (seq-contains-p seats (+ 1 s)))
            (push s result)))))

  (aoc input nil
       (day5-part2 lines))
855 551 0

Since I know there are unused seats at the beginning and end of the plane … I know that 855 is probably not the answer. I'm going to try 551.

BOO. Too low.

Attempt 2

Let's try that less-shitty way of finding a seat.

  <<aoc>>
  (defun notation-to-binary (notation)
    "Convert notation of seat to binary."
    (let ((result)
          (list (string-to-list notation)))
      (dolist (c list result)
        (push (cond ((eq c ?F)
                     ?0)
                    ((eq c ?B)
                     ?1)
                    ((eq c ?L)
                     ?0)
                    ((eq c ?R)
                     ?1))
              result))
      (concat (reverse result))))

  (defun list-of-ids (input)
    "Return a list of all seat IDs."
    (let ((result))
      (dolist (line lines result)
        (let ((binary-string (notation-to-binary line)))
          (push (string-to-number binary-string 2) result)))))

  (defun day5-part2 (input)
    "Solve day 5, part 2."
    (let* ((seats (list-of-ids input))
           (sorted (seq-sort #'< seats))
           (expected (number-sequence (first sorted)
                                      (car (last sorted))))
           (result))
      (dolist (e expected result)
        (if (not (seq-contains-p seats e))
            (push e result)))))

  (aoc input nil
       (day5-part2 lines))
552 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

Well, there's a lot of garbage here but there's also 552 which I think is probably our answer. Oh I must've had an off-by-one answer because I only tested for the non-existence of s+1 earlier meaning once I got to the seat before mine, it returned true. Ha.

YEP that was it !

Day 6

Input

  (setq input "qtmdwspah
  sqwdamhpt
  phwdaqsmt
  stmdqwhap
  pqawdhtms

  bgsickuztovfwa
  yiozauvgfsbtkwc
  zygijavmtfkcuwobs
  fvsuwtiadzrncboklg

  dxgieku
  dihnxkgf

  mqybtd
  yqbtd
  btydq

  rgpbcfxtzoewy
  otbyrfgwxzpec
  yocrwtebzxgfp

  qcpngeodrszaky
  ocaqrngsyuz

  xwenu
  nwsxuye

  xapwvhsktlmr
  twpslarxhvkm
  vhlwmrapxkts
  pmkxraswvlth
  ksrxpvtmwahl

  xhcepbdsltvk
  khcdptsixbg
  spbjtdchxk
  cbkxspqtdrh

  kaishmtdl
  jcnprqigt

  pjqtekodlmwcaginxfzrushbv
  iuyzsfaxcvrotdmklgebpnjwqh
  dirxeqbswlonhzumgafvckptj
  zqpitfrjnmhvuxbcdlwkogase
  khncmsfdzlgwpvriotxujbaeq

  motb
  twm
  mvt
  nomt

  euwhdnlaxbtjiqz
  dquxjznhtlwebia
  atzdwxqiunhlebj
  jnwlzxdiuaheqbt

  jnktcwaovpbqzei
  qcrljzskbvo

  tangojspuvlwbryeicz
  eujvkaporgwdilbyfscztn

  pjrisxqwdoyze
  cvyzmjlqxsgpeirw
  xieqwcajzslryp
  xjpzerwqyamis

  rftxglbkpqnchvajs
  cnsvqgpurtjfeb

  m
  mcx
  wramgjy
  mv

  meacfoiqpbzy
  zmvqpaibegoyfc
  oiyzmaengcfbpq
  uiaqprbycmzfoe

  qjdnecvmsr
  sdmecpqn

  gt
  tg

  bndhmeupwszlqiycofkt
  fcrptkulhixjnazvmdg

  nrcytwdaozvbmhsjuk
  owarihdekqzslvnxmubyfpj
  suzlnmxvkwjyodhbrag

  fz
  zf
  zefpk
  fz
  fz

  zfnqcdhvjwxa
  hxfazjcwd
  xzhtajkfwcd

  weusntyxblcdqpvgfzoam
  oxiyslgabqvdhnwzm

  jneuovbpgfxlsmkwd
  kjbwonlspfdumcegthv
  omvfbgejaiwnkdulsp
  orfgdlbqjkvhumpewns

  mhb
  hb
  dhjxb
  boh

  af
  tzlbugdkq
  j

  qhgnav
  ngvahqp
  gvnqha

  hoer
  oufeq
  u
  gmy
  td

  naguhdzsmcxlye
  pglwjsvxzduc
  uosgxqzldct
  xugcszld
  qcxsgtlzoud

  uoxacitdkeh
  kypudjgbsefi

  bjywqhgcps
  uaybelqkjpiwc
  yblwqpjec
  jwvyrcpbqzt
  qjgywbocp

  cuvwxkmrnliodphaj
  rvuzcdxknphol
  hprvkucdonsxl

  qtgjunkhaovbw
  wkgvotljhbq

  blfvtr
  vrtfby
  mbtvjdfnr
  xbftpvrh
  svbrhptf

  rijakd
  kadnijer
  kqdwjifar
  jdrihkmaz
  ejnirkfda

  ysukmtloxgjhvnwp
  qjxlwnvpyzsgbutomd

  gxpdqomijnhkyws
  vyqgxmjpowhsnik
  mnxqhgykwiopjs

  fm
  u
  fc
  zd
  yplnbikosxj

  welcjifhgnzupo
  izfpwljnodctheg
  dtlhgznwepcojif
  hzwvgpcifnjleo
  wgpqvtcnjofhlezi

  azhipsvbx
  xwbip
  ixpb
  xbip
  bpxi

  yxhpltiuvzorefqnwm
  azwiylnohxmejqurftvp
  hvuzwfxmnqyeltpro
  kwxghtdyfreqmplvzuon

  n
  f
  a
  f

  xfoaj
  ofsqb
  eqfo

  canrzup
  znarcpu
  pzcnrua
  czaupnr
  puchnzra

  hwxtaqvsci
  rhxylbskwcjmoid
  svqexwhaic
  whxisc

  xfamongdyrhjpizqbtswl
  tsnermfbvidyqcwhlxuzg

  jz
  zj
  zj

  mohrs
  rom
  mro
  orm

  rnwbshdkxv
  vkrjwsdthnxb
  kjwrxhsvnb
  rnbhvxowas

  lbdahrf
  ralbfhd
  lhfadbr
  radhflb

  wztomybdgaqhu
  rmuohgyqbdz
  dgzqrumoayhb
  hgqdmyubjpeoz
  mgdquhzoyb

  xiy
  yix
  bixoy
  xyi
  xiy

  xvzqjwfkhctgeayu
  kdjmlrow

  vnlu
  ulnvg
  wluvn
  lvun

  btmcqewifuh
  gqvakfzrmyuicsjpdbo

  npfy
  yznfx
  ynf

  b
  b
  b
  b
  b

  zuhkqwfpm
  mqpzwkhf
  pnwfqchkzm
  kfumpqzhw
  qzwhkmpfu

  pcevtdhgylnmsxaqiuzkr
  pxanvcgiquethzksmylrd
  vdszgiqyautrpxhcnmlek

  bhru
  ubhr
  uhvopbr
  trbizhud

  omnpx
  yp
  cpf
  p

  fuhokrpewbyvlnjcdmqi
  pcijvmskndtwohxylqeurf
  cdvfhebukmjrqnolwpiy
  qpwhymlcfjrndoeuivk

  xwehzfud
  wupfdexz

  xbdh
  jxdhb

  hmkbuyl
  rtcefpsaui

  jlfsy
  oknuy
  kvpy

  hcgzs
  hegzs
  sapzhd

  vnhjbqk
  bkvqnhjd
  vhnkqjb
  jhnkqvb
  bnhjkvq

  myjnp
  wkyjamn
  kmyjna

  rupvd
  pvrud
  rpdvu

  kvnlmhgizwdbjsxf
  nmfdkzgjxlbvsiwh
  zmsphibqwglkejfxrvn

  ge
  eg
  g
  g
  ga

  eivbk
  vikeb
  bkiyve

  puvf
  fvup
  uvfp
  pvuf
  fvup

  rydhgfbmpktzvlewjusn
  wqgfnovcerskjad
  ekrfsjgvowndcxq

  muco
  ouse

  pxoihbg
  bogpxhi

  aik
  k
  k

  qa
  aq
  aq
  aq

  snezvhbkwa
  nvzuaksbh
  zbvalskhn
  xposdbmhnavgzk
  thvfcbznkulas

  jaxdfucymsghp
  hfxaqcwunsjgmkpyd
  glfdjpuzxacyhm

  sp
  ps

  cesof
  vsu
  s
  svu
  sv

  s
  t
  te
  t

  epnq
  oeyqn
  nqe
  qen
  qne

  taxpglnzkejswbo
  zekwtongjpbxas
  gasokxnzbejpwty
  wanzsfbgpxjeotk
  wzxaengjkbptfso

  imftvao
  vtmif

  pbjelcf
  prnhgwqem

  xopmzg
  zfoxg
  xzgo
  ozxg

  gmcybniqevotjda
  ytiebavgdqojcnm

  mr
  m

  f
  n

  mnhpxfircz
  cihmvrxzyf

  ygibvxud
  ykubiqxgvd
  xydibeuv
  buvqdyxi
  budxiyv

  zjpqlmftionbgu
  tzbfgjiqoumapn
  nzcjuftibompqg
  aztbmoiqnjfgup

  chpnjmvlw
  hlbrdvqemcnwp
  pnkvcmlwh
  lmcyfwpvhn
  ynlmcjvipawh

  kzhxeqfa
  feaxqzkh
  hzxkaeqf
  zfqhexka
  fqxahkze

  blwqdpy
  yqdaniplwbe
  jhxbrwdylngqs
  qwtdylukzvbm

  asobzdl
  jahzxpdy
  daksz
  zadufl

  ahunxksgp
  sakhpun
  nukathps
  uzhnsapk
  pmusknahz

  yzmogwp
  tbqcp
  bnpcr
  xhp

  dhyxojbvrqnml
  nkr
  rnc
  wngra

  kmdynhutpjlvxaroce
  pbwohkjtmyfnzg
  tjoikmhypnsq

  zduqkfivgjo
  oizvjfuqbd
  zvjuqrfigdo
  vudqiozjf
  oidvqyzuftj

  usmo
  sm
  sm
  ms

  njf
  f
  glft

  auh
  hwiavfug

  xevqipr
  gwxdmlsuakcyf

  iltoavmycurph
  luhcarivtomxy
  yihcratumoevxl
  louhcvmiytra
  miqzdtolhrcayuvwg

  xwtcmqso

  xdnimfbyr
  okimydfr
  uhgzfyjqat

  evjdtmcoxiklhpgwq
  qgnxbkftmhiy
  ixqrakuhngytm

  hfzpe
  uefphkb
  afmwhqpek
  fvpoygjinlhexds

  oly
  byoal
  yol
  koly
  oyl

  k
  k
  k
  k
  k

  ofhrz
  xhpruzq
  zrh
  hwgrbedykvsmzin

  ginxcsjevrwyqz
  egysvqncxzrij
  syvgzcnreqijx
  zcvxgsjrqenyi
  qyfvzirnjcgxes

  eyxfutwoqjbrvkgds
  xsfjoutrbeqwkvgyd
  vqwtjgdbrsfoyukxe
  vfurtykqgebjwosdx
  eypubrkojqvdsgtfwx

  odwmeztifrjxn
  nrgmwlxc
  vgkxwrlnm

  tz
  tz
  rtz

  daze
  ezyad

  ujqdozgh
  goujdmqkzh
  jghuqdzo
  gjozdqhu

  erdnakojyfzchvxg
  hfekdrnctgvzpyjaxom

  hwi
  wih
  hiw
  hiw

  krqdscaoiwhnyz
  rwjaknoxyidzsqhpc
  rnyqdawcoskifghz
  wahrqznyvdcskiuo

  swlakrxjmtpv
  inaylxhdjwkmsvur
  qbxavfrlewkcsjm

  ucxvtw
  ue
  u
  lu

  oztxeqjvgb
  tpdbjgoqe

  spyqunh
  uypnhqs

  fdw
  safw
  wfjh
  wfomxi
  lwfsdn

  daibtezjo
  qtxeaizjmdb
  aoejitbkzd
  etadizjb

  jkeynazqvobiflrushcwtgdmxp
  wnrjequcdxlkmtfobihsvy
  iksvuebxtjwmhfrdqyocln

  gkxq
  pkw
  kw

  swy
  ywsn

  jzqurhixawto
  gaojpfrzciq
  izoxrtqawj
  asoihjqzutr

  wijlermdyzhstf
  zjlrwfsdhmtiey
  elymwztijfrdhs

  qatxy
  tyq

  nja
  yha
  a
  gfsav
  kha

  uebolhvntdkfsxap
  fpnlskhdeuobva
  oahteupksbvdlnf
  oeulbvhdpfksna
  ansgphkrfdlovebu

  vpe
  vedp
  pev
  pev
  pev

  zacfpshmrequykt
  tuzarfpmknwc
  pzuimacvfktr

  cjeqourh
  eouqcljr
  rojueqc

  ykoi
  koyi
  koyi
  kiyo

  fvkhuntrmpz
  ckngmxirpuzvat
  rfuvksnozpath
  bntdrlyvkzupj
  rukwpvtzcn

  wczery
  eczwrby
  wrzcey

  xjndayl
  hnlyaxdj
  lndayxj
  ynjdlaxt

  j
  j
  j
  tj

  awhrfvjbzduistx
  gnyhcmteop

  ym
  y
  sy
  my

  zkai
  ajiz
  aiz
  aiz
  ikaz

  irgsokuwy
  lnxtcqsiwmf
  busyvhzidw

  qxhpynjewsfmkd
  hwpqenfkydm

  aedbfmx
  fwexa
  jgckhspy

  zpusakfeb
  izpev
  sdepzu
  znpwe
  pqjgehtxzr

  vqmlkjznbeiofahucdtsgw
  utmvhgqedbocfwkszjlain
  yfbqzaspnlgotrdjxuhvkemiwc
  idglcasthofkuemnbjwqzv

  uqhdebp
  chdbquepl
  qedzphbu
  hupdqbe
  qbedhpu

  ehnv
  t

  aksmbzu
  wvlhktdqpjmsirz
  fznykbsem
  ksgmz
  kzxsymc

  vnoetrhlgkcmqxdp
  nvdqtkolcrhxep
  pxcedrnhoiltqvk
  elrxnhitcpqdokv

  ymuxitzqsagrkofcvbj
  tauxskfigjymro

  cnfdjwbxkisp
  cpydkbjxwsifn
  cipnkbufswdjrx
  ybkxihfwejnscdp

  yueaplwitfdvkoxnbjcmrqgz
  jvlfmxoakzwiegpbdnrquct
  manwikovgbpuhrcfesjlzxtqd

  lptzwxfn
  fpnxtlz
  nxtflegzpj

  dkpuyaefsijvlrhgqxmnt
  bshiwokugpflvtmzeqxnyja

  in
  n
  xzou

  ng
  gn

  epqbvmi
  vqembi
  bvmeqizu
  mbeqiv

  cjapgriulbzeq
  ugiqdzcvpobjlrek
  zqleircpubjg
  cirjuqbzgepl

  nhpsreikdjzo
  hkjsnodipzer
  znoidphekjrs

  dezf
  edfz
  efdz
  rdfze

  nzitsqrfp
  qiznrfspt
  rfqizspnt
  nsqizrptf

  xntrkogqfapj
  nioagqtmrfkjyp

  is
  sgdi
  qsity

  pe
  ep
  ep
  ep

  uhvpiwdgsfr
  uwlpcqrezykovni

  aevu
  ae
  ea
  ae

  djzfhxmas
  msdxhz
  zexhdsymt
  dxzshktm
  dzemshxg

  msqiuvncoltxejg
  cqxfmsonlvute

  wmfblsrogvjinpc
  rplfngicojbkvwms
  cfbolhnjvrsimwgk
  gmisflrwnkcjbov
  vmwrcbosjngfuil

  kbxitoqvzajudfnsgmyc
  ikfwcxzgvtjedmsyouqnab
  aqknmufjiypcvxbgodstz

  eshyzxbqncuomfpwgk
  gzcxqpmhljeoyuikbfrn
  bzhxveutpfyaqmkcong

  evqyuicpfhl
  yquckvlpiejf

  anf
  szydm

  qt
  qt
  qt

  mfyovqgpnlbcxidauzh
  cqniopdhfgxlauvzbmy
  idxofbaylmcznuvqhpg
  qbcpihzogydlfvmnwuxa
  qgvcumyizpnabxdfhol

  btwjlohyfaq
  ydlwprkj

  rhisamcj
  csirha
  srcaih
  icshar

  mejydkgtnfovuzix
  enuvirjogdmkyxztf
  xefomztvkungysdijc
  jxdginfktapovyzueqhm
  fioktdsnemgjuzyxv

  hrztvexlkob
  lwekirhbxdzqtmo

  etxv
  arxtvue
  exvft

  fwdnqsomhtryxvcgzej
  eczwytuhfsgmdqnxoj
  ycdsqwznhftgjmkoxe
  tsjnexcafwmhygzbvqod

  xovcfts
  cfsopxvdt
  xoscfvt
  osfxtvc

  w
  rc
  t
  zs
  ik

  lzm
  zpl

  romqvb
  mvo

  uy
  y
  y
  y

  govwliuabszqp
  goiabwfusvzlpnq
  qpiwgbvaosulz
  apvguizblwsqo

  s
  m
  s
  s

  ozpiljymxhswnfuevt
  emvbwshnylzxpjti
  nveblmzchtwjiypsx

  nldfsb
  sfblndt
  sdblfn
  bnflds
  ndslbf

  ieg
  idew

  wonxsab
  wbsaoxn
  nobaxws
  wasbnox

  alscukjbf
  lsbjakfc

  jxcduqioabwpyhlzef
  ialdxwfzycqjhbepuo
  jfzypowishadclxbueq

  riydchjfnwqvtmbpsaloxe
  dsbwfintzelormhvxcaqpyj
  ejomaiyqsxcthfvpdlwbnr
  lrycvtunboifgxawqemhpjd
  xvtiafqrdwnoymclepbhj

  jsydqempfvntrhui
  miyefthpuqsrvnj
  zsvyrmhbtuelpqinfja
  nuphytvreqmfsji

  cltvanwuh
  tulachoyvwn
  tuwclvanh

  bixkgozashw
  hakibzoswmx

  poxkblmhqjftwsdcn
  bhtykpvzjxuiengao

  j
  j
  j

  cqodguxrzles
  loxqcrgeszudw
  ocsdqruxglze
  rugqoyxesdzlcf
  ulzdorxgsqec

  yvz
  vyz

  mfq
  sztdnk
  py

  zawgmj
  jawgz
  gwapjz
  sgzajw

  ekoadscpwhg
  jsuchbxmfyzlnwq

  wlkrqcjux
  xuqjclr
  gjrqlcxu

  afcosnhvprzblxtwd
  abszvxoglnctfhpwr
  bjhlvzfwceayksxtun
  tzvnxrhwlmsfacbd

  igreocyhquzjmvlx
  liowjethfkqszvmxdyu

  ljeqkvwpdazgocf
  cqgdyvmjuwpeotainsr

  mhoylsckuzxbiaevq
  vyczxkjeoapsbifu
  kxbdosyzavujiec

  mwsfxbkjqazpiohgnyldc
  xqgnadblfkwpcomshiy
  wgvsalrhqbmieyxodpfnkc

  eurqfmtkvjbosh
  vyqrhkotfblmseu
  brtfqkvoheums
  rvtksmehoubqf
  uwftdoarkmvqgehbcps

  ctyalrqdxskjuoh
  dlathrokujqxs
  hxsqukdoaltjr
  osrqkautljxdh

  zfdlxtr
  sburlzxd
  zlrdx

  ocfb
  cbfo

  uykhxqrtmnc
  ahigrcuptnxdqmk

  tckz
  ktzc

  vzgtxhkums
  kvzmhtgus
  sgthkzumv
  vzxsgmkuht
  znqmuhvkswgt

  jtdwk
  ydkti
  kdt
  dkjt

  mwxehozbnqpad
  ryjdeblzwxnpoucqahmtg

  liumaz
  izulam
  zauloim
  miludzaqr

  rzkjguslxohwnfdivm
  ofulwkhisgvjmnrxzd
  dikwvojugxzfrmnlsh
  sxjdzkcuworbnvgflmih
  vlmxrzikndhwjofgus

  fzqnodmx
  a
  v

  lfoeh
  leovfh
  hofsle

  djku
  kjud
  dukj

  qtiwbxfhlzjnokvpadruymgse
  onurjdisvgzwaqkybftlhpmex
  fnmqwuhtyjrkepbgildovxasz
  marndljbkegqxtupviscywfhzo
  fdbqehtxkavjimzwporsugyln

  aqkonbhvfdljigp
  phaqrlkbjdin
  phldcbkaumjvinq
  iplbjxeykqhdazn

  zsl
  sz
  xsyzh
  zs

  xdhlq
  ndlkxjyu
  xlde
  xdl

  blwmairvkofcuq
  tedokrvbqm

  pw
  p

  iqrbnglofs
  grwuylifvkbq

  yl
  yl

  xaizpuhlqo
  kiloxm
  ilkox

  puaorhzmtvfg
  mutoegrhzafv

  lrzmpt
  dpqyihnsa

  jfiodcs
  spi
  swni
  isn

  ohdmyvlpbxjnqzfrswiuaeg
  ceafhrujqtndivbxpwzsmg

  mvoxyd
  tvdoymx
  xdymov

  py
  y

  nutogsehiczykpmdvf
  ngmueistpxkfodhvzrcy
  yuhczioegpvmnfktsd

  zp
  z
  zbc
  z
  z

  creyt
  uisfmova
  er

  dltugzhniyjro
  lizndhrutojyg
  jhgnzytuordli
  lhgotuznirjydc

  xtrckznswlueia
  ivnwstaeulrkzjc
  kcwaleiuznqrts
  rkwiunqzatsecl

  y
  pqnae
  ofm
  fl
  y

  czoi
  smvbnd
  tzi

  tzanvx
  azgnjx
  ingjzyuae
  anrhzkq

  eqhafrbmw
  rjscmwxz
  lrgnyfeukdvmiqwpt

  tarsmxwveqdhjbk
  xrajvebtdmwkh
  taojykmefwbdzrxuvnp
  wbdtmjrevakx
  ctilgkbmaredjwvx

  wp
  p
  p

  zprwtogmdu
  orwdmtzuxpg
  omwputzdgr
  umgrtpwozd
  wgzdrtpmou

  xtkjsm
  ylqptfjmk

  pzgyknr
  kyorpngz
  pnzykgra

  rtsiypahgecuvj
  rsudtcgjiheyvp
  rpyehvtijcgsu
  cyprhvestgjui
  uvigershtyjpc

  jlmhtfbsoq
  gbtohjsqm
  mbstojqh
  mhkecsqtabjox

  xrhinjamvo
  hproxvnma
  mzscorhnx

  utwprfqjyhsvzaomcb
  yesrijzcagmhbwoutvpnqk
  porcxwmyutzajbhqsv
  uvrcpyzsmhajowtqb
  ycpwuzovatbsmjqhr

  fbkgycqutlmw
  wuybgqmlcfk
  xycgbkqmulwf
  bgcfwyuqklm

  vntsimju
  boegqz

  edotgsi
  dgoism
  iogds
  gdstio
  sogdixz

  fdi
  ifd

  rx
  v
  x

  qibkwyvmtxargjldc
  bykzitxevgrwsnqflcdjm

  dborhtpxjsflciveyq
  xbuijhdqafnsrvepozytcl
  qhlopsdtebcjyfrixv
  hlvdyqxtcroegfjbisp
  ormifqdhyvxjpclebst

  qtzumogwrclaiex
  iburltzgexdocwapq
  ixuwtoqlegnrzc
  xizeklwrugtqhoj

  iynjbsahtvfeurqkgd
  rtnwjgeukyadicflq
  deytfqknlpjuairgc

  oy
  to
  po

  wyj
  q

  vatgy
  xegndfrv
  smgv
  sgzbacv

  ifmepunrdszgh
  mvgdesianluzpfrh
  eypfughdnmszitr
  nepugsfimzrdh
  fzuiqesnjcdwoxmhkpbrg

  goycuvjqnpix
  ytwnigvcjq

  bsiczfhkne
  gwxp
  ojdl
  a
  uvgm

  kaxzjpmwutcqnv
  isadmolbtrfugxyhcj

  vxqhfryiakbn
  txhqbavyknri

  ptbqifxcwyjgordls
  dbpvkeauyc

  kovpawxf
  ovwxkpfa
  xbknwjpcoaftq
  oxapvfkw

  ybjvaftkzheqgiuposnmxc
  ungfezmiskqvyjaphobxtc
  yjqimsvbktaonpeucfzhgrx
  nepvgsifuqytahxzmjkocb
  qmaexzipshcvjkfyonutgb

  u
  u
  u
  u

  tpgqyvjaedlkbhwr
  nytwkpqlvmgrbehxjad

  vsruxht
  rdmb
  rfb

  khqyd
  ycj

  aidrbmzkxvt
  yzvbkiorxamdt

  mzwvhblrxtn
  vqalzwcbrxjmtnd
  wlvnrtxmzcbg

  ow
  ow
  ewuob
  wo

  gl
  mnacgl
  lg
  gul
  kdflg

  oqvd
  qodvy
  qdvo
  qvoda

  rd
  fus
  thoi

  rtnz
  tqagrnlb

  wemlvjbhuqcfrtodkxzn
  pjbtruvdmhowfznlxekq
  eoyadnxbuktqshgwfmvzirlj

  kumotnwel
  lmezwoutkn
  nuemkwlot
  efnlduohmtkw

  mhaubleozw
  zwulbhmo
  mhbzouwl
  hmwulbzo

  hvjpdoiswzbenma
  ojndsepwhiq
  dwsjnhiope
  tsohjdpwien
  joipwhesnd

  edbhi
  fisdhbe

  r
  v
  v
  v

  ezlc
  czei
  azlcei
  czie
  eynczs

  ngfuhekmzxvopy
  twogyeknxvmhbjzpuf
  zxpfnygeomukvh

  ktxduimz
  vtgmurjiqk
  mtkbuia

  uykwh
  kuyhnw

  dzjqnwbrouh
  qfncpvszdeg
  cydmlqnz
  dzqtn

  xga
  hmxpdg
  fnxgeu
  nxeogu

  nsxrgu
  xngurs

  jvmudzscnalhwktry
  lrvucmjkwztsyna
  wyruzcjxlbtemsknva
  yzwvklpcqustojrmnai
  zyjntswcuarkmvl

  zq
  qz
  qz
  qz
  zqt

  gbpnqrxu
  dqnxyvwhbtgi
  csqmbfjeaokxlz

  rdtuqpxnbzj
  yzsnpu
  fcnrzpou
  penzu
  nvukhlmizwpag

  tdvfgahbiw
  gtbpsdo

  ucdprxmznhbw
  rcumdzpwnx
  dxnpzrmcuw
  drpxcmnzuw
  zxwcnpmrdu

  dhouqlfvsakg
  uaofqkdsvhgl
  uoalfhvqsgkd
  klgvfudqosah
  auhslqfkgvdo

  qkwfimrogubyhljda
  shuprevacxlndiqfjwy

  crpsetajviwmqhl
  szqdpfvimaekgbj

  geyqpl
  gzqlei
  qleg

  kcfipzjwyugsrtahboneqxdm
  uwkcmtdfopayenqbshxi
  eudhcyfpwamoxvkqlistnb

  yfqbtnwuzsdl
  lszfnquwbtyd
  fsjznbdwytulq
  bfgldzqyutwsn

  n
  uv

  vjfzuhqgaypbmcd
  hqmbpsjyugrvfzatndc
  ovfazbdipqxeclykjgum
  vmbzptjwydaguncfrq

  k
  w
  k
  k

  eipruzqndlys
  elrysidnzqu

  pzlgeciqys
  wjvrdxmunfsb

  kdy
  kd
  kd
  dlk
  kd

  yretjs
  g
  kahzubo
  rjd
  r

  hlxpawm
  xmyeltpqw
  gmpxicbv
  burmxc
  ozxmsfjdn

  dtskziwy
  qxzycupgs

  iflherjytpxg
  thienjgrfxly
  heyftrgjlix
  igyfjurphtexl
  gtyxrjleihf

  nuswkhz
  xosqihvwfrez
  hgszyw

  ukphojt
  hotkpzju
  htupjbko
  mjpkouhd

  luhsi
  shliu
  lihqsu

  iqr
  ybndlhzrgwtmkf
  rxcuq

  j
  j
  j
  j

  rwqsbyoe
  fweujxcoliya
  mpowrey

  wvn
  wv

  frbuexwg
  xmqgdwfeb

  rbyjsiqxtfcvlup
  vqpuyrifcsjxtlb
  yvtqirslxpjfbcu
  vsribxjcufylqpt

  ikcvoguphqtyjdswzexa
  ptjocgxiuhwavydsqzek
  ipcuohvqdwyxsetkagjz
  vpgdhzqckoywxaijuest

  erhdoyugavcq
  doqsvahugec
  cnhezgfavbuixdo

  lhgvknmequsctapxzbjdorf
  fodnxkrlqthcubmzvpjaeg
  fcvqmordxhklpybujgenatz
  nlmbxvpcokearhdzjtqufg
  uthcdpbvojlqewrknafgxzmi

  hwjpevzgrtmoqknydfs
  jvzstyfdhgkoqpmw

  ncw
  gwivun
  wnl
  nxw
  najwbzdrke

  ckyowhxblrt
  flabyrdwctk
  lbwripvjtykcs

  pn
  eonwtzp
  yxsirvqhcm
  fapu
  njwb

  lsjdymwpz
  zmrhuajxvewysp

  lyisuvcbdqxotkmh
  bkmrldugxsycohqitv
  xlhcvtmyqibdosuk
  hscubvoelkyqdximt

  mb
  mjbf
  rbm

  zvqlg
  gnlvjbz
  zvdgl
  dslgvzt
  vczwgl

  bem
  yqpgj
  dxflhwokatuvnzs
  irqc
  jqp

  gqolch
  hnozqgcl

  dnhwl
  hdo
  fduc

  lug
  lug
  gurkal
  lgu
  ulg

  uahmzdyxbr
  htkmwpcxbqy
  cbhyxmp

  ajv
  mjt
  j
  ji

  bfpygmtxajnk
  kpnmfbxtgayj
  pcynamktgbjxf
  tfympjvqxgnkab

  x
  x
  x
  mxf
  vqx

  wlzsgdhixr
  hgcoaiwpbluv
  wyhlig
  iwfnlhqgs
  jfgqihmxwlr

  cqrdbpoehiwfuzvgalxm
  ularwipqxcfedozmbvg
  vurqezjkoysgpalbfimxwcdt
  mcvfzqplaxwrgoebiud

  mydhxfvgzcleojiq
  ixcozgyvjdfl
  njxuwiaovpycslrzgdf

  gfwtnr
  mojdinwkf
  rfnwqhcg
  wfn

  lwise
  arl
  trzbvl
  bal

  y
  y
  y
  y

  sayqdimthfrpjvgn
  crdphnmayqbgf

  sfgtqwbzej
  pnmlcyitj

  yvtng
  tyn
  nyutg
  ytgenh
  onpty

  bleicngomsqhwfdy
  mrbnfygxpiwucoldqshke
  cqdeimynwhsfoblg
  gqesldbcijmwhonfy
  enblgcmfwdhyqois

  ufmsgkbcxz
  xfsckzmub
  umbkoxzhrsvcnf
  kzmcsbfxgu

  tuiwqd
  hbtdou

  t
  t
  t
  t
  t

  ureltqfji
  ohzkrul

  oievpqgs
  sqdvopigle
  easvqpkgio

  upkr
  urpk

  wrbipknheldxjfm
  rhjexfldkwpb
  lhrpejxfwbdk

  drybxszfetlnwjigk
  fngbltzjywsroixk

  hodteualp
  dtrpuile

  tqrbsjni
  sbcirnqt
  rsbaitqv
  qbsrit
  gbtsriq

  ovjmetdznlw
  dtjvlmonze
  zdjntemolvw
  mlouvjngzkdter

  ckrnly
  rclkyn
  cyjlkrnh
  crynkl
  ylckrn

  zjk
  zkj
  djkz
  jzk
  jzk

  xoj
  mjro
  kjuxro
  ybsjeahf

  zhwvtialqegufxmrcj
  hwljxrecaqmztgifv
  vgibmzlxwrdeacfqhjt

  nxicerwtzolfgky
  hogmsvdplbweja

  w
  clq
  i
  gi

  cilrkspgjqmw
  xhvadtlyfjobnzue

  ckytg
  nqtyg
  gyxbt
  kygtc

  fwcd
  wfc
  oebwhmil
  fdwxr

  lomdtfsihk
  sfyitokldmh
  dimyotfkls
  iovdstlmkfj
  smulideqtfok

  frazxb
  ahfbxz
  bafzx
  aftbxpz

  ubdarimsqvgtlhfjze
  eqfrvhsguzjamtidl

  hjidpgrc
  vrp
  zpxwsulqrona
  drhpftvi
  kbrdhype

  xidcskygjwmbzr
  bsqexaypghjkv

  tgxmy
  atxym
  txym

  qjrbmxtluews
  ulbrwtjsxqop
  fzbksturwmxlqj
  tbxvnsjqriuwcl

  edhvzwqxojuplbkyf
  wfphdjyczxvlkbqo
  jhxbpkvyfzdloqw
  yhmlfwoqkjpvdxbz
  qfmxikhozbvwydplj

  seyq
  yogxm

  jzbgatxhrplowqsyecvdn
  nzjvohtguxpydsrlcewab

  apzf
  zanwg
  pza
  az

  sapxfnyhbowujlcdveqiztkm
  tzskjxqcoebdunyfphi

  caruks
  rhlwsv

  cnswqfaztmdh
  uxszromtanqdfb

  cjnmstxqvdik
  qmjdcksitxvn
  cjktvxqmdnis
  cjnrsqdkxptivm

  oq
  qaion
  omq
  qo

  kzymeqtbasgn
  cuktvbsorim
  lpjxwhdf

  knflw
  ezvkn
  yuhakrnc

  vidhwxfrmnsyuct
  rzumskdfeqx

  p
  p

  duicxvgnbeopfzlqyrks
  skdetoclpbmzqfghwixr
  gfozcdskprxeaiqbml
  plkhqcifedxbgosrz

  ydtjolrxzefiaschwng
  tdoerngfhzwxjcylia
  zrawdytxhcojlgenfi

  ghvjqlifws
  sfiqklwjehrgv

  q
  q
  s
  a
  s

  et
  tme

  a
  a
  a
  a
  a

  qng
  g
  wg

  nvmlaui
  audrigo
  atnjdu
  hybxcpszkwuq
  fnu

  zmngdceqikxyuapwv
  ciwyqekgamdzvp
  ikcpavfgbwmerqyz

  mcvyjezqxrpkiu
  wlfatnmghs

  awkqenuiorcd
  lkuowsracdtzqgei
  joxhucpqrmfyvikawe

  cdn
  ndc

  fybj
  bjfy
  byjucsf
  flybjx

  zfcphgxqno
  zhmxyncpqr
  iqhwaclzupsne

  oscpyvdebfhz
  pbonsjyrelkfxvz
  wfpvyigbmaeztoqus

  ypbfhaivmkx
  xpjfhikyoca

  wkzvxlebarsmcdpi
  xidcbpswmazekr
  zsxwidpmekacrb
  pwczxsedakirbm

  vfupqwdshxygkmrzol
  wslmypfkogrxzqdvh
  qwlxsrfzpgdomvyhk

  cmkdiapszuyb
  bkpyduimascz

  vjpxmdzfwkuq
  eycbgsnhltmapxo

  xmnklfpugdewtj
  okzerxjuihqcptdmysf

  yajvhbtowixds
  dvynabxjiwhs
  asydoixzbh
  ihjdxbasyk
  lifxrbspedahyumcg

  snragze
  gmszrnae
  egrazsn
  ensragz

  odi
  odi
  ido
  odi

  mvogdzfker
  veongkrpzmdf
  vgekmrzdfo
  ombjdfqykergvz
  hzsormkdgfve

  l
  l
  l
  ly

  kgnpliuwmsebhjfrcyqxotvazd
  mzqryvgsftauxpcknehbiwojld

  vczkrabfmhpyjteui
  merjtikybvaugz
  aieydktjrmzvubg
  yeslqoibauvtkmrjz

  vi
  vip
  eigv
  vix
  iv

  mcuknbexfowszpvtyi
  ztmfwonvcsapqxyieb
  etowynxzcpirmbvsf
  wjfnyvopzetkmiusbcx

  ywhqemsx
  banksxwemy
  ymsexw
  smyewx
  szxeywm

  yvqtnsahzpwebgr
  zgtjnevyapwbhrs
  jzynhrpvwgsbat
  obtynrfwslcahvzgpm
  eytrpagzwsjvbkhn

  ynwutpmvhj
  mvwjpuyt
  wupzyjvmt

  kwnyatozcmdqbpsvejfrxug
  vkzjaogfmqsxhnyctpu
  cozypjmtvlxquakgfnsi

  qrwtgecs
  daley
  emh

  qmbjwe
  qebfwjm
  qewjm
  qjiwem

  dqc
  tad
  qdcs

  zrvjnfpe
  zpefunyvqc
  fzpvern
  pnefvz
  envpfz

  nduhkvstxqmbfyr
  ufmhbtkqvxdnpy
  hdntqxuvmbkfy

  ot
  o
  yv
  xp

  evkrifstpzgbahl
  vzkmdtchgseajyfub
  bgtnkxvheoaqifsz

  wxec
  wfuie
  awmj
  ghsnkvwbqor
  mcexwf

  teosna
  tnkb
  ptm
  t

  r
  na
  ykx

  jdl
  mzjtp

  xbpj
  tzrkxba
  xnbjmgosv
  mhxbw

  j
  j
  j
  j

  xn
  lrvt
  htg
  mr

  hafkb
  fkab
  afbk

  zlyxomawvuib
  vxwzbaymolui

  tcdfzgx
  ql
  luo
  uh

  ixtbluahoeqgsv
  eovsiglhuqanxtb

  ntychjig
  chyijtgn
  hcnjtiyg
  tgjnhiyc
  tgjiychn

  khomqatzscydwunfe
  ygoazrdukh
  zokbrlyaudjh

  uojynifthzvcgqp
  phnvryfbtucl

  sbeizdtjopxu
  nouqbeykmszd

  cga
  gca
  cag

  hiogxbslyptfc
  pilwxcthogysb
  holsibtcypfgx

  oahyr
  pkjro

  qgfkj
  gjzk
  jgvk

  kw
  wk
  kw
  wk

  bxvmnks
  sfmbva

  fsocn
  ygfopn

  wbarmxtfyjzenicvlhps
  aefdirlyvzjpwtcmnh
  rqymwfzjpevchiaotnl
  lietnypmcrvhowfjaz
  ztjcehympnavirlwf

  gqsnyhtafdcbki
  yncbhxiakgpqt

  mikyzoxflndetbp
  ebqdwiopkhyfxnl
  jbscverlgfyauo

  bkewpj
  n
  solnxmfr

  ybxa
  ybxa
  xyba
  byax
  abxy

  sgbo
  sg

  unvqlyhzdaxrcwg
  dxvhaugicrzqnlw
  mrplcqatdxzbuvgnwh
  vzaurnhdgqlxwc
  ucdwavqhylxrngz

  frhdaek
  fpuwosv

  qm
  m
  smg
  ")

Part 1

Problem

— Day 6: Custom Customs —

As your flight approaches the regional airport where you'll switch to a much larger plane, customs declaration forms are distributed to the passengers.

The form asks a series of 26 yes-or-no questions marked a through z. All you need to do is identify the questions for which anyone in your group answers "yes". Since your group is just you, this doesn't take very long.

However, the person sitting next to you seems to be experiencing a language barrier and asks if you can help. For each of the people in their group, you write down the questions for which they answer "yes", one per line. For example:

abcx
abcy
abcz

In this group, there are 6 questions to which anyone answered "yes": a, b, c, x, y, and z. (Duplicate answers to the same question don't count extra; each question counts at most once.)

Another group asks for your help, then another, and eventually you've collected answers from every group on the plane (your puzzle input). Each group's answers are separated by a blank line, and within each group, each person's answers are on a single line. For example:

abc

a
b
c

ab
ac

a
a
a
a

b

This list represents answers from five groups:

The first group contains one person who answered "yes" to 3 questions: a, b, and c. The second group contains three people; combined, they answered "yes" to 3 questions: a, b, and c. The third group contains two people; combined, they answered "yes" to 3 questions: a, b, and c. The fourth group contains four people; combined, they answered "yes" to only 1 question, a. The last group contains one person who answered "yes" to only 1 question, b.

In this example, the sum of these counts is 3 + 3 + 3 + 1 + 1 = 11.

For each group, count the number of questions to which anyone answered "yes". What is the sum of those counts?

Solution

I think this is basic set manipulation. Basically, for each group of people, build a set out of the letters they answered yes to, then find the length of that set. Then add the lengths. Okay, this shouldnt be too hard.

  <<aoc>>
  (defun set-from-group (group)
    "Build a set from a group.
    The group will be a newline-separated string."
    ;; basically, i just need to build a list from the string
    ;; then remove duplicates.
    (let ((lst (seq-filter (lambda (c)
                             (not (char-equal c ?\n)))
                           (string-to-list group))))
      (delete-dups lst)))

  (aoc
   input "\n\n"
   (seq-reduce
    (lambda (result group)
      (+ result
         (length (set-from-group group))))
    lines 0))
6532

Awesome, 6532 is right!

Part 2

Problem

— Part Two —

As you finish the last group's customs declaration, you notice that you misread one word in the instructions:

You don't need to identify the questions to which anyone answered "yes"; you need to identify the questions to which everyone answered "yes"!

Using the same example as above:

abc

a
b
c

ab
ac

a
a
a
a

b

This list represents answers from five groups:

In the first group, everyone (all 1 person) answered "yes" to 3 questions: a, b, and c. In the second group, there is no question to which everyone answered "yes". In the third group, everyone answered yes to only 1 question, a. Since some people did not answer "yes" to b or c, they don't count. In the fourth group, everyone answered yes to only 1 question, a. In the fifth group, everyone (all 1 person) answered "yes" to 1 question, b.

In this example, the sum of these counts is 3 + 0 + 1 + 1 + 1 = 6.

For each group, count the number of questions to which everyone answered "yes". What is the sum of those counts?

Solution

Hm… well, it wouldve been easy if Id set up the previous part to use or: this one would just use and. Of course I didnt make it easy on myself though!

Okay, Ive had a think and this is what Im going to do. The number of answers everyone said yes to is just the total number of answers 26 ✕ n (where n is the number of people in the group) minus the number of answers where anyone said yes. So I have to figure out how many people are in each group, use set-from-group (from part 1) to find the number of any yeses, then subtract that from the total possible answers.

  (aoc
   input "\n\n"
   (seq-reduce
    (lambda (result group)
      (let* ((members (split-string group))
             (total-questions (length members))
             (anyone-yeses-count
              (length (set-from-group group))))
        (+ result (- total-questions
                     anyone-yeses-count))))
    lines 0))
-4383

Damn, 36680 is too high. Hm. Lets try breaking the lambda out into a function. (By the way, I tried adding a -1 to the calculation too 36193 is still too high.

  (defun unanimous-yes-count (group)
    "Count how many answers were answered yes by everyone in GROUP.
  GROUP is a newline-separated string."
    (let* ((members (split-string group "\n"))
           (total-questions 26)
           (anyone-yes-count (length (set-from-group group))))
      (list total-questions anyone-yes-count
            (- total-questions anyone-yes-count))))

  (aoc
   input "\n\n"
   (let ((result))
     (dolist (ln lines result)
       (push (unanimous-yes-count ln) result))
   (reverse result)))
26 9 17
26 21 5
26 10 16
26 6 20
26 13 13
26 15 11
26 7 19
26 12 14
26 17 9
26 16 10
26 26 0
26 7 19
26 15 11
26 18 8
26 22 4
26 19 7
26 19 7
26 10 16
26 17 9
26 11 15
26 2 24
26 26 0
26 26 0
26 5 21
26 14 12
26 23 3
26 24 2
26 7 19
26 12 14
26 7 19
26 12 14
26 21 5
26 18 8
26 21 5
26 19 7
26 14 12
26 15 11
26 14 12
26 20 6
26 16 10
26 17 9
26 18 8
26 10 16
26 23 3
26 3 23
26 9 17
26 8 18
26 20 6
26 25 1
26 2 24
26 5 21
26 14 12
26 7 19
26 17 9
26 5 21
26 21 5
26 6 20
26 23 3
26 6 20
26 1 25
26 11 15
26 21 5
26 11 15
26 8 18
26 23 3
26 9 17
26 5 21
26 16 10
26 11 15
26 9 17
26 8 18
26 8 18
26 5 21
26 20 6
26 3 23
26 6 20
26 4 22
26 25 1
26 6 20
26 7 19
26 3 23
26 2 24
26 21 5
26 19 7
26 2 24
26 7 19
26 3 23
26 6 20
26 17 9
26 7 19
26 14 12
26 7 19
26 15 11
26 2 24
26 2 24
26 12 14
26 11 15
26 16 10
26 19 7
26 8 18
26 23 3
26 15 11
26 12 14
26 15 11
26 18 8
26 26 0
26 15 11
26 4 22
26 6 20
26 8 18
26 19 7
26 20 6
26 8 18
26 19 7
26 24 2
26 23 3
26 6 20
26 1 25
26 21 5
26 15 11
26 18 8
26 18 8
26 3 23
26 5 21
26 10 16
26 19 7
26 3 23
26 21 5
26 23 3
26 8 18
26 12 14
26 7 19
26 13 13
26 13 13
26 26 0
26 6 20
26 4 22
26 17 9
26 14 12
26 5 21
26 10 16
26 18 8
26 4 22
26 19 7
26 9 17
26 4 22
26 24 2
26 7 19
26 9 17
26 2 24
26 23 3
26 3 23
26 5 21
26 22 4
26 14 12
26 16 10
26 21 5
26 26 0
26 10 16
26 5 21
26 25 1
26 17 9
26 19 7
26 17 9
26 26 0
26 11 15
26 25 1
26 6 20
26 2 24
26 9 17
26 17 9
26 12 14
26 5 21
26 9 17
26 15 11
26 7 19
26 2 24
26 20 6
26 4 22
26 14 12
26 16 10
26 18 8
26 23 3
26 25 1
26 13 13
26 8 18
26 2 24
26 20 6
26 15 11
26 8 18
26 23 3
26 16 10
26 8 18
26 23 3
26 9 17
26 8 18
26 4 22
26 6 20
26 2 24
26 15 11
26 2 24
26 20 6
26 7 19
26 5 21
26 7 19
26 9 17
26 19 7
26 25 1
26 20 6
26 11 15
26 12 14
26 25 1
26 1 25
26 15 11
26 3 23
26 11 15
26 8 18
26 22 4
26 10 16
26 24 2
26 22 4
26 23 3
26 21 5
26 24 2
26 22 4
26 15 11
26 10 16
26 4 22
26 16 10
26 4 22
26 13 13
26 7 19
26 21 5
26 10 16
26 20 6
26 10 16
26 7 19
26 4 22
26 26 0
26 23 3
26 6 20
26 11 15
26 17 9
26 2 24
26 15 11
26 2 24
26 12 14
26 13 13
26 14 12
26 10 16
26 25 1
26 7 19
26 2 24
26 20 6
26 4 22
26 13 13
26 14 12
26 17 9
26 10 16
26 11 15
26 16 10
26 25 1
26 26 0
26 2 24
26 11 15
26 11 15
26 9 17
26 15 11
26 16 10
26 14 12
26 24 2
26 13 13
26 14 12
26 10 16
26 3 23
26 3 23
26 22 4
26 24 2
26 22 4
26 22 4
26 4 22
26 4 22
26 16 10
26 26 0
26 14 12
26 22 4
26 25 1
26 13 13
26 22 4
26 14 12
26 23 3
26 1 25
26 19 7
26 11 15
26 7 19
26 13 13
26 17 9
26 5 21
26 10 16
26 6 20
26 9 17
26 9 17
26 26 0
26 13 13
26 10 16
26 17 9
26 7 19
26 2 24
26 9 17
26 18 8
26 15 11
26 6 20
26 22 4
26 12 14
26 6 20
26 24 2
26 3 23
26 26 0
26 26 0
26 13 13
26 12 14
26 12 14
26 24 2
26 21 5
26 8 18
26 26 0
26 14 12
26 3 23
26 26 0
26 2 24
26 12 14
26 21 5
26 4 22
26 15 11
26 25 1
26 14 12
26 14 12
26 17 9
26 11 15
26 6 20
26 19 7
26 1 25
26 18 8
26 3 23
26 11 15
26 15 11
26 20 6
26 19 7
26 26 0
26 19 7
26 17 9
26 19 7
26 22 4
26 16 10
26 19 7
26 5 21
26 13 13
26 26 0
26 8 18
26 9 17
26 6 20
26 16 10
26 6 20
26 15 11
26 5 21
26 23 3
26 25 1
26 23 3
26 15 11
26 11 15
26 1 25
26 18 8
26 17 9
26 10 16
26 22 4
26 15 11
26 9 17
26 1 25
26 13 13
26 12 14
26 4 22
26 15 11
26 18 8
26 11 15
26 12 14
26 15 11
26 8 18
26 4 22
26 14 12
26 20 6
26 24 2
26 6 20
26 26 0
26 9 17
26 13 13
26 16 10
26 9 17
26 18 8
26 25 1
26 20 6
26 6 20
26 21 5
26 20 6
26 8 18
26 22 4
26 7 19
26 24 2
26 10 16
26 17 9
26 14 12
26 6 20
26 26 0
26 14 12
26 19 7
26 1 25
26 25 1
26 19 7
26 13 13
26 3 23
26 3 23
26 1 25
26 4 22
26 25 1
26 20 6
26 23 3
26 25 1
26 3 23
26 9 17
26 20 6
26 26 0
26 14 12
26 16 10
26 18 8
26 12 14
26 24 2
26 23 3
26 25 1
26 8 18
26 3 23
26 18 8
26 2 24
26 26 0
26 23 3
26 6 20
26 22 4
26 13 13
26 22 4
26 11 15
26 26 0
26 14 12
26 8 18
26 6 20
26 12 14
26 16 10
26 6 20
26 25 1
26 20 6
26 10 16
26 6 20
26 7 19
26 17 9
26 1 25
26 9 17
26 5 21
26 12 14
26 12 14
26 15 11
26 8 18
26 22 4
26 18 8
26 17 9
26 3 23
26 14 12
26 8 18
26 7 19
26 2 24
26 9 17
26 8 18
26 23 3
26 16 10
26 26 0
26 14 12
26 4 22
26 4 22
26 20 6
26 13 13
26 4 22

No… thats higher than the previous answer!!! hmmmmm. Lets try this a totally different way.

Wait a minute! The first answer was 3680 it makes no sense that the answre to part 2 would be 10 times higher than that. Im doing something wrong.

Okay, 4870 is too high too. Now were getting somewhere.

IVE GOT IT!! Its the set difference, not arithmetic difference!

  (aoc
   input "\n\n"
   (seq-reduce
    (lambda (result group)
      (let* ((members (split-string group))
             (total-qs 26)
             (anyone-yeses-count
              (length (set-from-group group))))
        (+ result (- total-qs
                     anyone-yeses-count))))
    lines 0))
6130

NOPE. Ugggghhhh

Okay, I really need to try another tack. Ive played this one out.

Another tack
    (defun unanimous-yes-count (group)
      (let* ((people (split-string group))
             (unanimous-candidates
              (string-to-list (pop people)))
             (result unanimous-candidates))
        (dolist (person people result)
          (let ((p (string-to-list person)))
            (dolist (answer result)
              (if (not (memq answer p))
                  (setq result (remq answer result))))))
        (length result)
  ))

  (aoc
   input "\n\n"
   (seq-reduce
    (lambda (result group)
      (+ result
         (unanimous-yes-count group)))
    lines 0))
3427

THANK GOD!

Okay, tomorrow Im going to start on a new file. This one is 10734 lines long and its annoying.

Footnotes

1By the way, inserting this shrug emoji was absolutely maddening to do on Emacs on Windows. I've got to fix my clipboard character set.