From 5a2aec7e76b498a97bed59218197ce472d1621b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= <tm@tlater.net> Date: Fri, 4 Dec 2020 20:15:55 +0000 Subject: [PATCH 1/8] Complete day 4.1 --- day-4/.gitignore | 1 + day-4/Cargo.lock | 78 ++++ day-4/Cargo.toml | 10 + day-4/input | 1068 +++++++++++++++++++++++++++++++++++++++++++++ day-4/src/main.rs | 80 ++++ 5 files changed, 1237 insertions(+) create mode 100644 day-4/.gitignore create mode 100644 day-4/Cargo.lock create mode 100644 day-4/Cargo.toml create mode 100644 day-4/input create mode 100644 day-4/src/main.rs diff --git a/day-4/.gitignore b/day-4/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/day-4/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/day-4/Cargo.lock b/day-4/Cargo.lock new file mode 100644 index 0000000..44f11e3 --- /dev/null +++ b/day-4/Cargo.lock @@ -0,0 +1,78 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "day-4" +version = "0.1.0" +dependencies = [ + "indoc", +] + +[[package]] +name = "indoc" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47741a8bc60fb26eb8d6e0238bbb26d8575ff623fdc97b1a2c00c050b9684ed8" +dependencies = [ + "indoc-impl", + "proc-macro-hack", +] + +[[package]] +name = "indoc-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce046d161f000fffde5f432a0d034d0341dc152643b2598ed5bfce44c4f3a8f0" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", + "unindent", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "1.0.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8833e20724c24de12bbaba5ad230ea61c3eafb05b881c7c9d3cfe8638b187e68" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "unindent" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f14ee04d9415b52b3aeab06258a3f07093182b88ba0f9b8d203f211a7a7d41c7" diff --git a/day-4/Cargo.toml b/day-4/Cargo.toml new file mode 100644 index 0000000..223e26a --- /dev/null +++ b/day-4/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "day-4" +version = "0.1.0" +authors = ["Tristan Daniël Maat <tm@tlater.net>"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +indoc = "0.3" diff --git a/day-4/input b/day-4/input new file mode 100644 index 0000000..5b0a490 --- /dev/null +++ b/day-4/input @@ -0,0 +1,1068 @@ +hgt:159cm +pid:561068005 eyr:2025 iyr:2017 cid:139 ecl:blu hcl:#ceb3a1 +byr:1940 + +iyr:2014 +byr:1986 pid:960679613 eyr:2025 ecl:hzl + +cid:211 ecl:blu hcl:#7d3b0c iyr:2011 pid:006632702 +byr:1982 eyr:2023 hgt:68in + +hcl:#341e13 hgt:192 iyr:2028 +ecl:utc +eyr:2027 byr:1979 pid:653515689 + +eyr:2026 hgt:161cm ecl:#1850b8 +pid:298779494 hcl:b2114e iyr:1953 + +hgt:155cm +hcl:#a97842 iyr:2019 +ecl:gry byr:1939 +pid:935099157 eyr:2027 + +eyr:2024 ecl:grn +pid:102781360 byr:1962 iyr:2013 hcl:#602927 + +hcl:#602927 hgt:152cm +pid:659074205 ecl:brn iyr:2014 byr:1951 + +iyr:2025 hcl:8464b2 byr:2030 pid:976783295 hgt:155cm ecl:dne + +hcl:#ceb3a1 byr:1984 pid:863872932 +iyr:2016 hgt:190cm ecl:grn eyr:2026 + +eyr:2030 hcl:#efcc98 +cid:166 pid:894418497 ecl:hzl +hgt:189cm iyr:2014 byr:1966 + +byr:1937 iyr:2017 eyr:2028 +ecl:amb +hgt:165cm cid:84 +pid:435289747 + +hgt:166cm hcl:#6b5442 byr:1953 eyr:2023 iyr:2010 +pid:948173962 ecl:amb + +byr:1962 cid:276 iyr:2010 hgt:183cm pid:097154397 +hcl:#341e13 eyr:2024 + +hgt:61cm +byr:1942 ecl:xry hcl:#05e97d pid:42823283 +eyr:2024 + +hcl:#888785 +pid:960190685 byr:1967 iyr:2012 cid:99 eyr:2021 +hgt:76in + +eyr:2025 byr:1958 hcl:#18171d iyr:2012 pid:759427419 +ecl:hzl + +ecl:#829d2e +cid:60 iyr:2028 +byr:1979 hcl:caff12 eyr:1931 pid:#fd7aab hgt:184cm + +cid:251 byr:1981 pid:625590775 +hcl:#a97842 eyr:2020 +ecl:amb hgt:178cm +iyr:2016 + +pid:026891577 ecl:amb byr:2014 +hcl:bc419f eyr:2026 +iyr:1948 +hgt:123 cid:67 + +ecl:hzl +hgt:152cm hcl:#efcc98 +byr:1993 +eyr:2025 + +ecl:grn iyr:1924 eyr:2039 pid:8441306576 +hgt:163in +byr:2012 +cid:193 + +ecl:#78f4fa +eyr:2020 hgt:165cm byr:1965 pid:987868257 iyr:2012 +cid:331 hcl:z + +ecl:brn cid:289 pid:868305933 +byr:1936 hgt:174cm iyr:2016 hcl:#623a2f eyr:2021 + +hcl:#2a6308 eyr:2027 hgt:154cm ecl:grn +iyr:2012 +byr:1940 +pid:675209536 + +pid:186cm eyr:2022 +hcl:#fffffd hgt:151cm iyr:2016 ecl:hzl byr:1954 + +ecl:grn hgt:177cm pid:725111435 byr:1927 eyr:2027 cid:154 iyr:2010 hcl:#623a2f + +pid:801551597 cid:55 eyr:2028 hgt:193cm hcl:#a97842 +ecl:hzl byr:1942 iyr:2015 + +cid:176 eyr:2030 iyr:2018 byr:1932 hgt:162cm pid:896180324 ecl:amb hcl:#6b5442 + +cid:239 ecl:grn iyr:1953 pid:9500162195 +byr:1998 +hgt:182cm hcl:#733820 eyr:1966 + +eyr:2030 +pid:919325322 hcl:z iyr:2024 hgt:71cm ecl:#1e935c byr:2026 + +iyr:2012 +ecl:gry eyr:2025 hcl:#602927 hgt:168cm byr:1925 +pid:303312675 + +hgt:150in iyr:2014 ecl:gry eyr:2029 +byr:2029 +cid:228 + +ecl:#9524e0 byr:2026 hcl:z +iyr:2023 +cid:325 +eyr:1996 +pid:6172325031 hgt:191 + +ecl:#689e88 +eyr:1937 +cid:75 byr:1963 iyr:2024 +pid:4980937 hgt:156cm +hcl:#fffffd + +pid:719820090 iyr:2020 hgt:165cm +hcl:#ceb3a1 byr:1997 ecl:blu eyr:2027 + +eyr:2025 +pid:241723456 +iyr:2011 +byr:1953 cid:230 hgt:185cm hcl:#efcc98 ecl:oth + +byr:1936 hcl:#623a2f +iyr:2010 hgt:156cm +eyr:2022 +pid:064253102 ecl:brn + +cid:332 hcl:#a97842 eyr:2026 ecl:gry iyr:2019 pid:#4e4a46 +hgt:150cm +byr:1987 + +ecl:grn hgt:67in +iyr:2012 +byr:1953 pid:910793005 hcl:#341e13 eyr:2020 + +iyr:2024 eyr:2030 cid:204 hgt:166cm pid:218828260 +hcl:701b48 ecl:gry byr:1930 + +hgt:162cm pid:024916763 eyr:2026 ecl:hzl +hcl:#efcc98 iyr:2019 byr:1921 + +eyr:2025 +iyr:2017 ecl:hzl hcl:#fffffd hgt:167cm pid:779214145 + +eyr:2022 +hcl:#6b5442 byr:1941 ecl:grn hgt:169cm iyr:2014 +pid:610328167 + +iyr:2026 cid:179 pid:193cm +ecl:#deb37c +byr:1958 eyr:2024 +hgt:185cm + +pid:907508207 ecl:oth byr:1941 iyr:2017 hcl:#341e13 +eyr:2030 hgt:186cm + +iyr:2018 byr:1925 +ecl:brn eyr:2023 pid:903196231 +hgt:159cm +hcl:#a97842 cid:323 + +hgt:185cm ecl:hzl eyr:2022 iyr:2020 pid:572453155 hcl:#fffffd + +hcl:#a97842 ecl:blu pid:#ab3597 eyr:1964 byr:2030 +hgt:181cm iyr:2018 + +ecl:blu +hcl:#602927 +cid:234 +hgt:68in eyr:2021 pid:257420555 iyr:2014 byr:1972 + +hcl:#7d3b0c eyr:2022 +hgt:152cm byr:1974 +iyr:2017 +pid:353127736 +ecl:gry + +iyr:2018 eyr:2028 byr:1924 hcl:#69929e ecl:gry +hgt:68in pid:942207567 + +eyr:2028 cid:90 +hgt:185cm +ecl:amb byr:1990 pid:947625812 hcl:#623a2f iyr:2011 + +eyr:2023 byr:1996 hgt:175cm +iyr:2012 +hcl:#866857 ecl:blu +pid:437669135 + +byr:1937 eyr:2030 +hcl:#866857 iyr:2017 pid:513963895 hgt:157cm +ecl:grn + +iyr:2016 hcl:#623a2f eyr:2025 +pid:559150893 hgt:176cm +byr:1920 ecl:amb + +byr:1982 +eyr:1961 ecl:hzl +hgt:167cm hcl:#888785 iyr:2011 cid:261 pid:709006236 + +pid:307171649 byr:1935 hcl:#888785 hgt:182cm ecl:brn eyr:2030 iyr:2013 +cid:256 + +ecl:hzl +eyr:1998 +byr:2009 +hgt:153cm iyr:2010 +hcl:#888785 pid:140487128 + +iyr:2019 cid:78 +hgt:169cm +hcl:#888785 ecl:hzl byr:1997 eyr:2028 + +hgt:182in eyr:2025 hcl:#cfa07d ecl:#27a1c9 byr:2005 pid:8143047758 + +byr:2013 hgt:178in +eyr:1933 +pid:829007679 iyr:2016 hcl:#783308 +ecl:grn + +cid:267 byr:1930 pid:949963673 eyr:2026 +ecl:grn iyr:2020 +hgt:188cm hcl:#6b5442 + +eyr:2022 pid:254482159 +byr:1935 iyr:2017 +ecl:hzl +hcl:#b6652a +hgt:165cm + +hcl:109d15 hgt:72cm +cid:258 byr:2023 eyr:1987 ecl:grt iyr:2022 + +byr:1969 +ecl:oth hgt:151cm +pid:578662559 +eyr:2024 iyr:2015 hcl:#602927 +cid:343 + +iyr:2011 byr:1989 +ecl:brn eyr:2029 pid:123354233 +hcl:#efcc98 + +hcl:#a97842 iyr:2010 pid:558586208 +eyr:2029 byr:2002 ecl:amb +cid:225 hgt:152cm + +eyr:2005 byr:2024 iyr:1924 ecl:gmt cid:186 pid:#886ae9 +hcl:3cf4cd hgt:74cm + +ecl:gry +eyr:2029 +iyr:2013 +hgt:178cm hcl:#7d3b0c + +byr:1970 hcl:#6b5442 hgt:155cm iyr:2020 ecl:hzl +pid:698123164 eyr:2030 cid:185 + +hcl:#6b5442 ecl:hzl +iyr:2014 cid:324 pid:149063285 hgt:64in eyr:2023 +byr:1949 + +hcl:#866857 +eyr:2025 +iyr:2012 cid:116 hgt:185cm +pid:416329937 +ecl:grn byr:1962 + +iyr:2020 cid:55 byr:1985 hcl:#733820 pid:237883033 eyr:2020 ecl:blu + +iyr:2020 hgt:71in +ecl:hzl byr:1960 cid:53 hcl:#888785 pid:590574853 eyr:2024 + +pid:834729501 iyr:2019 hgt:72in byr:1977 +hcl:#604861 ecl:oth eyr:2024 + +pid:111536282 ecl:gry +hgt:69in eyr:2021 byr:1940 +iyr:2019 +hcl:#ceb3a1 + +hgt:186cm pid:045765056 ecl:gry byr:1958 iyr:2012 +eyr:2025 hcl:#cfa07d + +hgt:61in eyr:2023 pid:4189258985 ecl:brn iyr:1995 +hcl:#602927 byr:2017 + +byr:1984 hcl:#866857 +iyr:2013 pid:927074474 hgt:168cm +eyr:2021 ecl:oth + +hgt:186cm +pid:948677443 iyr:2014 hcl:#866857 byr:1968 ecl:amb eyr:2027 + +eyr:2028 cid:260 hcl:#623a2f pid:500330326 +iyr:2018 hgt:170cm +ecl:gry +byr:1960 + +hgt:71cm +pid:6209572 byr:1927 iyr:2011 ecl:utc hcl:3bc47a eyr:1984 + +hgt:164cm cid:160 iyr:2010 +byr:1922 eyr:2024 hcl:#c0946f ecl:gry pid:867476938 + +cid:316 +iyr:2015 hcl:#b6652a hgt:72cm pid:#c37dbf byr:2022 eyr:2036 ecl:#8bd8f4 + +iyr:2016 hgt:172cm +pid:482664712 ecl:hzl eyr:2024 hcl:#602927 byr:1945 + +eyr:2029 pid:883381915 +hgt:174cm byr:1937 hcl:#fffffd ecl:gry cid:91 + +eyr:2029 pid:302832265 hcl:#ceb3a1 byr:2010 +hgt:64 iyr:1960 + +hgt:170cm eyr:2030 pid:846949920 +hcl:#ceb3a1 +ecl:hzl iyr:2016 byr:1945 + +hcl:#efcc98 +pid:406029852 eyr:2023 byr:1981 ecl:blu iyr:2013 + +pid:788563693 hcl:#a97842 hgt:172cm eyr:2022 ecl:brn iyr:2010 byr:2002 + +iyr:2013 +hgt:60cm hcl:#7d3b0c pid:6594060725 ecl:#46a7d7 eyr:2023 byr:1995 + +cid:313 byr:1964 pid:102442749 eyr:2020 +hgt:167cm +hcl:#341e13 + +ecl:grn hgt:163cm pid:405504213 cid:349 hcl:#733820 eyr:2029 iyr:2011 + +ecl:hzl pid:470689685 iyr:2015 byr:1980 hgt:180cm eyr:2027 + +eyr:2023 iyr:2013 +hgt:189cm hcl:#866857 byr:1981 +cid:313 +ecl:brn pid:386584267 + +iyr:2011 +hcl:#7d3b0c +eyr:2027 +ecl:gry byr:1931 +hgt:71in +pid:435568613 + +eyr:2021 +pid:443386140 hgt:192cm iyr:2015 byr:1974 + +byr:1989 ecl:oth iyr:2011 +eyr:2027 +pid:761106563 hcl:#efcc98 +hgt:60in + +byr:1933 ecl:brn pid:607926472 +hcl:#cfa07d eyr:2026 +iyr:2010 + +ecl:hzl eyr:2027 hgt:175cm +pid:68527368 +byr:1980 iyr:2017 hcl:#341e13 + +hgt:159cm pid:6199921925 iyr:1920 byr:1950 ecl:amb cid:229 eyr:2034 + +pid:060780170 ecl:gmt +eyr:1961 hgt:184cm hcl:#a97842 byr:2007 + +eyr:2025 byr:1970 ecl:brn hgt:183cm pid:423232940 hcl:#cfa07d cid:283 + +hcl:#18171d hgt:191cm +byr:1951 +eyr:2029 +pid:627632195 cid:268 iyr:2012 + +eyr:2025 iyr:2019 hgt:163cm +ecl:oth pid:967756889 +byr:1938 + +hgt:160cm iyr:2015 +ecl:#9cf598 pid:297446459 cid:123 byr:1968 eyr:1970 +hcl:#efcc98 + +ecl:hzl pid:311990731 hgt:171cm hcl:#602927 byr:1978 +eyr:2026 cid:254 iyr:2014 + +hcl:#8e0dfc +pid:961997362 byr:1950 eyr:2027 hgt:184in ecl:blu iyr:2015 cid:266 + +pid:953859016 iyr:2018 hcl:#341e13 ecl:grn cid:61 +hgt:192cm +eyr:2022 byr:1920 + +eyr:2026 pid:149020634 byr:1942 iyr:2021 hcl:#6b5442 +ecl:oth hgt:176in + +eyr:2025 hgt:176cm +iyr:2020 ecl:oth hcl:#efcc98 pid:196082064 byr:2002 + +hgt:172in hcl:z +pid:#b454a0 +ecl:#d7a600 +byr:1977 +eyr:2035 iyr:2014 + +cid:254 iyr:2020 +pid:716596533 +hcl:#341e13 byr:1947 +hgt:150cm ecl:hzl eyr:2028 + +iyr:2019 pid:190601635 byr:1922 hcl:#18171d hgt:71in ecl:brn eyr:2021 + +byr:1938 iyr:2019 eyr:2028 pid:568504071 hcl:#efcc98 hgt:178cm ecl:amb + +pid:921417345 eyr:2020 ecl:brn hcl:#c0946f +hgt:168cm +byr:1983 cid:170 +iyr:2018 + +iyr:2020 cid:212 eyr:2002 pid:61850316 hgt:148 hcl:#b6652a +byr:2024 ecl:grn + +hcl:z eyr:1985 iyr:2015 hgt:72cm ecl:brn pid:599880521 + +pid:166cm hcl:z +hgt:165 eyr:2036 +cid:152 iyr:1943 +ecl:zzz + +eyr:2021 iyr:2014 +hgt:156cm +pid:654181902 ecl:amb +byr:1946 +hcl:#733820 + +iyr:2019 +hgt:189cm byr:1940 pid:419593669 ecl:amb +cid:149 hcl:#fffffd eyr:2020 + +hgt:172cm +ecl:lzr pid:788208394 hcl:#341e13 cid:183 +iyr:2020 eyr:2027 byr:1988 + +byr:2030 ecl:#d82c54 iyr:2014 +hcl:#be9be7 eyr:2027 pid:1291285950 hgt:61cm + +ecl:hzl +hcl:#a97842 hgt:186cm byr:1992 eyr:2022 + +iyr:2017 hgt:191cm pid:097984693 eyr:2025 byr:1963 +cid:333 +ecl:blu + +ecl:zzz pid:425594420 +byr:1983 +hcl:z +eyr:2028 hgt:184cm +iyr:1937 + +hgt:167cm +eyr:2025 hcl:#623a2f pid:575911832 +cid:305 byr:1939 iyr:2020 + +iyr:2015 hgt:179cm hcl:d678e0 byr:2030 pid:284187009 eyr:1977 cid:285 + +pid:405789549 byr:1982 eyr:2020 hcl:#623a2f +hgt:161cm iyr:2013 ecl:amb + +pid:775860836 hgt:184cm hcl:#fffffd ecl:amb byr:1930 eyr:2022 iyr:2016 + +iyr:2020 byr:1979 +eyr:2024 hgt:171cm +ecl:brn hcl:#ceb3a1 pid:853915000 + +iyr:2015 pid:244459567 +hcl:#18171d cid:224 byr:1931 eyr:2022 hgt:169cm ecl:gry + +iyr:2017 cid:308 eyr:2026 ecl:blu hgt:59in byr:1953 +hcl:#ceb3a1 pid:466915764 + +hcl:#7d3b0c +byr:1940 iyr:2015 +eyr:2020 pid:950614940 ecl:amb +hgt:179cm + +byr:2010 +cid:106 eyr:2022 +iyr:2020 pid:336057617 ecl:brn hcl:f13e26 +hgt:182cm + +byr:1981 iyr:2017 hgt:152cm +hcl:#fffffd +eyr:2024 ecl:gry + +cid:216 hgt:193cm +byr:1975 ecl:oth pid:684529055 iyr:2018 eyr:2020 hcl:#18171d + +hgt:150cm +eyr:2028 +hcl:#cfa07d ecl:grn +iyr:2018 byr:1951 pid:749102509 + +pid:937451204 hcl:#341e13 iyr:2020 +hgt:171cm eyr:2021 +byr:1941 +ecl:hzl + +cid:69 +iyr:2014 eyr:2022 pid:174789690 hgt:157cm byr:1961 ecl:hzl +hcl:#a97842 + +hcl:#7d3b0c pid:658134059 hgt:65in byr:2005 ecl:#2dcb50 iyr:2012 +eyr:2030 + +eyr:2027 +hgt:68in ecl:oth hcl:#888785 iyr:2016 pid:181577931 + +iyr:1997 byr:1994 +hgt:189cm +ecl:gry pid:564165515 +eyr:2029 hcl:#ceb3a1 + +hcl:#602927 eyr:2024 +cid:130 +iyr:2015 ecl:blu +hgt:184cm byr:1996 +pid:897871188 + +ecl:oth hcl:#623a2f +iyr:2016 pid:012591439 byr:1937 eyr:2022 hgt:176cm + +eyr:2020 +byr:1965 +iyr:2013 hgt:193cm +hcl:#ceb3a1 +ecl:hzl pid:177120440 + +byr:1934 iyr:2015 hcl:#341e13 +pid:370860309 ecl:oth +eyr:2028 hgt:157cm + +ecl:brn +byr:2001 +iyr:2010 +eyr:2028 hcl:#866857 hgt:183cm pid:194361427 + +hgt:182cm pid:449667574 ecl:amb +byr:1958 iyr:2017 +hcl:#efcc98 + +iyr:2020 ecl:hzl eyr:2030 hgt:185cm byr:1969 hcl:#ceb3a1 pid:157651787 + +pid:893956434 eyr:2027 hgt:185cm hcl:#a97842 +byr:1944 ecl:oth + +byr:2011 +iyr:2018 +hcl:#623a2f hgt:159cm ecl:blu pid:174cm +eyr:2030 + +ecl:grt pid:520129782 eyr:2020 +byr:2020 hcl:z cid:50 iyr:2017 +hgt:156cm + +iyr:2015 +ecl:grn hcl:#83b224 eyr:2021 pid:554994156 hgt:179cm byr:1994 + +ecl:gry byr:1971 pid:772131254 +eyr:2027 cid:201 hcl:#602927 + +cid:125 +byr:1943 hgt:168cm ecl:hzl pid:418786991 +eyr:2020 iyr:2016 +hcl:#cfa07d + +pid:825704567 eyr:2032 byr:2024 +iyr:1926 +hcl:d31139 hgt:190in + +cid:243 hcl:#cfa07d byr:1951 ecl:oth pid:382615614 +iyr:2018 eyr:2030 hgt:64in + +byr:1925 hgt:187cm ecl:oth eyr:2023 hcl:#888785 + +eyr:2028 iyr:2013 ecl:brn byr:1923 cid:174 hcl:#b6652a hgt:154cm pid:274036240 + +ecl:brn hgt:183cm iyr:2016 +byr:1922 +hcl:#efcc98 eyr:2030 + +hgt:188cm +byr:1979 +ecl:amb +eyr:2025 hcl:#b6652a cid:130 +pid:646985829 iyr:2019 + +hgt:76cm hcl:z cid:112 ecl:zzz +pid:953385473 eyr:2020 +byr:1943 + +ecl:#12c807 +byr:1954 eyr:1934 hgt:73cm hcl:#ceb3a1 iyr:2015 pid:704621520 + +hgt:188cm hcl:#733820 eyr:2024 ecl:grn +iyr:2018 byr:1982 pid:522812862 + +hgt:68cm ecl:blu +byr:2023 pid:875418461 iyr:2021 eyr:2020 hcl:#623a2f + +byr:1967 +pid:313706535 ecl:amb hcl:#888785 +iyr:2012 +eyr:2026 + +eyr:2026 +pid:288363970 cid:70 byr:1932 hgt:157cm iyr:2016 ecl:hzl hcl:#ceb3a1 + +byr:1992 pid:539896055 +eyr:2023 +cid:189 hgt:70in ecl:oth iyr:2019 +hcl:#866857 + +hgt:158in +ecl:gry byr:2028 +eyr:2036 cid:188 +hcl:#cfa07d +pid:044279141 + +eyr:2024 hgt:170cm ecl:hzl +byr:1939 pid:851235247 iyr:2013 +hcl:#fffffd + +ecl:hzl hcl:#c0946f +hgt:167cm +eyr:2024 byr:1936 pid:463230636 cid:297 +iyr:2016 + +pid:291401545 ecl:grn hcl:#b6652a iyr:2014 +hgt:185cm eyr:2025 byr:1947 + +eyr:2029 pid:612595763 +iyr:2018 ecl:gry +cid:290 +byr:1991 hcl:#733820 +hgt:150cm + +hgt:151cm +pid:667532675 cid:134 +byr:1930 +hcl:#efcc98 iyr:2012 +ecl:oth + +ecl:gry +hcl:#888785 hgt:161cm +eyr:2023 +pid:467759498 cid:274 + +eyr:2023 byr:1956 hgt:188cm iyr:2014 hcl:#b6652a pid:382721925 ecl:brn + +byr:1947 ecl:gry eyr:2020 +pid:874004905 hcl:#602927 hgt:161cm iyr:2029 + +pid:164334257 +iyr:2014 cid:286 eyr:2020 +hcl:#733820 +ecl:gry byr:1959 hgt:165cm + +hgt:59in +pid:#5b1362 +eyr:2028 iyr:1980 hcl:z byr:2030 +ecl:utc + +pid:604128460 iyr:2016 byr:1952 hgt:152cm ecl:grn hcl:#7d3b0c eyr:2021 + +pid:7483106309 eyr:2005 hgt:158in byr:2024 iyr:1935 hcl:z +ecl:#158994 + +hcl:22207f eyr:1994 +cid:166 pid:#d8e64c ecl:utc +byr:1966 hgt:70cm +iyr:1980 + +iyr:2012 pid:045892410 hgt:70in ecl:dne hcl:1a323a byr:1920 eyr:2022 + +hcl:#18171d iyr:2019 eyr:2026 +hgt:191cm pid:514596186 cid:327 byr:1938 ecl:grn + +pid:904148746 hcl:#a97842 hgt:161cm +cid:181 +iyr:2012 eyr:2020 ecl:oth + +iyr:2028 +eyr:2034 +cid:276 pid:#0e7ee2 byr:2020 +hgt:63cm ecl:gry +hcl:z + +pid:4270554593 eyr:2031 ecl:lzr hgt:72cm +iyr:2027 hcl:ffc210 cid:132 +byr:2008 + +iyr:2018 pid:174cm cid:144 +ecl:#10b2ed byr:1931 eyr:2040 hcl:z hgt:68in + +pid:446746712 +iyr:1957 +ecl:oth cid:213 hgt:184cm byr:2008 hcl:z + +hcl:#7d3b0c iyr:2012 ecl:hzl +eyr:2023 pid:270148060 + +pid:832184923 +eyr:2023 hgt:180cm +byr:1965 ecl:hzl cid:189 hcl:#a97842 +iyr:2016 + +pid:688867083 +iyr:2011 hcl:#733820 cid:147 eyr:2021 +byr:1986 ecl:oth + +hgt:166in ecl:amb byr:2014 +pid:169cm hcl:#cfa07d iyr:1976 + +hgt:64in byr:1987 hcl:01f3d7 +pid:553206412 eyr:2027 ecl:grn cid:336 +iyr:2012 + +cid:336 +ecl:oth byr:1975 +pid:296100726 hcl:#6b5442 iyr:2016 hgt:180cm eyr:2029 + +hcl:#ceb3a1 hgt:181cm pid:364719801 byr:1922 eyr:2029 +iyr:2010 cid:346 ecl:gry + +hcl:#1c7f1d cid:205 +hgt:184cm +byr:1928 +pid:694275035 iyr:2018 ecl:blu eyr:2023 + +eyr:1970 +hcl:z byr:2001 +pid:9244596 iyr:2030 hgt:187in ecl:blu + +hgt:96 +byr:2030 ecl:zzz eyr:1920 pid:115437655 hcl:z +iyr:2017 +cid:344 + +iyr:2018 +eyr:2023 +hcl:#888785 hgt:188cm +ecl:amb byr:1992 pid:602211075 + +pid:848099019 hgt:168cm iyr:2016 +eyr:2026 ecl:amb +hcl:#866857 byr:1981 + +iyr:2013 hcl:#623a2f hgt:151cm cid:135 byr:1974 eyr:2026 ecl:gry +pid:313553018 + +hcl:#733820 +byr:1986 hgt:182cm +ecl:brn eyr:2024 iyr:2017 +pid:676008782 + +eyr:2030 pid:833874339 iyr:2011 byr:1949 hgt:159cm +ecl:brn hcl:#602927 + +hgt:182cm hcl:#6b5442 pid:131549376 eyr:2029 iyr:2012 +ecl:gry byr:1926 + +cid:55 ecl:amb iyr:2015 hgt:192cm hcl:#a97842 +byr:1944 +eyr:2027 + +iyr:1944 eyr:2038 hcl:a2adf2 cid:99 byr:2006 hgt:67cm +pid:154cm +ecl:dne + +eyr:2005 hcl:#1495bd ecl:grt byr:2028 +iyr:2016 hgt:155 pid:182cm +cid:326 + +hgt:136 +pid:599182089 eyr:2020 byr:1945 +iyr:2012 +ecl:oth hcl:#18171d + +pid:4695182580 +iyr:2012 +ecl:brn eyr:2039 byr:1936 +hcl:#cfa07d + +ecl:hzl byr:1949 cid:133 hgt:159cm hcl:#b6652a pid:9833212692 iyr:2011 eyr:2030 + +eyr:2020 +hgt:175cm +cid:140 iyr:2014 byr:1980 hcl:#7d3b0c +ecl:grn pid:400508366 + +pid:#100a75 iyr:2016 +hgt:65 +eyr:2037 ecl:hzl +byr:1962 + +eyr:2024 pid:180cm hcl:#6b5442 hgt:154cm +iyr:1964 + +byr:1986 hgt:159cm ecl:brn +pid:856817592 hcl:#cfa07d eyr:2024 +iyr:2017 + +hgt:166cm +byr:1996 hcl:#410645 +ecl:hzl iyr:2010 cid:178 pid:337713295 +eyr:2026 + +iyr:2017 byr:1964 hgt:167cm hcl:#7d3b0c cid:298 ecl:brn pid:371416367 + +byr:1929 iyr:2011 hcl:#fffffd ecl:blu +pid:013408674 hgt:187cm eyr:2021 + +hcl:#cfa07d byr:1986 cid:331 +iyr:2010 ecl:gry pid:616063053 hgt:150cm +eyr:2028 + +pid:013835033 iyr:2017 byr:1991 +hgt:154cm hcl:#efcc98 eyr:2020 + +byr:1978 eyr:2024 +hgt:155cm iyr:2012 hcl:#694989 pid:914726069 +ecl:amb + +ecl:blu pid:139464317 hcl:#fffffd eyr:2024 byr:1970 hgt:72in iyr:2012 + +byr:1965 hcl:#ceb3a1 ecl:hzl iyr:2019 pid:910593212 eyr:2029 + +byr:1994 cid:228 +ecl:grn hgt:171cm pid:538884417 eyr:2025 iyr:2011 hcl:#6b5442 + +cid:264 hcl:#623a2f +hgt:186cm iyr:2012 ecl:brn eyr:2024 pid:304101929 byr:1954 + +hgt:183cm byr:1987 hcl:z ecl:gry eyr:2020 pid:384983241 iyr:2015 + +pid:#885c1a +byr:2012 eyr:2034 ecl:#8ea705 iyr:2028 hgt:61cm hcl:z + +eyr:2023 hgt:156cm byr:1939 hcl:#cd2220 ecl:brn pid:484163297 + +hgt:158in +byr:2000 ecl:lzr +iyr:2014 +eyr:2033 pid:50157400 + +byr:1974 hcl:#c0946f +iyr:2018 pid:285451524 cid:299 eyr:2029 hgt:184cm ecl:hzl + +byr:1974 hcl:#602927 hgt:151cm iyr:2013 pid:322935162 ecl:amb +cid:209 +eyr:2026 + +hcl:#341e13 iyr:2015 +ecl:gry byr:1970 +hgt:186cm +pid:330151070 eyr:2034 + +ecl:gry eyr:2023 +hgt:160cm hcl:#c0946f +iyr:2011 byr:1926 pid:727347794 + +iyr:2012 +byr:1974 hcl:#866857 +eyr:2025 +pid:933155590 hgt:167cm +ecl:grn + +iyr:2015 ecl:gry eyr:2029 +byr:1967 hcl:#f9f576 hgt:170cm pid:439696954 cid:173 + +eyr:2029 byr:1935 ecl:brn pid:165587982 +hcl:#6b5442 +iyr:2020 + +eyr:2029 ecl:hzl hcl:#866857 byr:1994 +pid:308548232 hgt:162cm iyr:2012 + +byr:1924 cid:274 +pid:028266367 eyr:2025 iyr:2017 hgt:169cm +hcl:#cfa07d ecl:gry + +eyr:2025 byr:1995 +ecl:brn +hgt:160cm +pid:819047484 +hcl:#602927 iyr:2011 + +pid:660383456 +iyr:2016 eyr:2022 hgt:158cm byr:1942 ecl:amb cid:334 hcl:#efcc98 + +hcl:#6b5442 iyr:2024 cid:180 ecl:grn pid:167cm hgt:169 + +eyr:2024 iyr:2017 hgt:165cm hcl:#7d3b0c byr:1920 +ecl:amb pid:236377188 + +pid:063113952 +ecl:grn hcl:#341e13 hgt:166cm +byr:1977 iyr:2017 + +ecl:amb hgt:174cm +eyr:2028 byr:2002 +hcl:#7d3b0c +pid:428826816 iyr:2017 + +byr:2025 ecl:dne hgt:167in pid:706379338 +iyr:2019 hcl:240e75 eyr:1971 + +eyr:2021 +hcl:#efcc98 iyr:2014 +pid:358236477 +byr:1923 cid:73 hgt:165cm ecl:amb + +eyr:2030 cid:267 +ecl:brn +pid:282023612 hcl:#c0946f iyr:2018 byr:1989 +hgt:72cm + +ecl:utc hcl:ea4b34 byr:2013 +pid:#d58d54 +hgt:107 iyr:2027 cid:296 eyr:2038 + +byr:1946 eyr:2024 iyr:2012 +hcl:#341e13 +pid:765835791 hgt:159cm + +hcl:#341e13 byr:1927 +ecl:grn iyr:2011 +hgt:175cm eyr:2023 pid:638808763 cid:339 + +eyr:2030 cid:160 byr:1994 hgt:163cm ecl:hzl iyr:2016 hcl:#623a2f pid:569304871 + +byr:1965 +eyr:2020 hgt:157cm hcl:#a97842 +cid:271 iyr:2014 pid:326802068 ecl:#a16571 + +byr:1965 +ecl:hzl eyr:2029 iyr:2010 hgt:157cm +hcl:#7d3b0c pid:617693914 + +pid:547158528 byr:1956 +ecl:gry hgt:189cm +eyr:2029 +hcl:#602927 +iyr:2011 + +hcl:#efcc98 +ecl:#1ecd0e pid:160cm eyr:2027 hgt:183cm byr:2027 iyr:1963 + +hcl:#fffffd eyr:2021 iyr:2014 byr:1959 ecl:amb +pid:102521439 hgt:190cm + +cid:112 hcl:#fffffd byr:2025 +pid:016603375 +eyr:1942 hgt:145 +iyr:1994 + +ecl:xry +pid:#5be367 +hgt:171cm cid:144 iyr:1946 eyr:2034 hcl:z byr:2022 + +ecl:oth +iyr:2014 hcl:#7d3b0c +cid:316 +byr:1936 pid:088295340 +eyr:2029 + +iyr:2019 +hgt:183cm ecl:brn hcl:#efcc98 pid:821190245 cid:251 eyr:2023 +byr:1993 + +ecl:oth iyr:2018 +cid:131 +hcl:#524e2e byr:1981 hgt:183cm eyr:2022 pid:037981572 + +hcl:#18171d byr:1934 eyr:2020 hgt:62in +cid:64 +ecl:oth pid:343039563 iyr:2010 + +hcl:#733820 pid:374199356 +hgt:169cm eyr:2026 byr:1994 iyr:2015 ecl:brn + +pid:394267581 +hcl:#a97842 iyr:2010 byr:1988 +hgt:185cm ecl:amb +eyr:2022 + +ecl:#be3b70 iyr:2025 +hcl:z +eyr:2010 +byr:2023 +hgt:65 cid:220 pid:#d6af49 + +eyr:2029 +hcl:#a97842 ecl:amb hgt:159cm +cid:228 byr:1946 iyr:2012 +pid:805319194 + +hcl:#c0946f eyr:2020 hgt:171cm ecl:oth iyr:2010 byr:1958 pid:276122958 + +iyr:2017 +hcl:#da47a1 byr:2007 ecl:utc +eyr:1945 cid:327 hgt:192cm pid:549704477 + +iyr:1923 hgt:174in hcl:z byr:1974 +eyr:2026 +ecl:xry pid:158cm + +iyr:2022 +ecl:#ae10f9 +hgt:108 +eyr:2035 hcl:z byr:2019 pid:#1f4f7c + +eyr:2021 pid:959352732 cid:306 hgt:178cm ecl:amb +iyr:2012 +byr:1953 + +byr:2016 ecl:lzr eyr:2021 hcl:z iyr:1977 hgt:181cm cid:164 + +cid:242 byr:2008 hcl:#866857 hgt:172cm iyr:2011 +ecl:blu eyr:2026 pid:350658669 + +hgt:67in eyr:2030 +ecl:gry pid:156329184 iyr:2010 byr:1936 hcl:#efcc98 + +cid:110 hgt:76in iyr:2018 +eyr:2029 pid:474249956 byr:2002 hcl:#866857 +ecl:oth + +iyr:2016 hgt:193cm eyr:2029 +byr:1934 hcl:#b6652a pid:901756621 +ecl:brn + +eyr:2017 hcl:z pid:#2f9848 iyr:2024 +hgt:170cm + +hgt:60in eyr:2026 byr:1922 hcl:#18171d iyr:2016 +pid:921038878 diff --git a/day-4/src/main.rs b/day-4/src/main.rs new file mode 100644 index 0000000..f1f268e --- /dev/null +++ b/day-4/src/main.rs @@ -0,0 +1,80 @@ +use std::collections::HashMap; +use std::fs; + +fn main() -> Result<(), Box<dyn std::error::Error>> { + let input = fs::read_to_string("input")?; + let passports = parse_passports(&input)?; + println!("{}", validate_passports(&passports)); + + Ok(()) +} + +fn parse_passports(input: &str) -> Result<Vec<HashMap<&str, &str>>, &str> { + input + .split("\n\n") + .map(|passport| { + passport + .trim() + .split(|c| c == ' ' || c == '\n') + .map(|field| { + let split = field + .find(':') + .ok_or("Invalid passport entry; no separator")?; + let item = field.split_at(split); + + let key = item.0; + let value = item + .1 + .strip_prefix(":") + .expect("We've already checked the separator exists"); + + Ok((key, value)) + }) + .collect() + }) + .collect() +} + +fn validate_passports(passports: &Vec<HashMap<&str, &str>>) -> usize { + let required_fields = ["byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"]; + + passports + .iter() + .filter(|passport| { + required_fields + .iter() + .all(|field| passport.contains_key(field)) + }) + .count() +} + +#[cfg(test)] +mod tests { + use super::*; + use indoc::indoc; + + #[test] + fn test_simple() -> Result<(), String> { + let example = indoc!( + "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 + " + ); + + let passports = parse_passports(example)?; + assert_eq!(validate_passports(&passports), 2); + + Ok(()) + } +} From 1eed1d2f85303f07440ff59c09f2e5cbbcf70d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= <tm@tlater.net> Date: Fri, 4 Dec 2020 21:34:49 +0000 Subject: [PATCH 2/8] Complete day 4.2 --- day-4/src/main.rs | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/day-4/src/main.rs b/day-4/src/main.rs index f1f268e..1e5dfd9 100644 --- a/day-4/src/main.rs +++ b/day-4/src/main.rs @@ -37,13 +37,55 @@ fn parse_passports(input: &str) -> Result<Vec<HashMap<&str, &str>>, &str> { fn validate_passports(passports: &Vec<HashMap<&str, &str>>) -> usize { let required_fields = ["byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"]; + let rules = [ + |year: &str| match year.parse() { + Ok(1920..=2002) => true, + _ => false, + }, + |year: &str| match year.parse() { + Ok(2010..=2020) => true, + _ => false, + }, + |year: &str| match year.parse() { + Ok(2020..=2030) => true, + _ => false, + }, + |height: &str| match height.split_at(height.chars().count() - 2) { + (height, "cm") => match height.parse() { + Ok(150..=193) => true, + _ => false, + }, + (height, "in") => match height.parse() { + Ok(59..=76) => true, + _ => false, + }, + _ => false, + }, + |color: &str| match color.split_at(1) { + ("#", code) => code.chars().all(|a| char::is_ascii_hexdigit(&a)), + _ => false, + }, + |color: &str| { + ["amb", "blu", "brn", "gry", "grn", "hzl", "oth"] + .iter() + .any(|c| c == &color) + }, + |pid: &str| pid.chars().count() == 9 && pid.chars().all(char::is_numeric), + ]; passports .iter() .filter(|passport| { required_fields .iter() - .all(|field| passport.contains_key(field)) + .zip(rules.iter()) + .all(|(field, rule)| { + if let Some(value) = passport.get(field) { + rule(value) + } else { + false + } + }) }) .count() } From c6ca4d6c7dcfb81b7b7372cb5cac399475081aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= <tm@tlater.net> Date: Mon, 7 Dec 2020 23:54:12 +0000 Subject: [PATCH 3/8] Complete day 7 --- day-7/.gitignore | 1 + day-7/Cargo.lock | 128 ++++++++++ day-7/Cargo.toml | 12 + day-7/input | 594 ++++++++++++++++++++++++++++++++++++++++++++++ day-7/src/main.rs | 182 ++++++++++++++ 5 files changed, 917 insertions(+) create mode 100644 day-7/.gitignore create mode 100644 day-7/Cargo.lock create mode 100644 day-7/Cargo.toml create mode 100644 day-7/input create mode 100644 day-7/src/main.rs diff --git a/day-7/.gitignore b/day-7/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/day-7/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/day-7/Cargo.lock b/day-7/Cargo.lock new file mode 100644 index 0000000..14366e2 --- /dev/null +++ b/day-7/Cargo.lock @@ -0,0 +1,128 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "aho-corasick" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" +dependencies = [ + "memchr", +] + +[[package]] +name = "day-7" +version = "0.1.0" +dependencies = [ + "indoc", + "lazy_static", + "regex", +] + +[[package]] +name = "indoc" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47741a8bc60fb26eb8d6e0238bbb26d8575ff623fdc97b1a2c00c050b9684ed8" +dependencies = [ + "indoc-impl", + "proc-macro-hack", +] + +[[package]] +name = "indoc-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce046d161f000fffde5f432a0d034d0341dc152643b2598ed5bfce44c4f3a8f0" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", + "unindent", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "memchr" +version = "2.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", + "thread_local", +] + +[[package]] +name = "regex-syntax" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" + +[[package]] +name = "syn" +version = "1.0.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "thread_local" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "unindent" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f14ee04d9415b52b3aeab06258a3f07093182b88ba0f9b8d203f211a7a7d41c7" diff --git a/day-7/Cargo.toml b/day-7/Cargo.toml new file mode 100644 index 0000000..a9ba4c2 --- /dev/null +++ b/day-7/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "day-7" +version = "0.1.0" +authors = ["Tristan Daniël Maat <tm@tlater.net>"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +indoc = "0.3" +lazy_static = "1.4" +regex = "1.4" diff --git a/day-7/input b/day-7/input new file mode 100644 index 0000000..d63893c --- /dev/null +++ b/day-7/input @@ -0,0 +1,594 @@ +dull silver bags contain 2 striped magenta bags, 2 dark coral bags, 1 bright orange bag, 4 plaid blue bags. +dark plum bags contain 3 wavy teal bags. +wavy turquoise bags contain 3 bright salmon bags. +mirrored gold bags contain 3 wavy brown bags, 5 posh beige bags, 3 light crimson bags, 3 vibrant salmon bags. +drab green bags contain 4 dull white bags, 1 posh indigo bag. +faded lime bags contain 1 dim magenta bag, 1 wavy salmon bag, 4 dull purple bags. +mirrored blue bags contain 5 bright orange bags, 1 muted black bag, 2 muted brown bags, 2 vibrant gold bags. +faded crimson bags contain 4 wavy teal bags, 4 mirrored fuchsia bags, 3 plaid white bags. +faded magenta bags contain 2 clear orange bags, 5 dull green bags, 2 pale white bags. +pale red bags contain 5 shiny gold bags, 4 dull gold bags, 2 drab black bags. +dark coral bags contain 1 light turquoise bag. +faded chartreuse bags contain 4 shiny brown bags, 4 mirrored beige bags, 4 clear purple bags. +muted coral bags contain 4 pale coral bags, 4 plaid brown bags. +bright teal bags contain 5 striped blue bags, 4 faded orange bags, 2 faded crimson bags. +wavy green bags contain 5 dim chartreuse bags. +clear white bags contain 2 mirrored fuchsia bags. +clear aqua bags contain 1 faded beige bag. +vibrant yellow bags contain 5 posh brown bags. +pale lavender bags contain 1 striped beige bag, 2 striped cyan bags. +mirrored lime bags contain 3 bright orange bags. +faded tan bags contain 2 drab beige bags. +dark indigo bags contain 1 dark brown bag, 5 shiny beige bags, 1 vibrant indigo bag. +drab teal bags contain 2 vibrant fuchsia bags, 3 muted green bags, 5 dotted magenta bags, 2 shiny lavender bags. +shiny aqua bags contain 1 shiny gold bag, 4 clear white bags, 4 faded gold bags. +dull bronze bags contain 4 vibrant teal bags, 1 vibrant violet bag. +dark aqua bags contain 4 posh white bags. +dim coral bags contain 2 light yellow bags. +faded salmon bags contain 5 muted brown bags, 2 dotted red bags, 3 drab yellow bags, 4 dark red bags. +bright lavender bags contain 5 wavy maroon bags, 5 light brown bags, 5 bright silver bags, 1 dark gray bag. +mirrored cyan bags contain 4 dotted cyan bags, 5 striped orange bags, 1 vibrant gold bag. +drab aqua bags contain 3 striped black bags, 4 dark salmon bags, 1 drab white bag, 4 faded crimson bags. +striped purple bags contain 5 faded yellow bags, 2 faded brown bags. +drab fuchsia bags contain 4 vibrant violet bags, 5 mirrored yellow bags. +shiny red bags contain 3 faded cyan bags, 1 dull beige bag, 1 shiny blue bag, 5 dull cyan bags. +mirrored teal bags contain 4 clear brown bags, 5 light bronze bags, 3 light teal bags, 2 pale tomato bags. +dotted orange bags contain 3 dull white bags, 2 wavy blue bags. +dotted lavender bags contain 1 vibrant aqua bag, 4 shiny magenta bags, 3 dull plum bags. +pale crimson bags contain 4 muted cyan bags, 1 posh brown bag, 3 light magenta bags. +shiny black bags contain 4 vibrant chartreuse bags, 1 mirrored yellow bag, 3 posh brown bags, 5 vibrant violet bags. +clear bronze bags contain 5 dull violet bags, 3 pale plum bags. +striped lavender bags contain 1 dark plum bag, 2 striped yellow bags. +plaid indigo bags contain 2 plaid chartreuse bags. +shiny teal bags contain 4 wavy gray bags, 4 drab teal bags, 1 dark silver bag. +dull turquoise bags contain 1 wavy gray bag. +striped brown bags contain 1 striped olive bag, 1 wavy olive bag, 5 posh brown bags. +dotted magenta bags contain 4 drab silver bags, 3 light olive bags, 1 bright tan bag, 4 dull gold bags. +plaid yellow bags contain 5 drab black bags, 1 wavy lavender bag, 1 drab silver bag. +muted blue bags contain 5 posh aqua bags. +shiny olive bags contain 4 dark salmon bags, 1 faded gold bag, 3 drab chartreuse bags, 4 dotted yellow bags. +vibrant lime bags contain 4 shiny aqua bags, 1 bright maroon bag, 4 striped orange bags. +dim crimson bags contain 5 faded crimson bags. +vibrant gray bags contain 1 mirrored coral bag, 5 wavy beige bags, 3 drab turquoise bags. +posh chartreuse bags contain 3 light plum bags, 2 pale green bags, 5 drab white bags. +striped beige bags contain 5 dull red bags, 5 drab salmon bags, 3 vibrant salmon bags. +dotted tan bags contain 4 wavy crimson bags, 4 shiny orange bags, 1 drab turquoise bag. +vibrant aqua bags contain 1 vibrant gray bag, 5 light violet bags, 3 dim yellow bags. +faded turquoise bags contain 2 faded yellow bags, 4 mirrored coral bags. +mirrored purple bags contain 3 pale orange bags. +dim white bags contain 1 drab turquoise bag. +bright purple bags contain 5 muted chartreuse bags, 1 dotted yellow bag, 3 bright salmon bags. +drab red bags contain 1 mirrored magenta bag. +clear coral bags contain 4 drab black bags, 3 dark black bags. +mirrored orange bags contain 1 muted chartreuse bag. +wavy cyan bags contain 3 posh lime bags, 4 dark magenta bags, 4 vibrant turquoise bags. +pale magenta bags contain 4 vibrant turquoise bags, 3 clear gold bags. +posh gold bags contain 5 dotted lime bags, 5 wavy silver bags, 4 muted crimson bags, 1 dull yellow bag. +clear silver bags contain 1 drab indigo bag. +faded violet bags contain 2 mirrored bronze bags. +muted turquoise bags contain 2 plaid green bags, 2 light yellow bags, 4 dark violet bags. +striped bronze bags contain 4 striped white bags, 1 dim yellow bag, 5 clear aqua bags. +muted aqua bags contain 5 plaid green bags. +wavy teal bags contain no other bags. +pale black bags contain 5 dark salmon bags. +clear gold bags contain 2 plaid white bags, 5 drab coral bags, 5 pale coral bags. +muted chartreuse bags contain 5 faded crimson bags. +dotted fuchsia bags contain 1 plaid brown bag, 1 dark violet bag. +bright tomato bags contain 1 bright blue bag. +dim bronze bags contain 1 dotted green bag, 5 pale violet bags, 4 vibrant chartreuse bags, 3 striped yellow bags. +bright beige bags contain 1 drab blue bag. +vibrant olive bags contain 3 dotted olive bags. +clear tomato bags contain 1 light gray bag, 2 light turquoise bags, 2 striped yellow bags. +mirrored beige bags contain 3 light coral bags, 2 bright teal bags, 1 wavy magenta bag. +shiny gold bags contain 3 pale silver bags, 3 mirrored yellow bags, 2 shiny black bags, 2 light magenta bags. +plaid aqua bags contain 4 plaid crimson bags, 4 dim gray bags, 3 plaid orange bags, 2 dotted blue bags. +light green bags contain 2 light violet bags, 5 striped violet bags, 5 drab brown bags, 4 dull white bags. +vibrant beige bags contain 3 posh violet bags, 2 plaid blue bags, 4 shiny lavender bags, 5 wavy orange bags. +drab orange bags contain 3 striped beige bags, 3 posh teal bags, 5 drab silver bags, 1 dark indigo bag. +shiny orange bags contain 3 dark aqua bags, 4 clear beige bags, 2 mirrored lime bags, 3 dark violet bags. +wavy maroon bags contain 3 vibrant chartreuse bags. +wavy olive bags contain 5 dark aqua bags, 1 light yellow bag, 1 shiny crimson bag. +dotted cyan bags contain 2 drab gold bags. +muted cyan bags contain 1 clear gold bag, 4 dark plum bags, 2 wavy lavender bags, 5 vibrant indigo bags. +posh cyan bags contain 1 light fuchsia bag, 1 dark maroon bag. +faded bronze bags contain 2 muted salmon bags, 4 dim violet bags, 5 dark tan bags, 3 vibrant white bags. +pale green bags contain 4 muted turquoise bags, 1 vibrant green bag, 1 drab white bag. +clear brown bags contain 4 wavy teal bags, 4 drab violet bags. +striped salmon bags contain 5 mirrored orange bags, 1 shiny yellow bag, 1 muted beige bag, 1 clear purple bag. +posh brown bags contain 3 posh white bags, 4 drab chartreuse bags, 5 dark violet bags, 4 wavy teal bags. +mirrored green bags contain 1 dim tan bag. +bright yellow bags contain 2 striped indigo bags, 2 dark silver bags. +wavy yellow bags contain 3 dotted gold bags, 3 posh green bags. +light chartreuse bags contain 3 faded blue bags, 3 mirrored yellow bags, 3 shiny plum bags, 4 light red bags. +dark lime bags contain 5 vibrant chartreuse bags, 2 clear brown bags, 1 posh brown bag. +muted magenta bags contain 4 shiny silver bags, 2 dotted yellow bags, 4 pale fuchsia bags, 5 muted tan bags. +light plum bags contain 4 drab gold bags. +dim tomato bags contain 1 light silver bag. +pale lime bags contain 4 dull blue bags. +dim black bags contain 1 dark plum bag, 1 dull crimson bag, 5 wavy white bags, 2 plaid chartreuse bags. +muted teal bags contain 3 dim black bags, 4 mirrored lavender bags, 5 dull indigo bags, 3 clear red bags. +muted purple bags contain 1 mirrored red bag. +dull coral bags contain 5 pale teal bags, 2 faded cyan bags, 4 pale black bags, 2 muted olive bags. +vibrant red bags contain 4 light teal bags, 5 shiny fuchsia bags, 1 drab purple bag, 2 muted olive bags. +mirrored tomato bags contain 4 posh brown bags. +shiny coral bags contain 5 clear turquoise bags, 2 wavy salmon bags, 1 drab brown bag. +wavy indigo bags contain 1 vibrant brown bag, 2 dim turquoise bags, 1 posh violet bag, 1 plaid green bag. +dotted gold bags contain 5 pale aqua bags, 1 bright olive bag. +dotted violet bags contain 2 drab olive bags, 1 plaid cyan bag, 2 posh beige bags. +pale fuchsia bags contain 5 faded beige bags, 5 dark purple bags. +shiny chartreuse bags contain 1 striped tan bag, 5 pale tomato bags. +clear gray bags contain 1 bright fuchsia bag, 4 dotted olive bags, 2 light teal bags, 4 shiny magenta bags. +vibrant tomato bags contain 1 clear crimson bag, 3 pale purple bags, 3 faded gray bags. +light orange bags contain 5 plaid brown bags. +shiny tomato bags contain 3 light olive bags, 5 dim silver bags, 3 posh violet bags, 2 striped lavender bags. +faded green bags contain 2 dotted gold bags, 1 dark plum bag, 1 dull gray bag, 5 dark brown bags. +dim gray bags contain 5 muted white bags, 2 mirrored yellow bags, 1 muted tomato bag. +faded black bags contain 3 faded teal bags, 3 striped lavender bags, 2 striped blue bags, 4 muted lavender bags. +clear lime bags contain 3 mirrored yellow bags, 1 light yellow bag. +dark silver bags contain 4 wavy orange bags, 2 muted green bags. +plaid black bags contain 3 wavy indigo bags, 1 pale red bag. +mirrored black bags contain 5 dull black bags, 4 clear coral bags, 1 wavy olive bag, 4 dull silver bags. +light coral bags contain 5 drab black bags, 1 dark magenta bag, 1 drab teal bag, 1 mirrored crimson bag. +shiny yellow bags contain 5 faded indigo bags. +posh plum bags contain 3 faded maroon bags, 2 vibrant indigo bags, 1 bright turquoise bag. +faded olive bags contain 1 vibrant gray bag, 4 drab teal bags, 5 wavy teal bags. +dim plum bags contain 1 plaid white bag, 4 wavy beige bags, 3 wavy green bags. +muted tomato bags contain 5 dotted red bags, 1 drab purple bag, 1 light orange bag. +clear fuchsia bags contain 1 mirrored olive bag, 2 faded salmon bags. +striped violet bags contain 2 light olive bags, 1 plaid olive bag, 5 light white bags. +dim aqua bags contain 2 vibrant purple bags, 5 drab silver bags. +striped crimson bags contain 5 muted coral bags. +bright indigo bags contain 3 muted gold bags. +dotted black bags contain 4 shiny crimson bags, 5 dark salmon bags, 5 faded crimson bags, 2 vibrant magenta bags. +faded indigo bags contain 1 drab tomato bag. +bright bronze bags contain 1 wavy lime bag, 4 pale violet bags. +drab turquoise bags contain 2 drab gold bags, 2 vibrant gold bags, 4 pale tomato bags. +wavy black bags contain 2 dotted brown bags, 1 light salmon bag. +posh green bags contain 1 striped olive bag, 5 vibrant turquoise bags, 4 pale coral bags. +clear green bags contain 4 dull bronze bags, 4 shiny crimson bags, 1 light white bag. +dull chartreuse bags contain 2 dim aqua bags, 3 shiny black bags. +drab lime bags contain 1 wavy chartreuse bag, 4 mirrored chartreuse bags, 1 posh olive bag, 5 mirrored lavender bags. +bright tan bags contain 4 muted tan bags, 5 shiny gold bags, 1 mirrored red bag, 3 dull crimson bags. +dim maroon bags contain 3 clear red bags, 5 dark brown bags, 2 bright maroon bags, 1 muted teal bag. +drab tomato bags contain 4 dim orange bags, 2 mirrored violet bags, 3 faded purple bags. +muted gold bags contain 1 dim cyan bag. +striped white bags contain 1 plaid white bag, 1 posh purple bag, 3 muted cyan bags, 2 pale crimson bags. +wavy beige bags contain 2 plaid white bags, 3 dark brown bags. +vibrant turquoise bags contain 2 muted turquoise bags, 3 plaid green bags, 1 shiny crimson bag. +dark fuchsia bags contain 1 pale purple bag, 1 dim fuchsia bag, 3 light teal bags, 3 vibrant magenta bags. +dotted aqua bags contain 1 bright white bag, 5 clear gold bags, 5 clear tomato bags. +faded silver bags contain 1 light lime bag, 4 wavy gold bags. +faded brown bags contain 4 light aqua bags. +bright gray bags contain 3 faded red bags, 2 muted plum bags, 1 wavy brown bag. +wavy tan bags contain 1 pale maroon bag, 5 posh black bags. +bright blue bags contain 5 posh purple bags. +striped gold bags contain 4 dull tan bags, 1 shiny crimson bag, 2 clear blue bags. +bright magenta bags contain 4 shiny orange bags. +dotted brown bags contain 4 faded teal bags, 5 mirrored coral bags. +muted silver bags contain 5 striped black bags, 3 faded beige bags, 4 plaid crimson bags, 2 wavy brown bags. +wavy purple bags contain 1 dim brown bag, 1 bright yellow bag, 5 shiny lime bags. +dull plum bags contain 1 posh black bag, 4 vibrant fuchsia bags, 5 dull bronze bags. +dotted red bags contain 5 striped tomato bags, 4 shiny orange bags, 4 clear magenta bags, 5 pale coral bags. +light violet bags contain 2 bright beige bags, 5 mirrored plum bags, 3 wavy fuchsia bags, 1 clear tan bag. +dark teal bags contain 3 dull gray bags, 2 dark aqua bags, 1 clear beige bag. +light fuchsia bags contain 2 muted silver bags, 2 striped beige bags. +posh blue bags contain 5 striped olive bags, 5 dim coral bags. +light black bags contain 2 drab coral bags, 2 shiny indigo bags. +pale chartreuse bags contain 5 pale tomato bags. +drab gold bags contain 1 faded gold bag, 5 shiny gold bags. +posh bronze bags contain 2 drab aqua bags, 5 pale gray bags. +light tomato bags contain 5 wavy lime bags. +dull tan bags contain 3 drab blue bags, 4 dull green bags, 4 clear violet bags. +muted beige bags contain 5 clear white bags, 5 faded crimson bags. +faded fuchsia bags contain 5 plaid purple bags, 1 shiny silver bag, 4 muted violet bags. +bright green bags contain 5 dim teal bags, 5 shiny crimson bags, 5 clear crimson bags. +mirrored fuchsia bags contain 4 posh white bags, 5 wavy teal bags, 2 dark violet bags. +vibrant plum bags contain 2 posh yellow bags. +plaid bronze bags contain 4 dotted coral bags, 4 dull green bags, 2 plaid chartreuse bags. +plaid fuchsia bags contain 5 bright white bags. +dull red bags contain 2 mirrored fuchsia bags, 3 vibrant violet bags, 2 bright olive bags, 1 dim orange bag. +faded gray bags contain 1 dull purple bag, 2 posh salmon bags. +wavy plum bags contain 4 pale violet bags, 3 striped magenta bags, 4 pale red bags. +dark crimson bags contain 4 dim yellow bags, 1 dotted purple bag, 2 wavy indigo bags, 4 clear black bags. +pale cyan bags contain 5 shiny coral bags, 4 shiny beige bags, 2 plaid olive bags. +dull violet bags contain 3 wavy olive bags, 1 dull gray bag, 5 vibrant turquoise bags, 1 plaid purple bag. +wavy chartreuse bags contain 1 dotted magenta bag, 3 bright orange bags, 1 mirrored red bag. +dark cyan bags contain 5 dotted turquoise bags, 1 clear purple bag, 1 dim teal bag. +posh coral bags contain 3 muted bronze bags. +pale yellow bags contain 1 drab tomato bag. +plaid turquoise bags contain 1 muted gray bag. +dotted purple bags contain 5 posh silver bags, 4 dark salmon bags. +light indigo bags contain 4 mirrored red bags, 4 light olive bags. +faded plum bags contain 3 mirrored gold bags. +faded coral bags contain 5 dull tan bags. +clear indigo bags contain 5 mirrored magenta bags, 1 clear maroon bag, 1 bright blue bag, 5 light aqua bags. +dim cyan bags contain 5 plaid green bags. +dotted maroon bags contain 5 pale maroon bags, 2 dark indigo bags. +faded beige bags contain 1 plaid chartreuse bag. +striped indigo bags contain 1 dark gray bag, 3 drab olive bags. +clear yellow bags contain 4 dull gray bags, 1 muted green bag. +light lavender bags contain 4 pale coral bags, 2 light yellow bags, 2 light indigo bags. +light turquoise bags contain 5 pale fuchsia bags, 5 vibrant fuchsia bags, 5 vibrant magenta bags, 3 pale indigo bags. +light purple bags contain 2 light cyan bags. +bright gold bags contain 1 dark aqua bag. +muted bronze bags contain 2 light teal bags. +striped gray bags contain 2 light cyan bags, 1 pale black bag, 5 plaid plum bags. +wavy orange bags contain 2 pale coral bags, 2 dim coral bags. +wavy silver bags contain 2 posh white bags, 1 faded beige bag. +clear chartreuse bags contain 1 vibrant lime bag, 2 faded plum bags, 1 striped chartreuse bag, 5 clear maroon bags. +vibrant tan bags contain 3 striped lime bags, 4 pale maroon bags, 2 muted turquoise bags, 4 dark lime bags. +posh aqua bags contain 2 muted tan bags, 2 shiny blue bags, 2 posh purple bags. +bright orange bags contain no other bags. +drab coral bags contain no other bags. +light white bags contain 5 striped yellow bags. +wavy violet bags contain 1 pale silver bag, 2 shiny fuchsia bags, 1 vibrant violet bag, 1 shiny plum bag. +dark white bags contain 4 shiny maroon bags, 2 dim brown bags, 2 dark beige bags, 1 pale blue bag. +vibrant violet bags contain 4 striped blue bags, 1 mirrored lime bag, 1 posh white bag. +vibrant lavender bags contain 4 dotted magenta bags, 1 wavy red bag, 3 pale coral bags, 3 clear indigo bags. +dark purple bags contain 4 posh white bags. +mirrored lavender bags contain 5 clear brown bags, 2 faded gold bags. +striped silver bags contain 3 light yellow bags, 1 drab violet bag. +faded blue bags contain 3 muted violet bags, 4 wavy plum bags, 2 pale indigo bags, 1 wavy bronze bag. +drab cyan bags contain 4 dim tomato bags, 1 plaid lavender bag, 4 pale red bags, 2 drab olive bags. +clear lavender bags contain 3 wavy olive bags, 5 bright gray bags, 3 wavy beige bags, 2 dim violet bags. +striped aqua bags contain 3 mirrored lavender bags. +plaid tomato bags contain 2 posh cyan bags, 3 pale silver bags. +plaid salmon bags contain 1 muted lavender bag, 5 muted green bags, 3 bright aqua bags. +light blue bags contain 1 light white bag, 4 clear violet bags, 3 dark brown bags. +dark blue bags contain 5 posh aqua bags. +faded teal bags contain 3 light beige bags. +plaid chartreuse bags contain 4 wavy teal bags. +wavy gray bags contain 3 drab white bags, 2 muted lavender bags. +pale maroon bags contain 4 faded crimson bags, 4 vibrant chartreuse bags, 1 plaid green bag, 1 vibrant turquoise bag. +dark bronze bags contain 4 faded turquoise bags, 2 faded silver bags, 5 faded salmon bags. +pale coral bags contain 3 mirrored yellow bags, 4 dark plum bags, 2 dark aqua bags, 4 plaid white bags. +mirrored magenta bags contain 5 vibrant lime bags, 4 vibrant chartreuse bags, 3 striped aqua bags. +mirrored salmon bags contain 4 striped salmon bags, 1 posh tan bag, 3 faded bronze bags. +drab tan bags contain 5 vibrant violet bags. +vibrant indigo bags contain 1 pale coral bag, 1 light teal bag, 2 light magenta bags. +plaid lavender bags contain 1 striped silver bag, 1 clear lime bag. +muted plum bags contain 2 plaid crimson bags. +posh gray bags contain 5 mirrored lime bags. +clear maroon bags contain 5 wavy bronze bags, 3 dim gold bags, 2 muted beige bags, 5 posh coral bags. +striped maroon bags contain 2 dotted violet bags, 4 bright fuchsia bags, 4 striped aqua bags. +faded yellow bags contain 2 wavy teal bags, 3 wavy lavender bags. +posh black bags contain 1 drab silver bag, 2 clear white bags, 5 muted silver bags. +muted indigo bags contain 1 dark green bag, 1 plaid chartreuse bag, 3 bright indigo bags, 5 wavy silver bags. +wavy brown bags contain 5 faded red bags, 4 bright orange bags, 3 dim black bags. +vibrant coral bags contain 5 plaid white bags, 5 vibrant indigo bags. +wavy white bags contain 1 plaid green bag, 3 drab chartreuse bags, 1 posh white bag. +pale violet bags contain 2 shiny orange bags, 4 plaid crimson bags. +clear black bags contain 4 wavy blue bags, 5 plaid tan bags, 4 clear magenta bags. +faded aqua bags contain 2 wavy teal bags. +dotted green bags contain 5 shiny orange bags, 1 light magenta bag. +bright coral bags contain 2 shiny fuchsia bags, 4 light lime bags, 1 shiny gold bag. +vibrant fuchsia bags contain 1 vibrant chartreuse bag, 1 striped black bag. +dark turquoise bags contain 5 shiny salmon bags, 2 light lavender bags. +shiny green bags contain 1 pale silver bag, 4 dim red bags, 3 dark lime bags, 4 drab coral bags. +clear red bags contain 5 light teal bags, 5 posh brown bags. +dull gold bags contain 1 drab tan bag, 4 striped tomato bags, 5 pale maroon bags, 2 dim crimson bags. +mirrored red bags contain 3 shiny crimson bags, 4 plaid brown bags, 2 shiny black bags. +pale blue bags contain 1 wavy crimson bag, 4 faded beige bags, 4 shiny chartreuse bags. +clear beige bags contain 4 plaid crimson bags, 5 shiny crimson bags. +drab salmon bags contain 4 dim crimson bags, 3 light magenta bags, 1 clear violet bag. +vibrant magenta bags contain 4 dim black bags. +dark salmon bags contain 3 dull green bags, 4 faded red bags. +posh white bags contain no other bags. +light lime bags contain 5 dark aqua bags. +vibrant salmon bags contain 4 striped tomato bags, 4 clear aqua bags. +clear teal bags contain 3 striped gray bags. +plaid silver bags contain 3 vibrant violet bags, 2 muted magenta bags, 3 dark olive bags, 4 mirrored gold bags. +striped cyan bags contain 4 light gold bags, 2 dotted magenta bags. +wavy bronze bags contain 1 plaid crimson bag, 1 dull gray bag, 5 dull tan bags, 1 mirrored teal bag. +dim olive bags contain 4 vibrant lime bags, 2 shiny crimson bags, 2 muted turquoise bags. +dotted blue bags contain 4 vibrant gray bags, 2 shiny beige bags. +plaid blue bags contain 5 drab silver bags. +dark olive bags contain 1 pale coral bag, 4 vibrant indigo bags. +pale gray bags contain 3 dotted crimson bags, 1 striped magenta bag, 5 wavy white bags, 2 vibrant blue bags. +mirrored brown bags contain 2 bright cyan bags, 4 plaid brown bags, 5 faded turquoise bags. +wavy gold bags contain 1 wavy coral bag. +pale teal bags contain 3 vibrant magenta bags. +mirrored turquoise bags contain 4 mirrored olive bags, 5 bright yellow bags. +dark chartreuse bags contain 4 dotted cyan bags, 5 shiny turquoise bags, 5 vibrant salmon bags, 4 wavy yellow bags. +muted gray bags contain 3 dim orange bags. +posh turquoise bags contain 4 clear lavender bags, 5 dim coral bags, 2 striped salmon bags. +shiny cyan bags contain 4 striped gold bags. +drab olive bags contain 2 plaid cyan bags, 1 mirrored lime bag. +posh tomato bags contain 2 drab tan bags, 3 shiny orange bags. +muted fuchsia bags contain 1 pale salmon bag, 3 wavy violet bags, 3 mirrored maroon bags. +pale bronze bags contain 3 drab yellow bags, 3 muted chartreuse bags. +striped green bags contain 3 striped orange bags, 2 dull green bags, 3 vibrant tan bags. +faded orange bags contain 3 mirrored plum bags, 5 mirrored lime bags, 5 faded red bags. +dull aqua bags contain 2 striped coral bags. +dotted olive bags contain 4 faded salmon bags, 1 wavy green bag. +vibrant silver bags contain 4 mirrored yellow bags, 2 dotted salmon bags, 3 drab silver bags. +striped olive bags contain 1 mirrored fuchsia bag, 1 faded gold bag, 1 mirrored lavender bag. +dark violet bags contain no other bags. +mirrored olive bags contain 5 dull teal bags, 1 dim white bag. +plaid tan bags contain 4 pale gray bags, 2 dim crimson bags, 1 clear violet bag, 1 wavy lime bag. +pale tomato bags contain 5 posh green bags, 4 faded red bags. +dim turquoise bags contain 1 shiny gold bag, 5 drab blue bags. +muted lime bags contain 3 vibrant lime bags, 1 pale plum bag, 1 dark indigo bag. +drab beige bags contain 3 vibrant magenta bags. +posh beige bags contain 2 dark violet bags. +muted olive bags contain 2 pale brown bags, 5 light gray bags, 3 wavy green bags, 2 drab tan bags. +dim orange bags contain 1 clear lime bag, 4 faded beige bags, 2 mirrored fuchsia bags. +dull salmon bags contain 4 striped coral bags, 3 striped aqua bags. +dull maroon bags contain 3 clear brown bags, 5 dull magenta bags, 1 dim red bag. +mirrored coral bags contain 5 muted tan bags, 4 dotted magenta bags, 5 dim olive bags. +posh olive bags contain 4 dull magenta bags, 4 wavy blue bags, 2 drab yellow bags, 5 dotted gold bags. +mirrored violet bags contain 2 pale fuchsia bags. +drab bronze bags contain 4 drab chartreuse bags. +wavy fuchsia bags contain 2 dark gray bags, 5 muted silver bags. +pale plum bags contain 3 vibrant salmon bags, 5 drab chartreuse bags, 2 posh violet bags. +mirrored aqua bags contain 2 pale aqua bags. +bright silver bags contain 3 drab black bags, 5 dark salmon bags, 2 shiny beige bags, 2 posh lavender bags. +plaid lime bags contain 4 faded teal bags, 5 pale brown bags, 5 dim red bags. +dotted turquoise bags contain 3 dim olive bags, 2 mirrored blue bags, 3 dull lime bags, 4 vibrant lavender bags. +drab maroon bags contain 5 bright red bags. +wavy lavender bags contain 1 striped lime bag, 1 posh brown bag. +shiny beige bags contain 5 shiny aqua bags, 3 muted teal bags, 5 clear gold bags. +dark gold bags contain 4 clear maroon bags, 2 dotted maroon bags, 3 light red bags. +light aqua bags contain 2 dim red bags, 3 pale red bags. +posh teal bags contain 3 muted brown bags, 5 shiny gold bags, 5 dotted purple bags. +dull lavender bags contain 5 shiny blue bags. +dark tan bags contain 1 muted tan bag, 5 vibrant turquoise bags, 4 dark violet bags, 4 muted plum bags. +light beige bags contain 2 mirrored fuchsia bags, 1 drab chartreuse bag, 1 muted tan bag. +pale olive bags contain 3 clear brown bags. +dark maroon bags contain 5 dull plum bags, 3 muted green bags. +muted red bags contain 4 pale tan bags, 1 bright white bag. +light tan bags contain 3 light purple bags, 2 pale aqua bags, 3 wavy bronze bags. +clear magenta bags contain 3 vibrant chartreuse bags, 1 dim crimson bag. +dark orange bags contain 2 posh cyan bags, 1 wavy brown bag, 5 dull black bags. +dim lavender bags contain 5 drab fuchsia bags. +dotted beige bags contain 5 light blue bags, 4 plaid tan bags, 2 wavy maroon bags, 5 dim crimson bags. +dim green bags contain 3 plaid tan bags, 1 drab blue bag, 1 clear aqua bag. +plaid brown bags contain 3 muted turquoise bags, 4 drab chartreuse bags. +bright black bags contain 5 striped white bags. +plaid gold bags contain 3 shiny lime bags, 1 plaid maroon bag, 4 bright blue bags. +pale white bags contain 4 drab chartreuse bags, 3 pale tan bags, 5 pale aqua bags. +drab violet bags contain no other bags. +light magenta bags contain 3 faded crimson bags. +light gold bags contain 1 dim lavender bag, 3 light magenta bags, 5 drab gold bags. +plaid coral bags contain 1 vibrant salmon bag, 3 striped tomato bags, 3 posh blue bags. +dotted white bags contain 1 wavy lavender bag. +striped yellow bags contain 4 drab black bags, 2 faded red bags, 2 shiny gold bags, 4 dark aqua bags. +dark yellow bags contain 5 wavy bronze bags, 5 bright purple bags. +faded white bags contain 3 light tomato bags. +muted white bags contain 5 faded gold bags, 1 plaid magenta bag, 3 drab white bags, 5 dim brown bags. +faded red bags contain 1 posh brown bag, 2 muted turquoise bags, 3 plaid crimson bags, 4 shiny orange bags. +dark red bags contain 5 shiny salmon bags. +dull gray bags contain 2 posh white bags. +bright salmon bags contain 2 shiny aqua bags, 3 dotted crimson bags, 1 drab violet bag, 4 pale chartreuse bags. +mirrored chartreuse bags contain 1 vibrant magenta bag, 3 plaid salmon bags, 1 plaid chartreuse bag, 3 muted violet bags. +vibrant orange bags contain 5 posh yellow bags. +dark gray bags contain 1 plaid chartreuse bag, 2 drab violet bags, 1 bright chartreuse bag, 1 muted purple bag. +mirrored crimson bags contain 3 drab coral bags, 5 dull lime bags. +muted violet bags contain 3 dotted crimson bags, 3 light olive bags. +shiny brown bags contain 2 dark lavender bags, 2 vibrant yellow bags, 1 dark black bag, 2 drab olive bags. +muted green bags contain 1 dull cyan bag, 5 dull red bags, 4 pale chartreuse bags. +drab yellow bags contain 3 pale tomato bags. +dotted tomato bags contain 2 shiny magenta bags, 3 mirrored tomato bags, 5 plaid chartreuse bags. +plaid red bags contain 3 pale cyan bags. +bright red bags contain 1 shiny beige bag. +plaid purple bags contain 5 dull gold bags. +dark green bags contain 3 pale salmon bags, 3 dim brown bags, 2 wavy violet bags, 2 pale chartreuse bags. +plaid orange bags contain 1 vibrant chartreuse bag, 2 dotted coral bags, 1 posh teal bag. +plaid violet bags contain 1 shiny maroon bag. +posh tan bags contain 1 shiny beige bag, 2 dim magenta bags, 1 dark violet bag. +bright aqua bags contain 1 drab brown bag, 4 dotted purple bags. +vibrant white bags contain 4 light gray bags, 2 dark fuchsia bags, 1 pale cyan bag. +striped red bags contain 5 faded gold bags, 5 drab crimson bags, 3 faded turquoise bags. +dull purple bags contain 1 pale crimson bag. +shiny blue bags contain 1 pale violet bag, 5 mirrored plum bags, 3 posh white bags, 1 light yellow bag. +clear salmon bags contain 2 striped lime bags, 1 dull violet bag. +faded gold bags contain 3 light teal bags, 3 wavy teal bags. +mirrored yellow bags contain 2 muted turquoise bags, 4 drab chartreuse bags. +plaid gray bags contain 4 plaid plum bags. +plaid white bags contain no other bags. +drab black bags contain 2 mirrored yellow bags, 2 drab chartreuse bags, 1 shiny orange bag. +dotted chartreuse bags contain 2 vibrant cyan bags, 2 light salmon bags, 3 vibrant red bags, 5 light turquoise bags. +faded lavender bags contain 3 dark tomato bags, 5 muted lime bags, 4 light fuchsia bags, 4 dull lavender bags. +vibrant cyan bags contain 2 clear crimson bags, 3 pale orange bags, 4 dull indigo bags, 3 light red bags. +bright maroon bags contain 2 muted tan bags, 2 light teal bags. +drab silver bags contain 3 bright chartreuse bags, 4 pale crimson bags, 5 dotted crimson bags, 5 faded yellow bags. +drab purple bags contain 5 drab blue bags. +dim gold bags contain 1 bright cyan bag, 5 dull white bags, 3 vibrant blue bags. +dark beige bags contain 4 pale coral bags, 1 pale indigo bag. +dotted salmon bags contain 2 drab violet bags, 5 posh white bags. +vibrant crimson bags contain 5 faded teal bags, 3 dotted green bags, 1 clear maroon bag. +dim chartreuse bags contain 3 clear white bags. +bright violet bags contain 1 dim yellow bag, 1 muted purple bag, 4 muted teal bags, 5 striped cyan bags. +dim magenta bags contain 1 pale aqua bag, 4 pale maroon bags, 5 mirrored red bags, 4 drab yellow bags. +dim brown bags contain 5 faded salmon bags, 4 dotted magenta bags, 5 drab tomato bags, 2 faded teal bags. +shiny lime bags contain 5 dotted black bags, 4 plaid turquoise bags, 2 dim tomato bags, 2 clear magenta bags. +drab magenta bags contain 3 dark beige bags. +faded cyan bags contain 2 striped lime bags, 4 bright red bags. +dark brown bags contain 4 mirrored lime bags, 1 bright orange bag. +posh fuchsia bags contain 5 shiny gold bags, 5 pale salmon bags, 1 light coral bag, 1 mirrored plum bag. +shiny magenta bags contain 4 dark aqua bags. +dark lavender bags contain 1 pale purple bag, 3 vibrant yellow bags. +vibrant brown bags contain 2 posh teal bags, 1 wavy silver bag, 2 pale plum bags. +muted black bags contain 5 faded crimson bags, 3 dim crimson bags, 4 vibrant magenta bags. +muted brown bags contain 5 striped olive bags, 5 dark brown bags, 2 clear brown bags, 4 plaid white bags. +pale orange bags contain 4 bright blue bags, 3 dark aqua bags, 1 clear gold bag. +light cyan bags contain 3 muted silver bags. +drab white bags contain 2 drab tan bags, 2 striped tomato bags, 4 dull gray bags, 5 drab blue bags. +dim tan bags contain 3 mirrored bronze bags, 3 faded salmon bags, 4 drab purple bags. +dull tomato bags contain 3 clear lime bags. +wavy aqua bags contain 3 dotted orange bags, 5 shiny crimson bags. +shiny lavender bags contain 5 vibrant blue bags, 4 pale purple bags, 1 wavy bronze bag, 2 posh violet bags. +shiny white bags contain 5 faded blue bags, 5 pale cyan bags. +wavy blue bags contain 4 vibrant chartreuse bags, 4 plaid brown bags, 3 plaid white bags, 2 faded gold bags. +striped magenta bags contain 2 dark olive bags, 5 bright chartreuse bags. +vibrant black bags contain 4 plaid white bags, 2 dull silver bags, 5 striped purple bags, 1 dark plum bag. +dull green bags contain 2 dull crimson bags. +vibrant chartreuse bags contain 2 bright orange bags, 4 dark aqua bags. +dim violet bags contain 2 dark teal bags, 4 plaid brown bags, 4 mirrored yellow bags. +clear blue bags contain 5 posh maroon bags. +faded tomato bags contain 5 clear beige bags, 4 bright orange bags. +posh violet bags contain 3 clear gold bags. +striped tomato bags contain 2 shiny black bags. +muted crimson bags contain 4 light aqua bags, 3 dim gold bags. +clear tan bags contain 4 drab tomato bags, 4 mirrored bronze bags, 1 shiny chartreuse bag. +posh magenta bags contain 4 posh red bags, 3 light bronze bags. +dim blue bags contain 5 dim gray bags, 1 light turquoise bag, 5 muted bronze bags. +drab plum bags contain 1 vibrant plum bag, 4 striped coral bags. +pale silver bags contain 5 drab black bags. +posh purple bags contain 2 dark brown bags. +drab indigo bags contain 1 muted lavender bag, 2 posh salmon bags, 1 pale brown bag. +striped blue bags contain 4 wavy teal bags. +wavy magenta bags contain 1 dotted salmon bag, 1 drab black bag, 2 dull tan bags, 1 drab silver bag. +pale turquoise bags contain 4 dark lime bags, 4 drab maroon bags. +shiny tan bags contain 4 plaid coral bags, 3 dim black bags, 1 dull plum bag. +light teal bags contain 3 dark violet bags. +mirrored silver bags contain 1 striped salmon bag, 1 clear chartreuse bag, 2 clear orange bags, 2 posh aqua bags. +wavy coral bags contain 2 muted teal bags, 1 wavy white bag. +wavy crimson bags contain 1 shiny aqua bag, 3 muted beige bags. +shiny bronze bags contain 1 posh indigo bag, 5 wavy blue bags, 1 faded gold bag, 3 striped tomato bags. +shiny maroon bags contain 1 clear tomato bag, 1 wavy crimson bag. +bright turquoise bags contain 3 dull tan bags, 3 vibrant teal bags. +faded purple bags contain 1 plaid chartreuse bag. +bright white bags contain 2 faded gold bags. +clear orange bags contain 4 striped blue bags, 2 mirrored lime bags, 5 muted turquoise bags. +clear cyan bags contain 1 dim plum bag, 3 shiny brown bags, 1 muted purple bag, 2 plaid lime bags. +plaid teal bags contain 2 faded aqua bags, 4 wavy olive bags. +dotted lime bags contain 5 posh olive bags, 2 pale orange bags. +muted tan bags contain 1 dull gray bag, 2 dark aqua bags, 1 pale violet bag. +striped orange bags contain 3 mirrored lime bags, 2 dull crimson bags, 4 faded gold bags, 3 pale silver bags. +light olive bags contain 2 dark tan bags, 3 dim orange bags, 5 mirrored yellow bags. +plaid magenta bags contain 2 wavy orange bags, 1 wavy chartreuse bag, 5 striped coral bags. +dark magenta bags contain 3 bright white bags, 3 plaid purple bags, 3 striped black bags, 4 light beige bags. +dark black bags contain 3 pale tan bags, 4 mirrored orange bags, 3 dull teal bags. +posh orange bags contain 4 bright aqua bags, 1 dim crimson bag, 4 dim turquoise bags, 1 dotted bronze bag. +dull crimson bags contain 4 vibrant violet bags. +clear turquoise bags contain 1 muted brown bag, 2 dull yellow bags, 3 pale black bags, 1 plaid crimson bag. +vibrant blue bags contain 2 clear beige bags. +dull lime bags contain 4 shiny plum bags, 3 vibrant magenta bags, 3 dark olive bags. +drab brown bags contain 4 clear green bags. +mirrored plum bags contain 2 faded red bags. +shiny fuchsia bags contain 2 muted cyan bags, 4 dark aqua bags, 3 light olive bags, 2 clear gold bags. +vibrant purple bags contain 3 pale aqua bags, 3 dark lime bags, 1 bright chartreuse bag. +bright crimson bags contain 1 vibrant gold bag. +shiny plum bags contain 2 clear olive bags, 4 dark plum bags. +shiny crimson bags contain no other bags. +dull beige bags contain 1 mirrored coral bag. +dim salmon bags contain 1 clear tomato bag, 2 shiny teal bags, 4 plaid olive bags, 3 plaid purple bags. +muted maroon bags contain 2 muted violet bags, 4 dark white bags. +pale aqua bags contain 4 dark beige bags, 1 muted brown bag. +bright plum bags contain 4 dim black bags. +striped tan bags contain 3 bright orange bags, 3 dark violet bags, 4 drab blue bags, 2 vibrant lime bags. +clear crimson bags contain 3 wavy brown bags, 1 faded blue bag, 2 striped cyan bags. +dim indigo bags contain 3 dotted lime bags, 1 dotted purple bag. +pale tan bags contain 2 drab blue bags, 5 dim orange bags, 5 wavy olive bags, 3 striped tomato bags. +vibrant bronze bags contain 5 clear red bags, 5 posh red bags. +dotted bronze bags contain 1 light yellow bag. +wavy salmon bags contain 2 striped olive bags, 4 muted teal bags. +shiny turquoise bags contain 3 dark teal bags, 1 plaid yellow bag. +faded maroon bags contain 1 vibrant salmon bag, 5 dotted magenta bags, 1 faded tan bag, 5 striped tomato bags. +vibrant teal bags contain 4 light teal bags, 3 pale orange bags, 5 drab white bags. +vibrant gold bags contain 1 muted cyan bag, 2 mirrored plum bags, 1 drab coral bag, 4 dark lime bags. +bright cyan bags contain 2 muted silver bags, 5 plaid bronze bags, 3 light beige bags, 2 faded crimson bags. +shiny silver bags contain 4 mirrored fuchsia bags, 2 clear violet bags, 3 faded beige bags. +dark tomato bags contain 4 clear lime bags, 2 light beige bags, 3 bright turquoise bags. +mirrored indigo bags contain 5 posh chartreuse bags, 5 clear tomato bags. +dotted indigo bags contain 2 drab olive bags, 2 dim indigo bags, 5 dotted magenta bags. +shiny gray bags contain 4 muted chartreuse bags, 4 plaid gray bags, 3 dull red bags, 5 striped orange bags. +dim yellow bags contain 1 muted cyan bag, 4 mirrored fuchsia bags, 1 faded gold bag, 1 drab turquoise bag. +bright lime bags contain 5 shiny bronze bags, 3 wavy aqua bags, 4 plaid turquoise bags. +dotted gray bags contain 2 shiny gold bags. +striped black bags contain 1 wavy teal bag, 5 dim chartreuse bags, 4 mirrored lavender bags. +pale beige bags contain 2 posh black bags, 4 clear white bags. +posh indigo bags contain 5 plaid white bags. +dull blue bags contain 4 dark violet bags, 2 clear magenta bags, 4 dotted crimson bags. +mirrored white bags contain 5 faded yellow bags. +bright brown bags contain 3 pale gray bags. +light gray bags contain 3 clear magenta bags, 5 wavy brown bags, 3 dotted salmon bags. +muted orange bags contain 1 bright magenta bag, 1 bright plum bag. +clear purple bags contain 1 shiny gold bag, 1 dark white bag. +striped coral bags contain 5 pale gray bags, 3 wavy chartreuse bags. +plaid green bags contain no other bags. +plaid maroon bags contain 5 posh brown bags, 3 striped crimson bags, 4 plaid green bags. +light maroon bags contain 3 muted gray bags, 5 dull crimson bags, 2 shiny maroon bags. +pale purple bags contain 2 striped white bags, 3 plaid chartreuse bags, 1 mirrored lime bag. +muted yellow bags contain 5 vibrant purple bags, 1 dark teal bag. +plaid olive bags contain 1 light crimson bag, 1 faded gold bag, 1 vibrant blue bag. +dim beige bags contain 4 muted silver bags, 3 mirrored beige bags, 4 striped violet bags. +striped chartreuse bags contain 3 dull teal bags. +muted salmon bags contain 2 posh salmon bags, 2 posh silver bags. +dim red bags contain 2 drab blue bags, 4 plaid crimson bags, 3 vibrant gold bags. +dull magenta bags contain 5 faded crimson bags, 1 shiny orange bag, 1 dark tan bag. +plaid beige bags contain 1 vibrant turquoise bag. +striped teal bags contain 2 dim chartreuse bags, 4 dark green bags. +dotted plum bags contain 2 light cyan bags. +dotted yellow bags contain 5 posh black bags, 5 dull tan bags, 2 dull violet bags, 5 muted plum bags. +dotted coral bags contain 1 striped tomato bag, 2 light crimson bags, 3 clear violet bags. +dull fuchsia bags contain 3 plaid purple bags, 4 mirrored red bags. +dull yellow bags contain 5 vibrant violet bags, 2 dark olive bags. +dull white bags contain 5 posh olive bags, 5 pale tomato bags, 2 bright teal bags. +pale brown bags contain 3 dim crimson bags, 3 pale indigo bags, 1 dim chartreuse bag, 4 muted teal bags. +shiny violet bags contain 1 muted tomato bag, 2 dull yellow bags, 1 drab teal bag. +drab blue bags contain 3 vibrant gold bags, 4 drab black bags. +posh lavender bags contain 5 shiny plum bags, 3 drab salmon bags, 4 dim brown bags, 4 plaid blue bags. +dull teal bags contain 2 drab turquoise bags, 1 shiny crimson bag, 5 shiny aqua bags. +shiny purple bags contain 3 drab orange bags, 4 dark red bags, 4 vibrant fuchsia bags, 2 light fuchsia bags. +pale salmon bags contain 2 plaid chartreuse bags, 3 striped white bags. +posh silver bags contain 4 clear magenta bags, 5 light magenta bags. +light salmon bags contain 4 vibrant olive bags. +striped turquoise bags contain 1 faded magenta bag, 3 shiny indigo bags, 4 striped lavender bags. +dotted crimson bags contain 2 pale silver bags, 2 striped magenta bags, 1 striped white bag. +dull brown bags contain 5 clear crimson bags, 1 dotted green bag, 4 dull magenta bags, 3 dim tan bags. +plaid cyan bags contain 1 striped orange bag, 2 muted cyan bags. +muted lavender bags contain 5 mirrored fuchsia bags. +dim lime bags contain 1 muted black bag. +light bronze bags contain 1 dull crimson bag, 5 dim chartreuse bags. +dull olive bags contain 2 vibrant coral bags, 3 shiny teal bags, 4 plaid purple bags. +posh yellow bags contain 5 dark lime bags, 3 mirrored plum bags. +bright fuchsia bags contain 1 striped silver bag. +posh maroon bags contain 4 dotted magenta bags, 4 posh yellow bags, 2 drab beige bags. +posh salmon bags contain 2 muted green bags. +mirrored gray bags contain 4 striped silver bags. +dull cyan bags contain 2 bright orange bags, 4 dark plum bags. +light crimson bags contain 3 drab fuchsia bags, 3 bright blue bags, 1 dark purple bag. +light red bags contain 3 dim maroon bags, 4 muted green bags, 3 dotted olive bags. +dull indigo bags contain 2 plaid brown bags, 1 wavy white bag, 2 vibrant turquoise bags, 5 drab chartreuse bags. +drab crimson bags contain 2 vibrant salmon bags. +posh red bags contain 3 mirrored violet bags, 1 striped tomato bag, 2 striped olive bags. +drab chartreuse bags contain no other bags. +posh lime bags contain 3 drab violet bags, 1 bright coral bag. +wavy red bags contain 4 striped gray bags, 3 posh salmon bags, 1 dotted violet bag, 3 striped aqua bags. +striped fuchsia bags contain 3 bright crimson bags, 3 dark silver bags, 1 clear magenta bag, 3 drab salmon bags. +striped plum bags contain 2 drab tan bags, 5 pale gold bags, 1 dull white bag, 1 clear coral bag. +mirrored maroon bags contain 1 dark magenta bag, 1 plaid purple bag, 2 light gray bags. +shiny indigo bags contain 2 drab teal bags. +dim silver bags contain 1 striped aqua bag, 3 dull tan bags, 3 striped tan bags, 2 wavy maroon bags. +shiny salmon bags contain 5 faded beige bags. +dull black bags contain 3 vibrant plum bags, 2 plaid chartreuse bags, 1 muted brown bag, 2 clear tomato bags. +clear plum bags contain 3 striped maroon bags, 2 dark white bags. +vibrant green bags contain 5 light orange bags, 5 mirrored magenta bags, 3 bright teal bags, 2 striped brown bags. +drab gray bags contain 1 plaid maroon bag, 2 pale tan bags, 1 plaid white bag. +wavy lime bags contain 2 clear gold bags, 2 bright chartreuse bags, 1 faded crimson bag. +light silver bags contain 4 dim maroon bags, 1 mirrored teal bag. +light brown bags contain 5 muted magenta bags. +dim fuchsia bags contain 5 pale purple bags, 5 wavy orange bags, 5 clear lime bags. +vibrant maroon bags contain 4 light gray bags. +dim purple bags contain 2 muted white bags, 2 shiny aqua bags. +clear olive bags contain 3 bright olive bags. +drab lavender bags contain 4 mirrored crimson bags, 3 bright violet bags, 5 posh gold bags, 2 bright olive bags. +light yellow bags contain 1 posh brown bag, 2 pale violet bags. +plaid crimson bags contain 1 plaid green bag, 3 shiny crimson bags. +pale indigo bags contain 3 clear aqua bags, 2 pale silver bags. +mirrored bronze bags contain 4 muted tomato bags, 4 bright white bags, 1 faded crimson bag. +dim teal bags contain 1 muted salmon bag. +clear violet bags contain 2 dim coral bags, 2 faded beige bags. +dotted silver bags contain 2 posh plum bags, 4 pale chartreuse bags. +pale gold bags contain 2 vibrant gold bags, 1 dotted magenta bag. +posh crimson bags contain 4 dull yellow bags, 3 clear fuchsia bags. +dull orange bags contain 3 dull silver bags, 3 clear violet bags, 4 clear chartreuse bags, 3 faded salmon bags. +striped lime bags contain 5 mirrored plum bags, 4 faded gold bags, 3 wavy white bags, 3 light teal bags. +mirrored tan bags contain 4 dull silver bags, 4 light coral bags, 2 plaid lavender bags. +wavy tomato bags contain 4 clear orange bags, 5 shiny fuchsia bags, 3 light red bags. +dotted teal bags contain 5 dark salmon bags, 1 light indigo bag, 4 pale white bags, 5 clear olive bags. +bright olive bags contain 1 dark tan bag, 4 striped orange bags, 3 bright orange bags. +plaid plum bags contain 1 shiny maroon bag, 1 dotted coral bag. +bright chartreuse bags contain 2 wavy blue bags. diff --git a/day-7/src/main.rs b/day-7/src/main.rs new file mode 100644 index 0000000..a427514 --- /dev/null +++ b/day-7/src/main.rs @@ -0,0 +1,182 @@ +use std::collections::HashMap; +use std::fs; + +use lazy_static::lazy_static; +use regex::Regex; + +fn main() -> Result<(), Box<dyn std::error::Error>> { + let input = fs::read_to_string("input")?; + let rules = parse_rules(&input)?; + + // Part 1 + println!("{}", count_containing_bags(&rules, "shiny gold")); + + // Part 2 + println!("{}", count_contained_bags(&rules, "shiny gold")); + + Ok(()) +} + +fn parse_rule(input: &str) -> Result<HashMap<String, usize>, std::num::ParseIntError> { + // Rules look something like: + // + // <value> <key> bags?, <value> <key> bags?. + // + // or: + // + // no other bags. + + lazy_static! { + static ref RULE_RE: Regex = Regex::new(r"(\d+) (.+?) bags?").expect("Should compile"); + }; + + if let "no other bags." = input { + Ok(HashMap::new()) + } else { + RULE_RE + .captures_iter(input) + .map(|captures| Ok((captures[2].to_string(), captures[1].parse::<usize>()?))) + .collect() + } +} + +fn parse_rules(input: &str) -> Result<HashMap<&str, HashMap<String, usize>>, String> { + input + .lines() + .map(|line| { + // Each line looks something like: + // + // <key> bags contain <rule> + // + // So we simply split on " bags contain " and pass the + // rest to the rule parsing function. + + // Note this will be a lot easier once str::split_once is stable + let (key, rule) = { + let temp: Vec<&str> = line.split(" bags contain ").collect(); + if temp.len() != 2 { + Err(format!("Invalid format for bag rule: {}", line)) + } else { + Ok((temp[0], temp[1])) + } + }?; + + Ok(( + key, + parse_rule(rule).map_err(|e| format!("Could not parse rule '{}': {}", rule, e))?, + )) + }) + .collect() +} + +fn count_containing_bags(rules: &HashMap<&str, HashMap<String, usize>>, color: &str) -> usize { + fn contains_recursively( + rules: &HashMap<&str, HashMap<String, usize>>, + rule: &HashMap<String, usize>, + color: &str, + ) -> bool { + // A bag contains the given color recursively, if either it + // contains the color, or any bags it contains contain the bag + // recursively + rule.contains_key(color) + || rule.keys().any(|bag| { + if let Some(rule) = rules.get(bag.as_str()) { + contains_recursively(rules, rule, color) + } else { + // The bag should always be in our index, but in + // case it's not, we treat it as if it contains no other bags. + false + } + }) + } + + // Count from how many bags the given bag is reachable + rules + .iter() + .filter(|(_, rule)| contains_recursively(rules, rule, color)) + .count() +} + +fn count_contained_bags(rules: &HashMap<&str, HashMap<String, usize>>, color: &str) -> usize { + if let Some(rule) = rules.get(color) { + // Count how many bags are reachable from this bag; except + // multiply the numbers by the number of each bag contained + rule.iter() + .map(|(contained, number)| number + number * count_contained_bags(rules, contained)) + .sum() + } else { + // The bag should always be in our index, but in case it's + // not, we treat it as if it contains 0 other bags. + 0 + } +} + +#[cfg(test)] +mod tests { + use super::*; + use indoc::indoc; + + #[test] + fn test_simple() -> Result<(), Box<dyn std::error::Error>> { + let input = indoc!( + " + light red bags contain 1 bright white bag, 2 muted yellow bags. + dark orange bags contain 3 bright white bags, 4 muted yellow bags. + bright white bags contain 1 shiny gold bag. + muted yellow bags contain 2 shiny gold bags, 9 faded blue bags. + shiny gold bags contain 1 dark olive bag, 2 vibrant plum bags. + dark olive bags contain 3 faded blue bags, 4 dotted black bags. + vibrant plum bags contain 5 faded blue bags, 6 dotted black bags. + faded blue bags contain no other bags. + dotted black bags contain no other bags. + " + ); + + let rules = parse_rules(&input)?; + assert_eq!(count_containing_bags(&rules, "shiny gold"), 4); + + Ok(()) + } + + #[test] + fn test_simple2() -> Result<(), Box<dyn std::error::Error>> { + let input = indoc!( + " + light red bags contain 1 bright white bag, 2 muted yellow bags. + dark orange bags contain 3 bright white bags, 4 muted yellow bags. + bright white bags contain 1 shiny gold bag. + muted yellow bags contain 2 shiny gold bags, 9 faded blue bags. + shiny gold bags contain 1 dark olive bag, 2 vibrant plum bags. + dark olive bags contain 3 faded blue bags, 4 dotted black bags. + vibrant plum bags contain 5 faded blue bags, 6 dotted black bags. + faded blue bags contain no other bags. + dotted black bags contain no other bags. + " + ); + + let rules = parse_rules(&input)?; + assert_eq!(count_contained_bags(&rules, "shiny gold"), 32); + + Ok(()) + } + + #[test] + fn test_simple3() -> Result<(), Box<dyn std::error::Error>> { + let input = indoc!( + " + shiny gold bags contain 2 dark red bags. + dark red bags contain 2 dark orange bags. + dark orange bags contain 2 dark yellow bags. + dark yellow bags contain 2 dark green bags. + dark green bags contain 2 dark blue bags. + dark blue bags contain 2 dark violet bags. + dark violet bags contain no other bags. + " + ); + + let rules = parse_rules(&input)?; + assert_eq!(count_contained_bags(&rules, "shiny gold"), 126); + + Ok(()) + } +} From 0c61772aa026a1be39a2e1f284b27e14a077a94d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= <tm@tlater.net> Date: Thu, 3 Dec 2020 20:41:18 +0000 Subject: [PATCH 4/8] Complete day 3 --- day-3/.gitignore | 1 + day-3/Cargo.lock | 78 +++++++++++ day-3/Cargo.toml | 10 ++ day-3/input | 323 ++++++++++++++++++++++++++++++++++++++++++++++ day-3/src/main.rs | 91 +++++++++++++ 5 files changed, 503 insertions(+) create mode 100644 day-3/.gitignore create mode 100644 day-3/Cargo.lock create mode 100644 day-3/Cargo.toml create mode 100644 day-3/input create mode 100644 day-3/src/main.rs diff --git a/day-3/.gitignore b/day-3/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/day-3/.gitignore @@ -0,0 +1 @@ +/target diff --git a/day-3/Cargo.lock b/day-3/Cargo.lock new file mode 100644 index 0000000..d0411da --- /dev/null +++ b/day-3/Cargo.lock @@ -0,0 +1,78 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "day-3" +version = "0.1.0" +dependencies = [ + "indoc", +] + +[[package]] +name = "indoc" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47741a8bc60fb26eb8d6e0238bbb26d8575ff623fdc97b1a2c00c050b9684ed8" +dependencies = [ + "indoc-impl", + "proc-macro-hack", +] + +[[package]] +name = "indoc-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce046d161f000fffde5f432a0d034d0341dc152643b2598ed5bfce44c4f3a8f0" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", + "unindent", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "1.0.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8833e20724c24de12bbaba5ad230ea61c3eafb05b881c7c9d3cfe8638b187e68" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "unindent" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f14ee04d9415b52b3aeab06258a3f07093182b88ba0f9b8d203f211a7a7d41c7" diff --git a/day-3/Cargo.toml b/day-3/Cargo.toml new file mode 100644 index 0000000..d861f49 --- /dev/null +++ b/day-3/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "day-3" +version = "0.1.0" +authors = ["Tristan Daniël Maat <tm@tlater.net>"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +indoc = "0.3" diff --git a/day-3/input b/day-3/input new file mode 100644 index 0000000..b4223c3 --- /dev/null +++ b/day-3/input @@ -0,0 +1,323 @@ +...#...#..#....#..#...#..##..#. +.#..#.....#.#............###... +.#...###....#.............##..# +...##...##....#.....##..#.##... +.....###.#.###..##.#.##.......# +#...##.....#..........#..#.#.#. +......##.......##..#....#.#.... +....#.###.##..#.#..##.##....#.# +.......#.......###.#.#.##.....# +.........#.#....#..........#.#. +.#...##.....##.........#..#.... +.##....#.#.#...##......#....... +##.#.#..#....#....#....#...#.#. +##....#.#..##......#....##...#. +....#..#..##..#.###.......#.#.. +.....##....###...........#.#.## +#.....##.........#....##......# +........###.#..#....#....#..... +...#.......#.##..#.###......#.. +...............#..#....#.##.... +..#..###..#.#..#.........##..#. +####..#..####.................. +#...####...#.......#.#.#...#... +......###.....#......#..#..#... +#...#.....##.....#.#..##...#.#. +#...........##.......#......... +.#..#.........#.#..##....#..... +........##...#................# +........#.###.#.###.#.#.##..##. +.#....##.....#...##.#..#.#..... +..#..#.....###....##.#....#.#.# +#......##.##...##..#.........#. +#..#..#.....#.....#.........#.. +#....#.#...###.........#...#... +.#.#.....##......#.#......#.... +..##......##...#.#.#.#......... +..#......#.....##.###.#.#..#... +....#..#.......#..#..#.....#... +.#.#.....#...#..........#...... +#.#..#...........#.#.##.#...#.# +..#.#....###...#...#.....#.#... +....##.#.###....####.......#... +.....##....#.......#..#..#....# +...##..#.#.#.#......#......#... +...##...#....#...#......###...# +........#..#.#.....#.###....... +..#..##.#....#.#.........#...#. +.....#.####....#.##.........#.. +......#...#...#.....#......###. +.##.....#....#..#.#....#.....#. +...........#...#....##..#...#.. +.....#....#.....#...##..#...#.# +.#...#.........#.......#...#..# +...#..#...#........#......#.... +..#..#####.#.....#.#....#...#.# +...#.......#.#....#...##..#..#. +####..#.#.###.#.#.............. +.##........#...#.#....#..#..... +..#..............#.#..##...#.## +.###.#.....#.#.....##.#......## +....###.....#...#...#.#..#..... +....###.#.##.......#....#...#.. +#..#...#......##..#.....#.#...# +....#.#.........#.............. +#.##.##...#..#.#.#.....#...#.## +#...#...#......#...........##.. +#.#.#......#............#.#.... +.#.#..######...#.#.........#.## +..#.#..#...#......#............ +....#.....#......##..#.....#... +.##............#....##..#...... +.#.#.#...#.##.............###.# +#.#...#...#.....#....#.#.#..... +........#..#......##.##.#.....# +.....#.....#.#####...#....#.... +.#...#......#.........#.#...... +...#...#..##.....##....#..#.... +....#....##..#.........#....... +..#........##..#.#........#.... +...#...##...........#...#....#. +.....##.........#..#....#..#.#. +#..#....##..#...##.....#..##.#. +..#.#.#.#...#...#.....#.#....#. +.......#.###...#.#.......#.#... +....#..#..#.###.#.....###..#.#. +.#..##......#..#..#....#.####.. +..##...........#...#.........#. +......#..#...#..........#...... +....#..........#......##...#... +....#..#.##........#.#...##.#.. +#.##......#........##.#...#...# +#..#....#.....###........##.... +...........##.....##..#....#.## +..#....#..#..#......#.#.....#.. +#....#.##....#.....##.......#.. +.#.....#.#..............#.##..# +.#..#..#...#...#....#.#.....#.. +...###...##.#...#..#........#.. +#...#.##.#.....#.#....#..#..... +#.....###.#.......#.#..#.#..##. +....#..#..##.......###.#...#... +.#...####...............#.....# +.#.##.#.....#.....#.#......##.# +#...........#.##....###.##....# +...............#..........#.... +.....#..#.##.###.#............. +...##.............#.....#.#..#. +....#.#...#.#..#..#..#....#.... +..#.......#..........#...#...#. +...............#.#.#...###....# +....#...#.##....#..##....#..... +........#.#.##.........##.##.## +#.....###.......#.#....#..#..## +.#..#...#......#.#..##.......#. +#.....#.#........#.##..#..#.... +.###..##.#.......#......###.... +.#...###.....#.....#....###...# +........##.##......#.#....#...# +.#....#..#.........#..##...##.. +.......#.......##.#..#..##..... +#..##..##......#.#......#.##... +..#..###..#...#....#..#...#.... +#.............#.####.........## +..#..................#...#..#.. +..#......#........##.......#.#. +.#.#.#.#..###.....#....#.#..... +...#.##.###.......#....#....... +................##...#.....#... +..#.###.#...#.####....#..#..#.. +..#....###....##..#.#.........# +.#..#.#.....#........#....##... +.....#..#......#..#..##.#.#.... +.#..#.........##....##......#.. +.....#.#...#...#.#...#.#...#.#. +..#..#...#...#...##.#..###..... +..#..##......#..##.#...##...... +.......#..##....##.#......#..#. +..#......#.#.....#.##....##.... +..#....#......#......##........ +....##.#.#....#.......#.##..... +#.....#...###....#....#...#.... +............#.#..#...#...#..#.. +..##.............##....#....... +.#.......#.##.#......#....##... +...##............#....#..#...#. +.##.####.....#.#..###.#....#.## +....##.#........#..#...#....... +...#...###.##...........##..#.. +..##..##....#...#..#..........# +..#.........#.#...##..........# +.......##....#.#...##.....#..#. +.............#.....#.#.......#. +#.......#..##..##...##.#....... +..............#.....#.#..#...## +........##..#.....#...#...#.#.. +###.#.................#........ +...#........#...#.#######..#..# +...#.##...##.#.#..######...#... +#.......#..#....#..#.##.....#.. +#..#....##....#.##.......#....# +#...#..#.#.#...#..#.##..#...... +....#..##....#..#.#...........# +.##..#.#.............###....... +#....##......#..#..#.....###... +..#..........#...###.#......... +.####......#....#......#.#....# +..#....#.#.#......#....#....... +.....#.....#....#....#####....# +.##..........#...#.###....#.... +....##.....##......#...#.#..... +.#...#...#..#.#.#...#####...... +...#.##..####.##.##.......##... +............#.......#.......... +.#..##.#..#####........#..#...# +#......##..##..##.........##... +....#....#.............#.#....# +###..#.....#.....#.#...#..#.### +#...#.......##......#....#.#.#. +...#......#..#...#....#...###.# +....#....##.......#....#......# +............#......##.##.....#. +...#.........#......#....##..## +.....##....##...#..###...#..#.. +.......##.#..........#.##.##... +....##...........#.#..#..#.##.# +#...#..##.##.#....#....#.#..... +...##.#.....#..#..#..###....##. +#.##.#..#..#.#.............#... +..#.#.............###.....#.... +...#..#....#..#.....#.#..#..#.. +...#.....##.#...........#..##.# +.........#.#.##..#..#.#...#.... +...#..##..#...#...###.##.#..#.. +.#..##...##......##..##........ +......##....##.#.##.#.#........ +...#..................#.....#.. +.##................#.#..#..###. +.##.##.....#................#.. +.....#.#..........#...#..#.#..# +.............#......#..#.#..#.. +...#...##..#........#....#..... +#......#........##.##...##..... +##..#..##....#...#............# +..##..##.##....##..##........#. +...#....#.#.#.#....#.#...##.... +....#...##..##.#.##...#..#...#. +#..#....##.#.....#.......#...## +##.#....#.............#..#..... +.##..#..#.#.....#.......#.#..#. +.......#..#...##...#...###..#.. +..........#...#.#..##.....#...# +..#....#...........#####....#.. +#....#..#.......##............. +.........##..#####.......##.... +#..#..........#.....###...#..#. +.#.#.#..#...#.......##...#####. +.....#....#.###...#.......#.... +#.#.....##...###....###....#... +.#.....#..#.#.#........#...#... +.##.#.#.#......#....###....#... +.#..##..####......###......#... +......#.#.#.#.#...#...####.##.. +.#........##..#.....#....#....# +.....###......##..#....#....... +#.#.##...#.#......###.......... +........#.#...#..#......#....#. +..##...##.........#.......#.#.. +..#.##....#...##.....#.###..... +.........#..#.#....#....#.#.##. +#.........#......#..#.......#.. +...#...##.......#.........#.... +............#......#........... +##.....#.....#.#...#.....#..... +..#.#...#..#...#.#...........#. +#.#.#..#..#...##.#...#.#.....#. +.#..###.#..##.#.....#.....#.... +##....##....#.......##..##..... +.#..#...........###..........#. +.#..#..#..........###..#....... +#..###......#............##...# +#......#........#..#..#..#.#... +.......#.###...#.##............ +.##....#.......#.#...##.....#.# +....#..#.#.......#.#........... +##....#.###.#....#.#..##.#....# +..#..#..#....#...#........##... +...#...##....#..#.#...#..#..... +......#..#......#....#.......#. +#.#..............#...###...#..# +...#....#..#..........#.#...#.. +#.....##..##.....#........#.... +.#...##..#.#..............#.... +##.#....#..##...#..#.####.#..#. +.....#.......#.#.#.#..#.....### +...#.##....#.#........##....... +#...#.#...#.#..###..##.##...#.# +###..............#.#.###....... +...###..#.#..#....##...###.#... +......##...........#...#..#...# +.#..#.........##.......#..#...# +.#.......###......##...#...#... +.#......##...#........#.......# +.#..#.....#.........#.#........ +#...#.#.....#...#..##.........# +......##.#......##.#..##.#..... +...............#.#..#....#....# +#....#..#..#..#.#.....##...##.. +#.#......#.###......#..#...#### +.#.#..#...#...#.#..#.##.##.#.#. +.....#.#...###...#.#.....##.... +...#..#.#..........##.#....#.#. +...#..#.#.##.....###.##.#....#. +..........#..###......#..#.#... +###.....#..###..#...#..###.#... +..#..#.....##.#.#..###.......#. +....#....##........##.......... +.......#..........#...#......#. +.#........#.#.#.#.#.......#.... +.#..#.......##..##....#.#...#.. +.#.#.#.......#..#.............. +#.#....#.#...#.#.#.....#.#...## +.....#..........##..#.......#.. +.##......#.#....#.#.......#.... +..#.##....#.##.#...#........... +...##......##..##.............# +..........##.#.#..#..........#. +.##....#..#..#.#....##.#...#.#. +...........#....#.....#.#..#... +.#.....#....##..#.........#.... +.....#.....#...#....#...#.###.# +..#....#....#.....#...#......#. +.....##..#.............#...#... +........#..#.......#.#.......#. +#...###..#.##.#...###...##..##. +....##..#.......#...#.#........ +.#...#.#.##....####........#..# +.#...#.#.####.##.#............. +#..##...#....#...#.#.#.#.##..#. +.#.......#........#.....###.... +#.#.....#....#..#....#..#....#. +...#..#...#.....#.........##... +.#....#......###...#....#.#.#.. +#.#........#......#...#....##.. +.....#..#......#..#..#......#.. +.#.....#..#.##.#.#.#...#......# +##........#..#.#..#...#.####... +..........##....#.#..#.#....#.. +#.##..#..#....#..#....##..#.#.# +..#......#.......#...##..#..... +##...#.........#......#......#. +.#.....................#..#.##. +.#.......#........#.#.#..##.#.. +..#..........#........#..##.#.. +.#...#...#.........##.#.#.#.... +....#....#.###.#....###....#.## +....##......##........##.#.##.. +....#.#......#.##.#...#.##..... +....#....#..#.#..###.#.#....... +....#......#..#.#.......#..##.. +.....#..#.#.##.##..##.....#.#.. +...#....................##..... +#.....#...##...#.#............. +..#.#...#.#.#.....##..#....#... diff --git a/day-3/src/main.rs b/day-3/src/main.rs new file mode 100644 index 0000000..b5c2d85 --- /dev/null +++ b/day-3/src/main.rs @@ -0,0 +1,91 @@ +use std::fs; + +fn main() -> Result<(), Box<dyn std::error::Error>> { + let input = fs::read_to_string("input")?; + let slope = parse_slope(&input)?; + + // Part 1 + let encounters = count_encounters(&slope, (1, 3)); + println!("{}", encounters); + + // Part 2 + let encounters: usize = [(1, 1), (1, 3), (1, 5), (1, 7), (2, 1)] + .iter() + .map(|angle| count_encounters(&slope, *angle)) + .product(); + println!("{}", encounters); + + Ok(()) +} + +fn parse_slope(input: &str) -> Result<Vec<Vec<usize>>, String> { + input + .lines() + .map(|line| { + line.chars() + .map(|c| match c { + '.' => Ok(0), + '#' => Ok(1), + other => Err(format!("Invalid slope; contains character: {}", other)), + }) + .collect() + }) + .collect() +} + +fn count_encounters(input: &Vec<Vec<usize>>, angle: (usize, usize)) -> usize { + input + .iter() + .enumerate() + .step_by(angle.0) + .map(|(i, row)| row[(i * angle.1 / angle.0) % row.len()]) + .sum() +} + +#[cfg(test)] +mod tests { + use super::*; + use indoc::indoc; + + #[test] + fn test_simple() -> Result<(), Box<dyn std::error::Error>> { + let example = indoc!( + "..##....... + #...#...#.. + .#....#..#. + ..#.#...#.# + .#...##..#. + ..#.##..... + .#.#.#....# + .#........# + #.##...#... + #...##....# + .#..#...#.#" + ); + + let parsed = parse_slope(example)?; + assert_eq!(count_encounters(&parsed, (1, 3)), 7); + Ok(()) + } + + #[test] + fn test_simple2() -> Result<(), Box<dyn std::error::Error>> { + let example = indoc!( + "..##....... + #...#...#.. + .#....#..#. + ..#.#...#.# + .#...##..#. + ..#.##..... + .#.#.#....# + .#........# + #.##...#... + #...##....# + .#..#...#.#" + ); + + let parsed = parse_slope(example)?; + assert_eq!(count_encounters(&parsed, (2, 1)), 2); + Ok(()) + } +} From ab79670185461cc91747489b771f55c97108c99e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= <tm@tlater.net> Date: Sat, 5 Dec 2020 20:42:17 +0000 Subject: [PATCH 5/8] Complete day 5.1 --- day-5/.gitignore | 1 + day-5/Cargo.lock | 78 +++++ day-5/Cargo.toml | 10 + day-5/input | 815 ++++++++++++++++++++++++++++++++++++++++++++++ day-5/src/main.rs | 94 ++++++ 5 files changed, 998 insertions(+) create mode 100644 day-5/.gitignore create mode 100644 day-5/Cargo.lock create mode 100644 day-5/Cargo.toml create mode 100644 day-5/input create mode 100644 day-5/src/main.rs diff --git a/day-5/.gitignore b/day-5/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/day-5/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/day-5/Cargo.lock b/day-5/Cargo.lock new file mode 100644 index 0000000..80f8ea6 --- /dev/null +++ b/day-5/Cargo.lock @@ -0,0 +1,78 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "day-5" +version = "0.1.0" +dependencies = [ + "indoc", +] + +[[package]] +name = "indoc" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47741a8bc60fb26eb8d6e0238bbb26d8575ff623fdc97b1a2c00c050b9684ed8" +dependencies = [ + "indoc-impl", + "proc-macro-hack", +] + +[[package]] +name = "indoc-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce046d161f000fffde5f432a0d034d0341dc152643b2598ed5bfce44c4f3a8f0" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", + "unindent", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "1.0.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8833e20724c24de12bbaba5ad230ea61c3eafb05b881c7c9d3cfe8638b187e68" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "unindent" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f14ee04d9415b52b3aeab06258a3f07093182b88ba0f9b8d203f211a7a7d41c7" diff --git a/day-5/Cargo.toml b/day-5/Cargo.toml new file mode 100644 index 0000000..f161c8d --- /dev/null +++ b/day-5/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "day-5" +version = "0.1.0" +authors = ["Tristan Daniël Maat <tm@tlater.net>"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +indoc = "0.3" diff --git a/day-5/input b/day-5/input new file mode 100644 index 0000000..8699311 --- /dev/null +++ b/day-5/input @@ -0,0 +1,815 @@ +BFBBFFFLRR +FFBFBBBLLL +FBFBFBFLLL +BBFFFBFLLR +FBFFBBFLRR +BBFBFFFLLL +FFBBFFFRLL +BFBFBBBRRR +FBFFBFFRLR +FBBBBBBLLL +BBFBBBBLLL +BFFFBBBLLL +FFBFFFBRLR +BFFFFBFLLR +FFBBBFBLRL +BFFBFBBRRL +FBFBFBBRRR +FBFFFBBRRL +FBFBBBFRLR +BFFFFFBRRL +BBFFFBBLRR +FFBBBBBRRR +FFBBBBBLLL +BBFBFFBRLR +FBFFBFBRRR +FFFBBBBRLL +BBFBFFBLLR +BFBFFFBRLL +FFBFBFFLLR +FBFBBFBRLL +FBFFBBBLLL +FBFBBBFRLL +FBFBFBBRLL +BFFFFBBRLL +FFFBBFFLLR +FFBFFFBLRL +FFBFBBFLLL +BFBBFBBLLL +BFFFFBBRRL +FFBFFFBRLL +BFBBFFFRRR +FFBBFFFLRL +FFBFBFBRLL +BFBFBBBLLL +BBFBBFFLRL +BFFFFBBLLR +FFBFBBFRLR +FFBBFBBLLR +FBFFBBFLLL +BFBFBFBLLL +BFFBFBBLLR +FBBBBFFRLR +FBBBFBFRLL +FBBBBFFLRR +BFFBBBBLRL +FBFFBBFLRL +BBFFFBBLLR +FBFBFFFRLL +FBBBFBBRRL +FFBBBFBLLR +BFFBBBFLLR +BFFFFBFRLR +BBFFFFBLLR +FBBFFFBRRL +BFFFBFBRRR +FBFBFFFRRR +BBBFFFBLRL +BFBFBFBLLR +BFBBBBBLRL +FFBBFBBRRR +FBBFFFBRRR +FFBFBFBRRR +BBFFFFBRRL +BFBBBBBLLL +BFBFBFFRLL +BFBFBFBRRL +BFBFFFFLRL +FFBBBBBLLR +FBBFBFFRLL +FBBFFBBLLL +BFFFFFFLRL +FFFBBFFLRL +FFFBBFFRLL +FFBFFFBLLL +FBBFBFBLRL +BBFFFFBRLR +FBBFBBBRLR +FFBBFFBLLL +FFBFFFBRRR +FBFBFBFRRL +FFBBBFBRRL +BBFFBFFLRR +FBFFFFFRRR +FBBFFFBRLL +FFBBFBBRRL +FFBBFFFLLR +FBFBBFBLLL +BFFFBBFLRR +BFBFBFFLRR +BFFFFBFRRR +BBFBBFFRLL +BFBBBBBLRR +BFBBBBFLLL +BBFBBBBLLR +FFBBBFFRRR +BBFFBFBLRR +FFFBBBFRLR +BFBFFFBLRR +BFFFBBFLLL +FBBBBFFLRL +FBBFFFFRRL +FFBFFBBRRL +BFBBBBBRLR +FBBFFBBLRL +BBFBFBBRLL +FBFFBFBRLR +FBBBBFFLLR +FBBFBBFRRL +FBFBBBBRLL +BFFBFBFRLL +FFBFBBFRRL +FBFFFBFRRL +FBFFBBFRRL +FFBFBBFRLL +BBFBBBBLRL +BFFFBBBRRL +FFBFFFBLRR +FFBBFBBLRL +BFBFBBFRRR +BFFFFFFRRL +FBBBBBBRRR +FBFBBFBLRR +FBFFFFFRLR +BFFBBBFLRR +BFBBFFBLLL +FBFFFFBLRL +FFBBBBBLRL +FFFBBBFRLL +FFBBFBFRLL +FBFBBBFLRL +FFBBBFBRLL +BBFBBFBLRL +FFBFBFFRLR +BBFBBBBLRR +FFFBBBBRRR +FBBBFBFLLL +BFFFBFBRLR +FBBFBBFRRR +FBFFBBBRLR +FBFBBFBRLR +FBBBFBBLLL +BBFBFBFLLL +FFBBFBBRLL +FBBFBBBLRR +BFFFBBFRRL +BFBFFBFLRR +BBFBBBFLLL +BFFFBBFRLR +BFBBFBFLRL +FBBBBBFRRR +FBFFFBBRRR +BBFFFFBLRR +FBFBFBFLRL +BBFFBBBRLL +FFBBBFFLRR +FFBBBBFLRR +FBFBFBBRRL +BBFBFFBRRL +FBBBFFBLLL +BFBFFFFLLR +FFBFFBFLRR +BFBBFFFLLR +BBFBBFFLRR +BFFFFFFLLR +BBFFBFBRRL +FBBBFBBRLL +BFBBBFBLLR +BFBBFFBRLR +FBFBBBFRRR +BFBBBBBRRR +FFBBFBBRLR +FBBFBBFRLR +BFFBBFBRLR +FBFFFFFLLL +FBBFFBFRLL +FBBBBFFRRL +FBFBBBBLRL +FFFBBFBLRR +FFBFFBBLRR +FFBBBBBLRR +FBBFFBFRRR +FBBBFBFRRR +FBBFBBBLLR +BFFFFBFLLL +FFBFFFFRRL +BFBFFBBLRL +FFBFFFFRLR +FBFBFBFRLL +BBFBFBBRRL +FFBFBBFLLR +BFBBFFBLLR +FBFFBFFLLL +BFFBBFBRRR +FBFFFBBRLL +BBFBBFFRRR +FBFBBFBLRL +FBFBFBBLRL +FBFFBBFRRR +FBFFBBBLRL +FFBFBBBRRR +BFBBBFFLLR +FFBBFFFRRL +FFBBBBBRRL +FFBFFBBRLL +FFBBFBFLLR +FBBBFBFLLR +BFFFBFFRLL +FFBBBFBLRR +BFFBBBFRRR +BFBBFBBRRR +BBFBFFFRRR +FBBFFFBLRL +BBFBBBFLLR +BBFFFBBLRL +FBBFFFFLRR +BFFBFFFRRL +FFBFBBBRLL +BBFBBFBRLL +FBFFFBBLRR +BFBFBBFRLL +FBFBBBBRRL +FFFBBBFLLR +FBFFFFBRRR +FBBBBBBRLR +BBFBFBFRRR +BFBFFBFRLL +BFBBBFFLLL +BFBBBFBLLL +FBFFBFBLRL +FFBFFFFLLR +FBBBBBFLLL +BBFFBFBLLR +BBFBBBFLRR +BFFFFFFRRR +BFFBFFBRRR +BFFBBFFLLL +FFFBBBFLLL +BFFBBFFRRR +BBFBBBBRRL +FBFBBFFLRR +BFBFFBBLLR +BFBFFBBRRL +BFBBFFFLLL +BFBFFBBRRR +BFBBFBFRRL +FBFBFFFLLR +BFBFBFFLLR +BFBBBBFRRL +BFFFBFFLRR +FBBFBBBRRL +BBFFFBBRLL +FFBFBBBLRR +FFBBFFBRLL +FBBBFBFRRL +FFBFFFFLRL +BFFFBBBRLL +BFBBBFFRRR +FFBFFBBRRR +BFBFFFBLLR +FBFFFBFLLR +FBFBBFFRRL +FFBFFBBLLL +BBFBBBFLRL +BFBFBBFRRL +BFFFBFFLLL +FBBBFFFRLL +BBBFFFFLLR +BFFBFFBLRL +BBFFBBBLLL +BFFBFFBLLR +BBFFBBBLRL +FBBFFBBLLR +FFBFBBFRRR +FBFBBFBRRR +BFBFFBFRLR +BFBBBFBRLL +FFBBBBFLRL +BFFBFBFLLR +BFBBFFFRLL +BBFBFBBLRR +FBBFBFFLLL +FBBFFFFLRL +FBBBBFBRRL +FFBBBFFRLL +FBBFBFFRRL +FBBBFBFRLR +FBBBFFBLRR +BBFFBBBLRR +FBBFFBFLLL +FBFBBFFRLL +FFBFBFFRLL +BFBFBBBRRL +FBFBBBFRRL +FFBFBBBLLR +BFFBFFFRLR +FFBFBFFRRL +BBFFFFFLRL +FBFFBFFLRL +BBFFFBFLLL +BFFBBFBLRR +BFBBFBFLLR +FBFBFBFLRR +BBFFBBFRLL +BBFBFBFRLL +BBFFFBFRLR +BFFBFBFRRL +BFFBFBBLRL +FFFBBBFLRL +FBBBFFFRRL +FFBFBBFLRR +FBBFBFBRLR +FFFBBFFRRR +FBBBBBBLRL +BBFFBBFRRR +FFBFFBFLLL +BFFFBBFLRL +FBFBBBFLRR +BBFFBFBLLL +FBFFBBFRLR +BFFBFBBLLL +BFBBFFBLRR +FFBBBFFLLR +FBFBFFFRRL +BFBBFBBRLL +BBFBBFBLRR +FBBFFFFLLR +BFFFBBFRRR +BBFFFBFRRR +BBFBBFFLLL +BBFFBFBRLL +BBBFFFFRLR +BFFFFBFRLL +FFBBBFFRRL +BFFBBBFLRL +BBFBBBFRLL +FBFFFFBRLL +BFBFFBFLRL +FFBFFBBLRL +FBBBBBBLRR +BBFFFBFRLL +BFBFFBBRLR +BBFBFFBLLL +BFFFBFFRRR +FFBFFBFLRL +FBBFBFFLRR +BBFBFFBRRR +BBFBFFBLRL +FBBBBFBLRR +BBFFBBBRRR +BBFFBFFLLR +FBBBFFBRLL +BFBFFBBLLL +FBBFBBBLLL +FFBBFBBLRR +FBBBBFFLLL +BFBFBBFLRL +BFBBBFBRRL +BFBBBBFRLL +FFBBFFFRLR +BBFBBBFRLR +BFBBFBBRLR +FFFBBBBLLL +BFFFFFBLRL +FBFBFFBRLL +FBBFBBBRLL +FBBFBBFRLL +BFBFBBFLLR +FFBBFBFLRL +FBBBFFBRRL +FFBFFBFRRR +BBFFFFBRLL +FBBFFBFRRL +BBFFFFFRLR +FBFBFFBLRR +BFFBBFBRLL +BBFFFFFLRR +BBFFBBBRRL +BBFFBFFRLR +FFBBFFBLLR +FBBFFFBLRR +BFFBBBBRLL +FBFBFBBLRR +FBBFBFBRLL +FBBBFFFRRR +FBBFFBBRLL +FFBFFFFRLL +FFBBBFBLLL +FBFFBBBLRR +FFBBFFBRRR +FFFBBFBRRR +FBFBFFBRRR +FFBFFBFRLR +BFFFFFFLLL +FFBFFBFRRL +BFBFBFFLLL +BFFBBBBRRR +BFFBBFBRRL +BBFFBBBRLR +BBFFBFFRRR +BBFBFBFRLR +FFBBFBFLRR +FBFFBFBLRR +BBFBBBBRLL +BBFFFFFLLL +FBFFBFFLRR +BBBFFFBRRL +BFFBFFBRRL +BFBBBFBRRR +FFFBBFBRLL +BFFBBFBLLR +BFBBBBFRLR +BFFFFBFLRL +FBBFBFBRRR +BFFBFBBLRR +BBFBBFBLLL +FBFBFFBRLR +FFBBBBFRLL +BFBFFBBRLL +BBFBBBBRLR +FFFBBBBLRL +FFFBBFBLLR +BFBBFBFLRR +FFFBBFBLRL +FBBBBBFLLR +FBFFBFBRLL +BFBFBBBRLL +BFBBBBFRRR +FBBFBFBRRL +BBFFBBFRLR +FFFBBBBRLR +BFBFBBBLRR +FBBBBFBRLR +BBFBFBBLRL +FFBBBFFRLR +BFBBBFFLRR +FBFBBBBLRR +FBBFFFBRLR +BFFFFFBLRR +BFFBBBBRLR +FBBBFFFRLR +BBBFFFFLRR +BFBFBFBRRR +FFBFFBFRLL +BBFBFBFLRR +BFBBFBBLLR +FFBBBBBRLL +FFFBBBBLRR +FBBFBBFLRL +BFFFBFBLLL +BFBFFFFRLL +FBFFFBFLRL +BBFFFFFRRR +FBBFBBFLLL +FBBFBFFRLR +FFFBBFFLRR +BFBBFFFRRL +FBFFFBBRLR +BBFBFFFRLL +FBBFFBBRRL +BBBFFFFRLL +BFBBBBBRLL +FFFBBFFRRL +FBBFFFBLLR +BFFFBFFLLR +FFBFFBFLLR +FBBFFBBRRR +BFFFFFBRLL +BFFFBFFRRL +BBFBBBFRRR +BFFBFBFLRR +FBFBBFFRLR +BBFFFBFLRR +BBFBFBFLLR +BFFBBBFLLL +FBFBFBBLLR +FBBBBBBRLL +FBFBFFFLRL +FFBBFFBRLR +BBFBBFBRRL +BBFBBFBRLR +BFFBBFFLRR +BFFBFFFLRR +BFBFBFFRRL +BBFBBBBRRR +FBFFFFFLLR +BBFFBBFLLR +BFFFBBBRLR +FBBBBFFRLL +BBFBBFFRRL +BBFFBFFRLL +BFBFBFBLRL +BFBFFFBLLL +BBFBFFFRLR +FBBBFFFLRL +FFFBBBBLLR +FFBFFFFLRR +BBFBFBFRRL +FBFFBBBRLL +FBBBFBBLRL +BBBFFFFLLL +FFBFBBBRRL +FBFBFFBLLR +FBFFFFFLRL +BFBFBBBLRL +BFFBBFFRLR +BFBFFBBLRR +BFFBFBBRLR +FBBFBFBLRR +FFBBBFFLRL +BBFFBBFLRR +FBBBFBBRRR +BFFFBBBLLR +BFBFBBBRLR +BFFBFBFLLL +BBBFFFBRRR +BBBFFFBRLR +FBFBBFFLLL +BFFBBFFLLR +FFBBFFBLRR +FBBBBBFRLR +BFBBFFBRRL +FBBBFFFLRR +FBFFFFFRLL +FFBFFFBLLR +BFFBFFFRLL +BFBFBFBRLL +BFFFFBBLRR +FBBFFBBLRR +BFBBBFBLRL +BBFBFBBLLR +BFBBBFBLRR +FBFFFBFLLL +BFBBBBBLLR +BFBFFFBRLR +BFBFBBFLLL +BBBFFFFRRR +FBBFFBBRLR +BBBFFFFLRL +FBBFBBBRRR +FFBBFBFRRL +BFFFBBBRRR +FFBFBFFRRR +BBFBFFFLRR +FFBFBBBLRL +BFBFBFFRLR +FFBBFFFRRR +FBFFBFBLLL +FBFFBFBLLR +BBFBBFFLLR +BFBBBFFRLR +BFFFFBBLLL +BFFBFFBRLL +FBBFFFFRLL +FFBFBFBLRR +FBBBBFBLLL +BFBFBFBRLR +FBBFBBBLRL +BFBFFBFRRL +FBBFBFBLLL +BFFFBFBLRL +BBFFBFFLLL +BBFFFBFLRL +FFFBBBFRRL +FBBFFFBLLL +BFFFFFBLLR +FBBBBFBRLL +BFFFFBBRRR +BFFFFBBLRL +FBBFFBFRLR +BBFFFFBRRR +FBFFFFBLLL +FFBFBFBRLR +BFFFBBBLRL +BFFFFFFRLL +BFBFFBFLLR +BBFFFBBRLR +FBBBBFBLRL +FBBBBFBRRR +BFFBFFFLLL +BFFBBBFRLL +BFBFBBFRLR +BBFFBFBRLR +FBBBBBFLRR +BFBBFBFRLR +FFBBFBFRLR +BFFFFFBRRR +BFFBBFFLRL +FBFFBFFRRL +BFBBFFFLRL +FBFFFBBLRL +BFFFBFFRLR +BFFFBFBRRL +FBBBBBFLRL +BBFFBBFLLL +FFBBFBBLLL +FFBFBFFLLL +BBBFFFBLLL +BFBFBBBLLR +FBBFFBFLRL +FBBBBFFRRR +BFBBBBFLLR +FFBFFFFRRR +BBFFBBFLRL +FBFBFBBRLR +BFBBFFBLRL +FBFBFFBLLL +BBFFBFFLRL +FBFBFFFLRR +FFBFBFBLRL +BFFBFBBRRR +FFBFBBBRLR +BFBBFFFRLR +BFBFFFFRLR +FFFBBFFLLL +BFBFFFFLLL +FFBFFBBRLR +FFBFBFFLRR +BFFBBFFRLL +BBFFBBBLLR +BFBBBBBRRL +FBFBBBBRRR +FBBFFFFRRR +FFBBBFBRLR +FFBFBFBLLL +BFFBFFFLLR +FBFBFBFRRR +BFFBBBBLLL +BFFFFBBRLR +FBFBBFFLRL +FFBFBFFLRL +FBBBFFBLLR +FBBFBFFLRL +FFBFBBFLRL +BBBFFFFRRL +FFBBFBFLLL +FFBBBBFRRL +BBFFFFBLLL +FFBBFBFRRR +FBFFFFFLRR +BFFBBBBRRL +BFBBFBBRRL +BBFBFBBRLR +FFBFFFFLLL +FBBFBFBLLR +FBFBFFBLRL +BBFBFBBRRR +BFFBBFBLRL +FFBBBFFLLL +FBBBFFFLLL +BFFFBFBLLR +FFBBFFFLLL +BFFBFFBLRR +FFBBFFFLRR +BFFBFBBRLL +FFBFBFBLLR +FBBBBBBLLR +FBFFFFBRLR +BFBBBFFRLL +FFBBBBFRLR +FFBFFBBLLR +BBFFFFFLLR +FBFFFBFRLR +BFBFFFFRRL +FBFFFBBLLL +BBFFFBBLLL +BFFBFBFLRL +BBFFFBFRRL +FBFFBBBRRR +FBFFFBBLLR +FFFBBFBRRL +BBFBFFFLRL +BFBFFFBRRL +BFBBBFBRLR +BFFFBBBLRR +FBBFBFFLLR +FBFBBBBRLR +BBFBBBFRRL +FFFBBFBRLR +BFFBFFFLRL +FBBBBBBRRL +BFFBFFBLLL +BFFBBFFRRL +FBBFBBFLLR +BFFBBBBLLR +BFBBBFFLRL +BFBFFBFRRR +BBFFFBBRRL +BFBFBFFLRL +BFBBFFBRLL +BFFFFFFLRR +FFFBBBFLRR +FBBFFFFLLL +FFBBFFBRRL +BFBFFBFLLL +FBFBBBFLLR +FFBBBBBRLR +BBFBFFBRLL +FBFBBFBRRL +FBBFFBFLRR +BFFFFFBRLR +FBFBBFBLLR +FBBBFFFLLR +BFFFFBFRRL +FBFFFFFRRL +FBFBFFFRLR +FBFBBBFLLL +BBFBFFBLRR +BFBBBFFRRL +BFBBFBFRRR +BBFFFFFRLL +FBFBFBFRLR +FBBBBBFRLL +BBFFBFBLRL +BBFFBBFRRL +BFBFFFFLRR +FBFFBBBRRL +FFFBBFFRLR +BBFFBFFRRL +BBFBBFBLLR +FBBFFBFLLR +FBFFFFBLLR +FFBFBFBRRL +FBFFFFBLRR +BFFBFFFRRR +FFFBBBFRRR +BFBFBFBLRR +FBFBBBBLLR +BBFFFFBLRL +BFBBFBFLLL +FBBBFFBLRL +BBFBFFFRRL +BBBFFFBRLL +FBBFBBFLRR +FBFBFFFLLL +FBBFFFFRLR +BFFBBBFRRL +BBFFFBBRRR +FBBBFFBRLR +FFBFFFBRRL +BFFFFFBLLL +FBFFFBFRLL +BBFFBFBRRR +BFFFFBFLRR +FFBBBBFLLR +BFBFBBFLRR +FBFBFBBLLL +BFFFBFBLRR +BBFBBFBRRR +BFBBFBBLRL +BBFBFBBLLL +FBBBFBFLRL +BFFFBBFRLL +FBBBBBFRRL +BFFBFFBRLR +BFFBBBBLRR +FFFBBFBLLL +BFBBBBFLRL +FBBBFBFLRR +FBFFFBFLRR +BFBFFFBRRR +FBFFBFFLLR +BFBFBFFRRR +BFFBFBFRLR +FBFFFFBRRL +BFFFBFBRLL +FBBBFBBLRR +BFBBFFBRRR +BFBFFFFRRR +BFFBFBFRRR +FFBBFFBLRL +BFBBBBFLRR +FBFFBBBLLR +FBFBBFFLLR +FBFFFBFRRR +FBFBBBBLLL +BFBBFBBLRR +BFBFFFBLRL +BFFBBFBLLL +FBFFBBFLLR +BBFBFFFLLR +BBFFFFFRRL +FBFBBFFRRR +BFFFBFFLRL +FBFBFBFLLR +BFFFFFFRLR +FFBBBBFRRR +BBFBFBFLRL +FBBBFFBRRR +FBFFBFFRRR +FBBBBFBLLR +BBBFFFBLLR +FBFFBFBRRL +FBBBFBBRLR +FBFFBBFRLL +BBBFFFBLRR +BFFFBBFLLR +FBFFBFFRLL +FFBBBBFLLL +FFBBBFBRRR +BBFBBFFRLR +FBBBFBBLLR +FBBFBFFRRR +BFBBFBFRLL +FFFBBBBRRL +FBFBFFBRRL diff --git a/day-5/src/main.rs b/day-5/src/main.rs new file mode 100644 index 0000000..62208ce --- /dev/null +++ b/day-5/src/main.rs @@ -0,0 +1,94 @@ +use std::fs; + +type SeatCode = [char; 10]; + +fn main() -> Result<(), Box<dyn std::error::Error>> { + let input = fs::read_to_string("input")?; + + // Part 1 + let max_id: Result<usize, String> = input + .lines() + .map(|code| { + let (row, col) = find_seat(parse_seatcode(code)?); + Ok(row * 8 + col) + }) + .max() + .ok_or("No seat codes set")?; + + println!("{}", max_id?); + + Ok(()) +} + +fn parse_seatcode(input: &str) -> Result<SeatCode, String> { + let mut output = ['0'; 10]; + + for (i, c) in input.chars().enumerate() { + if i > 10 { + Err(format!("Seat code too long: '{}'", input))?; + } + + if !['F', 'B', 'L', 'R'].iter().any(|valid| &c != valid) { + Err(format!("Invalid character in seat code: '{}'", input))?; + } + + output[i] = c; + } + + Ok(output) +} + +fn find_seat(code: SeatCode) -> (usize, usize) { + let midpoint = |(start, end): (usize, usize)| (start + end) / 2; + let binary_follow = |range: (usize, usize), direction: &char| match direction { + 'F' | 'L' => (range.0, midpoint(range)), + 'B' | 'R' => (midpoint(range) + 1, range.1), + _ => unreachable!("We already checked all characters are valid"), + }; + + let row = code[..7].iter().fold((0, 127), binary_follow).0; + let col = code[7..].iter().fold((0, 7), binary_follow).0; + + (row, col) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_simple() -> Result<(), Box<dyn std::error::Error>> { + let input = "FBFBBFFRLR"; + let seat = find_seat(parse_seatcode(input)?); + + assert_eq!(seat, (44, 5)); + Ok(()) + } + + #[test] + fn test_simple2() -> Result<(), Box<dyn std::error::Error>> { + let input = "BFFFBBFRRR"; + let seat = find_seat(parse_seatcode(input)?); + + assert_eq!(seat, (70, 7)); + Ok(()) + } + + #[test] + fn test_simple3() -> Result<(), Box<dyn std::error::Error>> { + let input = "FFFBBBFRRR"; + let seat = find_seat(parse_seatcode(input)?); + + assert_eq!(seat, (14, 7)); + Ok(()) + } + + #[test] + fn test_simple4() -> Result<(), Box<dyn std::error::Error>> { + let input = "BBFFBBFRLL"; + let seat = find_seat(parse_seatcode(input)?); + + assert_eq!(seat, (102, 4)); + Ok(()) + } +} From 361285e23de7cb623ee225c7a6c07c835c17a4af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= <tm@tlater.net> Date: Sat, 5 Dec 2020 21:11:41 +0000 Subject: [PATCH 6/8] Complete day 5.2 --- day-5/src/main.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/day-5/src/main.rs b/day-5/src/main.rs index 62208ce..81f9d27 100644 --- a/day-5/src/main.rs +++ b/day-5/src/main.rs @@ -17,6 +17,26 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { println!("{}", max_id?); + // Part 2 + let mut ids = input + .lines() + .map(|code| { + let (row, col) = find_seat(parse_seatcode(code)?); + Ok(row * 8 + col) + }) + .collect::<Result<Vec<usize>, String>>()?; + ids.sort(); + + let mut previous = ids[0]; + for id in &ids[1..] { + if id - 1 != previous { + println!("{}", id); + break; + } else { + previous = *id; + } + } + Ok(()) } From cc2bc308c3774b0f15f86d524fd92342f6827e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= <tm@tlater.net> Date: Sun, 6 Dec 2020 21:00:40 +0000 Subject: [PATCH 7/8] Complete day 6 --- day-6/.gitignore | 1 + day-6/Cargo.lock | 78 ++ day-6/Cargo.toml | 10 + day-6/input | 2087 +++++++++++++++++++++++++++++++++++++++++++++ day-6/src/main.rs | 137 +++ 5 files changed, 2313 insertions(+) create mode 100644 day-6/.gitignore create mode 100644 day-6/Cargo.lock create mode 100644 day-6/Cargo.toml create mode 100644 day-6/input create mode 100644 day-6/src/main.rs diff --git a/day-6/.gitignore b/day-6/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/day-6/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/day-6/Cargo.lock b/day-6/Cargo.lock new file mode 100644 index 0000000..e508f5f --- /dev/null +++ b/day-6/Cargo.lock @@ -0,0 +1,78 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "day-6" +version = "0.1.0" +dependencies = [ + "indoc", +] + +[[package]] +name = "indoc" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47741a8bc60fb26eb8d6e0238bbb26d8575ff623fdc97b1a2c00c050b9684ed8" +dependencies = [ + "indoc-impl", + "proc-macro-hack", +] + +[[package]] +name = "indoc-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce046d161f000fffde5f432a0d034d0341dc152643b2598ed5bfce44c4f3a8f0" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", + "unindent", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "1.0.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8833e20724c24de12bbaba5ad230ea61c3eafb05b881c7c9d3cfe8638b187e68" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "unindent" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f14ee04d9415b52b3aeab06258a3f07093182b88ba0f9b8d203f211a7a7d41c7" diff --git a/day-6/Cargo.toml b/day-6/Cargo.toml new file mode 100644 index 0000000..a253da5 --- /dev/null +++ b/day-6/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "day-6" +version = "0.1.0" +authors = ["Tristan Daniël Maat <tm@tlater.net>"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +indoc = "0.3" diff --git a/day-6/input b/day-6/input new file mode 100644 index 0000000..9745c0b --- /dev/null +++ b/day-6/input @@ -0,0 +1,2087 @@ +v +vx +v +vx +nclmbv + +odgpnwqxhbits +pqwsnxihogdbt +pogiwxdhqbsnt + +q +o + +apulnqresohvktxcymzibdwg +sigdvakmlyxhetopnubwzrqc +iushndtclbeyowxpqmkgzavr + +ow +wo + +phegq +eqgph +hgpque + +xispjzq +sqkzcupi +ikspqyzue + +hgfesyvn +dnsvtkhglea +heygnqbcvs + +qmrpy +pmrck +vcprum +mrkcp +mrp + +kgjx +jghk +kjgu +enlgdwzqkjr +vjgk + +ungsdozkphlxy +nbkgzaifsovjpdt +geoskuyznpcd + +qw +qw + +x +r +sl +v +s + +kxcn +kxn +wxtkn +xkcn +xkn + +peionmzqyda +apdinomqzey +npmqoiedzay +dmpzoyqiane + +gpaedw +mwda +daw +awbd + +fyxeptlrmisjhdzquv +xfqydzruvmjepsilth +sipulvdzmftqeyhrxj + +kzofrcamenxyvwgpq +zqkrapxwomvycgnef +ywxvpazgcenrqkfmo +kgcvezmfqwrpnxaoy + +zhf +zegfhd +fhz +hfz + +iqspn +bytmd +sq +gwx + +begosk +gnbskz +sgkb + +ok +ek +ek +k + +hbucsatqvdryfojxlz +tufzxjvbrwasemg + +d +ef +k + +p +mrp + +kuywroetvjnf +wjvtkreufyn +frkyjwevntu +frtewnkjvuy + +iu +wzi +axbcgpldyi +seoiz + +ekjmbsuwglftpvya +esmwuftgpvyjalkb +vflbtyekmjupasgw +tepmwgksulybavjf +psawvbtgjfelmyuk + +jsmoydnvkiql +lqdojsvnik + +ayrtxivjlpeuzohnk +whjitnkfyealoguxprzc +bzjiruohtlakxnedypm +pmyxeizqjhkntoarul + +vnrcwouidfb +bufrwnociv +unrvefbcwo +cvnswubfro + +hmnoazwvtcrigqsujldpk +qeflzdwyongvtjishpacumr + +ytwpgkvceaolhrz +agyepkhwlzvctr +yvpkwcgerzhtaq +pcaeygktzwhrv +rgvpkwtylzhcea + +io +oi +io +ito + +ckmfawyb +glvfiymobadc +jnsfbmapcy +jfysmathnbc + +uxbfdygqwpom +sxmuwbdporyvqh +rbuqmwxydpo +ncpuyowqildjxebmk +wxuysoqhvbampd + +keo +oz +jdorxbia +lo +ok + +zk +zco + +bhwmscnrqeou +rlqenzswohbmu + +synmfzljkdebq +cmdyzlfekjbns +nkgzsmvlydpjobfute +lsfjkmnzdeby + +xshlzwcndtjefi +wcnljfditsexzh +ehtsjwidflcznx + +zry +vyqz + +owfcybsdipnqlthavu +psdiqfhwctrzvaybon +ybmpdciqhvtsfawon +givjcetkhwbdyponfsaq +cvotsnhqfywplidab + +cibwptjnu +ncruhi +hnuic + +apzjqbdlwyicfgxv +apxodvwlzyfbgqcij +pcdxjvzwqfliyagb +rixjaclsdpvyzgwqmbfe + +timpsox +poxsm + +fres +refs +fersq + +w +z +r +w +r + +xz +x +x +x + +ciyhkpjswqvxz +xyskvphmowjzcia +kywsxihpc +wtpnflcsekhbgxud + +qrtweigjlbucfxnkos +iwlbgmnosuxfetkrqc +sfbwxcotierqukldn +euroqfdxywclsitkbn +qelfbarchnwuxtsiok + +gj +woh +g +jr + +lpcdqf +qdfupwzcl +dpcqgtl + +zlnkeyroq +rtyoleqnkz +leykztqnor +ahoukcelrxjqynpz + +twxjdbuhclzgnop +fgeqkcbvziwtludop + +ylukhwtcf +aikdrxfov + +ucbklojiyxmz +ulkjco +kroljuch + +rfhyj +fhy + +cmtedvxioy +infmacweshtuo +tpoimecz + +kylduhw +yublkhd +kdulyh +dyuhlrk +zhfgkudly + +laoemdcgpyhtnb +ygclebodtmpnha +zomgnqpalhebxwtcd + +bmogrnztvyil +vlotrzngbmiy +lvyogrzbimtn + +zjcgheblotdramsn +mlgbshrzotcnjawd +otgsjdnmbrchlza +dbazlpfkhgtmsvocnjqr +sgrazcjondmlhbt + +ryhifaxpemsgcdubvtjzwnol +bduiojqhcsvlyrxefntpgwma +pvebfwitculrgyjshkdxmaon + +lqmopgwbesjhk +mgbkhqejlswop +wqklaeogsdxhfbmjp +sjgphokmqewlb +kesrghbmpjlowq + +tu +rp +r +rgh + +tfeyhjbnpaqwz +rxuefvgiaybzqth + +pwx +lk +iahyv +jr +p + +ezsghqtdnjbfox +dsucq +sduqp +cusvdqy +dslwqm + +dm +gf +g +xtg + +mfihn +mhyifot + +iabeswqrzlcxvkpmtnug +qexctgrkwbpusazinmv +riztmgqsewunxbapkcvj +avbuxqizmrkeswtpncg + +ozrwipdmgajlkfuxcnhtyveqs +fntcigalzdxmyuesjkqwo +dtfyeqklgjmwxunosizca +efclkowaujqzigbtymdxsn + +jkiupmatwxqhdrs +midjhwutq +dmhujzqwyit +dwuqhymtji + +ziqfh +hnboqe +qhktzdfp + +qohbywgtlucajf +ltahuywfjbmc + +arfpqdcbtnw +kfzonycewxbghvr + +tdxqelwnu +luenxdtqw +udlteqxnw +wxendqlut + +pvkrgaushqidfmnjz +eajzrkhndfitsqvmwugyp +sgohxqcvrzunapjfdmki +vinodpkazgfrmcushjq +jmufirnszpdqoahgkv + +uvcmgfrk +fugmrvck +kfuvrmcg +cmrfgkuv +kcvumfgr + +kmrb +krbm +rkb +bekrt +rbmk + +mzbrfsnxgjpywavcohuqlkitde +xpekistdzlrgmcawnvuqfohjby + +vrjew +rvj + +qlefnd +fdleo +pxcehwdfy + +amftbpvo + +ljcyn +cynosjum +jync +yrqbwjzc +jcy + +tmdcuk +ckudm +mucdk +cdkum + +icsvhmefaztoxkgndq +sbyqivkrdplwjemou + +jtrhafpkbwzdox +hbrwpzajokfx +jbkfaphxzcrwon + +bqg +qgb +bgq +qbg +qgb + +ljte +jle + +tvhjx +hvjwxrt +vtjxh +dtjvhx +vjxht + +zsdejcrvab +kbjzrscaedv + +oehivmku +igfhuxozy + +x +xs +x +x +x + +klqnrzftv +iqgfaupt +fdqgswyjt + +opjeslcx +psohecjxl +yxelsjoc +lescojvx +molnextcsj + +sf +cps +fos + +crxbjzkivydsgfpehmq +wnhfgljeptzrmikcy + +bghydvqxicsfunlzpart +rsyugqcxtvdzanpblihf + +v +gnvw +lv +v +lv + +mpzvdjqhxnuocr +chidrnuvxmkjqpt +suhdxgvbcnrpmj + +ewpfugobznrqydsj +ivgxtjludcm + +enytuvzoqmljfwd +satbgwcrndzyk + +fuzl +ful +lu +lpuxy + +qrhltkesazpmo +puaedmzsqhot + +vcktz +zqtjsbuiaomwf +ygzkthx + +zt +tdz + +fvpjlcarqdukio +luotiqzkjfrwahcdvm +rcykufoadqxilvj + +kfpuwxi +wpfxuik + +xjzpf +cyqsouwf +xzf +zf +bifpj + +q +cw +n +nu +q + +lscdtzvhajkqpm +vdpklhqscm +pvcdqskljh +hcjdqklsyvp +eqshcdklvp + +muyldxobakfq +ecjvfm + +jkas +ws +s +ws + +qbjzcolnuy +jyulobzncq +izqlnycoubj + +yvsoztedn +eotvydz +yzetodv +edvoyczt + +tcfqkxrib +fozbtnlwucq +qvagfdebtc +qcpftbk + +amlcyk +acempy +aymcv +cayml + +gsybwf +ybsfgw +bsgywf +bfwygs +fsygbw + +hypxicwobt +pciytbxwh +xhycspitbw +pcibytrhxw +yckhxtebwpi + +olneqtcpzfiahbj +oitbqejcahpnfmzl +bpnjyhfkqmlczteoai +hlpjefoaqznbtci +jdwtzsfcviaqnobhpxel + +mkflqourwyh +kqmylohfu +lyohqumfk +fyhukomplq + +cfegzaprw +prvbgiymj + +besuka +hsnkua +slaguxky + +smwuovdpnjfyl +mcjvguors +qjvsmiou +abotmkxujvs +uhmoqsvje + +udrmcxqay +dqyhumca +mfwcujskglbedqt + +xewpyrsjzktgbaochuni +xjaohuwligysztekpnc +tfghodxyjsnapmquwcziekv + +fxypwlo +wpsxleyfo +ylmpxfzwo + +ok +rspbkt +mauyxcw +rqdkz + +fsehripoyjawt +styheviwfrn + +onxrvplyuzqcj +vlzuyrcpxoqjn +nuoqyrzjcpvxl +ljyuoqvnzprcx + +o +ac +c +c + +hwxmesjuzo +hylvoxzpfbntsr +shoquzx + +pidfxg +igrxm + +gshkfbcujpyztoevxdlmaw +kzvmejbygdpaxufhlcotws +hfgamkstbwjoyxlczupevd + +p +p +ltf + +iufdzosnagkhtw +dzkhlgvsitucoa +adtgzokhsviuc + +jywe +wy +yw +wzy +yw + +ghvadykiscnfxo +noxckgivyhdaf +gfxmtodbwvnkhipaqy + +ifsp +xnivluaq +fioe +wisydc +siw + +jxbmclnevwztqug +keptqcrmzufglhi +tleqgyvjbumzdc +xzdmslqcutge + +ogdxpnjbti +ipgnotx +ipehgonkcxrtfa +ntdiygpox + +wxhcjtredknifvulymp +vgksmwqzctybidjofha + +lxmficysbt +jslmrn + +pcoxigrdtkul +sjmhtbxulyord +uxlcpdktoarv + +crgundohktjfasebzvxl +gdsvcufrnljazotkxehb +onbgcjfeirxkhzvudtsla +njcheafbokgzvsxrudlt +ekgvfruchstjldoxzabn + +wmkivpgfqdrsl +wmcjvofkhnz +kfwbuvam +jtmwhfkvz + +thy +hy +yhe +yh +dqbyh + +xtbhkovsjcga +xqkoeavjsch +xacvkjhds +mcjuwskavnrixyh + +lhfwqr +ypkruwqs +xcgdwmj + +eyiwrundqsflgcavxk +fejmwtyulodkhrzbp + +yvz +expa + +aohj +ejoai +ldypfnejoa +dcxpjoatv + +vuinj +prv +v +vlr + +sqpdmrnlwa +nlgasrpqomd +padlqsmrn + +r +pjd +d +azbhs + +hfotieypnlwdkjzv +jlfveimtdckongwzpy + +af +zaf +afn +abf + +csjx +scrk +ucws +csj +sjc + +juwtder +dtjrwe +werjdt +djreywut +rceoqjwdt + +nazufjeomxpkc +xmeopajcunkzf +pfcuazejknmxo +nkzceomfapxju + +epiykxforjz +fylzbxjeoipg +ahfyxvpmsujiedzon +eoyxcqwpikjzfg + +umfrlqhakzdn +mshjfdkqungrzv + +opxjdgemsvailruzfbcq +ozmgbdirxelyfsqpjvuc +iqbucpflxsvzdoetjrm +ysiqolmberzvjnctdxgufp +bxfemdhcukplzrijsqvo + +yocg +g +uqg +rzy +vjbmw + +vljzumo +ujzvmo +vujomz +vjzomu +zmjuov + +srwagukx +ahjroqmxy + +cgkj +jcgknvs +jgkyc +kcjgy +jrgck + +ugcwvx +gfuzaxw + +n +o +n +n +n + +vsmd +mcdvbs +cdmxy +tadr + +znsokugwejfylica +iwpnfyolqzkcuaegdsj + +azuver +remzau +arezu +zerau + +wevbmlq +bwalcodevx +ewtuxlbv +zivypeswlb +ebwvaln + +qjrdgxmc +hrcozqdxj + +mpcogjzyrhisuxlv +mskpazxdfvqc + +xtzyl +lxyt +xytl +xlyt +oxslyt + +jrteqswkcazlbfhog +tsqafcbgrelzokhjw + +fjqlibpwukcoznavyrtd +bzdtupklrqivanwyojfc +lvjarpkyubndzqiwoftc +bdrcniwvktylpajoqzuf +uycprvalqdiwonbjztkf + +lwga +dgswz +zgwy +nwugcrik +gwsy + +gwmvxakicou +avugcmowixk +ckxugomwvia +ukwacxogmiv +xiwavcgmkou + +znvgeymhb +rztconyiq +lwzayn +jswnuzyk +fnwuxlypz + +etkdwlgscmzyuafvhbo +vhctfgkmwouaylesbzd +vfcetldzsyobghmuwka +tsgzmkufeajlvwcyodbh +gazdhmkotswlfuvbcey + +zdsjweg +sezjgd +dsgzei + +zi +z + +tbg +fbtg + +g +g +g +g + +rid +jvi +inxo +id + +dbrjtfupcyvzlqmwei +zqbwfmljvcdirtyepu + +jmhubvclsdprw +cpswbmldjrveu +rpbsvucmdfjlw + +qk +ekniz + +kvlmhegzcryd +zrlmdgvefyhc +zhgvrqueymdca +remdfyhzcgv + +zxhiaqs +hxiqsa + +sumrbd +qgrbuw +ubqgr + +dkmqsebjznylwucxot +ewyqhjrlpcfotbis + +ti +kxi + +dvgmlyepfnhscui +isbvmudynplf +nzqldwmfyuvtpi +finlydpourvme +dulnypvsrafmik + +zemctnsralu +trnaelzmsuc +azrstumnecl +mltrceasnuz +rtazlucenms + +aydgxnwehomujpv +nedjuaxhopwvmg +dvgwhfojpanmuxe +wjaenpdvmohugx +vanuomdxjehgwp + +xchjblnwmogv +coxlngbwjmhv +mjbwoclgxvnh + +br +rohb + +knpclsvozb +slcvbznk +klcbnvzs +lsvbkncz + +cehpgtzmawkjndufrlixb +anrtxfdbhiwmcjzplkeug +rkmwtcunzxhjpgbafdeil + +rqlstcwxkmoz +thsvxzkueymrlqw +rqlskomwzpaxt +wcxrzmptqkls + +tshv +hfzdlpij +hmces + +kfjmaedcoqltuwp +jrngliqdohsce +bgclzdhjqxyero + +urndaqxz +fyw +wzqua +ehglomjvbk + +guhfvqlnkydpiz +ljgyoiqarzksuwet + +yutebcorzh +slxcdkqnhjga + +fivxqukh +kixqzvu +vqxuki +xnpiuqvk +kvqfxudie + +rpsfdkmc +cdefrksmp +khmsfrdpc +pdmkrcfs + +hwn +whn + +rxhbzyedclofgwmuktsp +xlmozsbgkcfeyurthdw +psgtkcfazdwomblhyerxu +ytvfsxukgwmlrzdhobec + +nrvyx +vytxn +xyvn +nxvy +xnyv + +qct +cqt +tcq + +y +dy +lcwtunshbmy +fy +ry + +cnboedgyxatrk +ktdbeocgnay +wbkgtecnyahmodq +nxbtgzcsyeukrado +ydagcekbfont + +jytulh +yhtlz +fwtrkhly +bylht + +huigqrok +ikhrong +bighkwor +kgxrhosi + +zbkrpelxtsohdaw +ewzkvcxrdtboas +rabkdwoxyneszt +axhkbzrwdteos +rtbowkelsxzad + +aonplewqryh +euyqrfncsovkld +byalnwiezroq +enobxrlqy +pmgzeryonql + +akxpsmecuj +kfgsexjm +oxqfeskjm +yervixmdktlshbj + +r +r +r +r +r + +rdghefnubpzkma +dhubafromtpekzgn +knmhfjduebpgraz +zpekdbfamrnihug + +ybcgsmlwhovidfezp +omfpzqugycwrhbs + +x +x + +vjahspyncxzmie +zmpu +krpmzog +tfpmkz + +morafxw +xyckafoqwjm +ialpowmf +xhrsmwokbfjazu +anmfowdbq + +gdpblscxazjrmikoyth +exrolqfahdbymcwpksjt +gtmadncysrlhpojvxkib + +nxdilkwregfbaoqp +exnjrbsifwypkqovag +fgrotinqbwpkxae +flndzeoxkwgrcptibqa + +sidjln +mjslodni +ztdoxjnise +odnsehfjti +dnsyij + +qx +wmxtj +wxzmtucqy +godkvenhxpb +xrztj + +xofhvkjytqus +ytdqjkufimvx +uwyqntcvfpxkj + +rdtqukinob +wzufpcolmskynvteh + +vnab +kouvrfe +ljvcd +wqbdpvsy +bighvnmx + +frgsavwjel +fjlrwsaveg +afeljgrwsv +jlvsrewafg +kvfesjlwgra + +ygdszflehmwcnbopiatxju +jdnupgzmilsywaechoft + +da +rzfvailh +bhorq +ctgujpmsw + +ymbnzldsi +ltvsfm +mgcsl +emslgw + +taqecxvdypifblzgk +cekxfvgplrnqbty +vejogtfwqbyknlrpxc + +souwzdkcbqf +awzqgvbscukdpxn +bcszjdfkuimwq +sdbcuzqkw + +avrlf +kerlgmuahvc +wavfibznrol + +upnkam +xmjt +milex + +rxotufwczkpvia +pajkvhwtme +gpnektwljasv +pknaqwtvey +wpadktnlvjb + +kpfj +syurwad +asyvld + +p +bpz +po + +s +u +s + +ksvbeno +uyfivq +kbjodvh +czptrmawg + +xtiqze +xtisdz + +pylbdvkncjurmgh +yhbdoltvrpiknmjucg +vbmlhynrcugjpdk + +byoavnixtlzepjds +sapxunqeizdvblyho +qvlmeoisanzyhdxpb + +ifykcw +iyckw + +u +p +s +s + +f +f +f +f + +fvbjxaiklos +ufqnvcgxikdpalobt +bixlarfkvo + +ygpsxce +cpdsfygaxueb +ycgsxep +epcxsgty +pctxesgy + +meawzoqnidgh +hodmagqnzew +mwhzndaqgjoe +cdhseoqauwngzmx +oawmeqfdnhzg + +yrlvejxocsh +hvjrsmloyne +nsrvyojlhe + +zhufxvrkcdmwqlsa +lergvwdqnaosxtzchukbj + +xbvyt +ybvndgxt +gzxtonyb +xbcuwtyp + +creoxajkgvq +vgljkrexacwmhq + +wckjovuftgmb +boktfjuvgmwc + +cguaojyvre +ohiknuqags +lcazjyguor + +inhyfk +kify + +uhtqci +tfoqacim +srvcjytkqgx +hqctz +qmctahizn + +vekplqxuhrm +kmeuprlvqxh +vhlrkmpxuqe + +at +tagexyi +mpt +yxta + +uezmyjqvbgspirlc +fydbljgwmzxquecop +zptrgeybcqmluj +pelzjcugymtbvq + +fakguojpbsic +ubcfgyjakpiso +bliusctfvkampjog +fybsicjawkupog + +kmxerqlautij +zxidayte + +imbngcehtvs +oipfmkrqusnwxdzyl +imasjvn + +pek +e +ei +ep +ex + +yuw +uyw +wdysu + +omikta +zjvatmw +txsma +cm +lndgqmry + +cwazbkolvys +liyoveacbswj +siwokbavleyc +rocsyndufablvwx +aylbvcojesw + +nazfjsrouhgtv +zgsprothnufav + +ptmshxwqk +sebqodwi +euqsw +zwousq + +uqltjsikhpvefdawycbzg +plyhvtieubakzswqcfjgd +wehjvikyfpcsgaqtlbuzd +sfibzvquyljekgthpwcda +cgbtvdolizaeqypfksxjuhw + +izeqstg +sgiqzet + +fqbmpoxscydhrtljzga +cfqodxevmajhbrplzt +oecfrzvbpdaqhtjlxm +adfbxrmqlctzpjho + +dsmewbhpvrfuknj +opcvhwtrqkue +rwvkguhpzoe +vxpghreuiwqk + +fjzi +ftmizn + +xumjz +ujxymg +zumjx +ujmx + +n +l +l +x + +ghwfslriojz +rfzliwoe +flrziobw +ifcpozlrw + +smvfnglxaeczqwukojhbi +uieagsoqbhvlmjcfxwknz +nxoacfwemhijsgqvzbkul +qanmsiwvflcjbxzoeugkh + +pzciwneljbghoufdvymtqar +exlhrjvkpnmdoqbtzusiwcgf + +uxjwpobgcflndqairke +oktwumrzjlyedagxbinsfp + +oibhmyeguqkxjrcpawzfvds +vhsauyxdrobwcjmkzqepgif +gxhiwozfkbsecamrypudvjq +mxywofehvsczapkbuidqjgr +xsmvybwqdgrzeucfahpojik + +gdtlkuomn +ytkueoglh + +xgimja +gjxibma +mjbagix +xaiojmg +mgjaxi + +sgnfdiz +dto + +yhkvqrzw +hyknjrzvq +xtrhdsvkzoqy +ykqvzhr +zkqyhanegrv + +tzqrhavysuodmjp +abvpofyzhmrjqdt +yzopriuqnvmtahjd +atmryjpzhovqgd + +cyljrwofasq +afoqswrjclu +carljswfkoq +ljwsfocqyra +xjolqcwfars + +r +o +ak +xdje + +lfyjxpoeau +yhlgcftszpr +pkylfomw + +lunijqekwg +vafgdsjqeklniw +yeglwqkjin +leqgjkniyw + +mpvlijnfbz +jzmfbplnvih +jqdlpvbmnzif + +tk +tk +qkst +kt +tk + +mdowpcnxgbvuytqezljsk +tbnzcduipewvxlkqrsmjyga + +ilumzjpqotcv +fgtmowyx +gdsotkrm + +yncslevbgrqmizwu +brclynqgzvuewisfm +lgbzcesuvqnrwmyi + +bjmzopcdiqlyueh +olyupebiqcmzjhd + +eubsjrvwmyinzkaqdgcf +icqzjksbyregauvfdwnm +jugdnbsczwqfarvkyiem +benyrimfwzaqvukdscjg +ndcuvaziekbwyjrqgsfm + +g +c +c + +gvyfqupnxtswb +uvtykbjxgifcqz +lhvobuxgqfetmy + +dpzgaulb +plqugbrdmac + +htr +kgrt +rt +tr +trg + +o +qv +lr +m +l + +qotxnerijpfbkcagylh +nilhcfrpkjgboxaqey +ognqxipefrbjhlkacy +kojtilqxyrhbpancgfe +qjilgekcfsnhxapomrby + +fes +feoijn +ef +ef +ef + +dlzga +tlsidg +gdl +lpdgh + +onysxwkqlcgdemhup +mzlscwgkdnouexyp +kzdubeoyslgnpcxm +dymulpowksnegxc +kpusvxldgyaonemrci + +xh +e + +utbirhymae +yzehmoukq + +ijvulcmbrgkyxao +uvrajglcbomkxiy + +xo +zo +o +xo +o + +mbghatcenlifqjdkp +ejscikpgvtomhnxqzf + +stpvo +cjvpthsl +spvdnyrt +qvypftsx + +obrxaqyudvinmk +qlimnvosubahydgkecrx +yrftzoxkjqvbaidm +kvqaxdmboirwy + +dxj +xdj +jxd +jxd +djx + +hfjeucmkrvnwxs +nxujekrqmsbofhc + +ezarol +lebz +bzel + +jgmzcl +jlzcmg +cmlzjg +jmclzg +gmcjzl + +o +u + +bdfqljiuacptzvgrxoe +pauvztlihdqrjofgx +xtrjvzuaipfldgoq +jzrdtxqlwiavungfpo + +cjurgpeyvlzhafx +aurhsfbvpeyxgjzc +gzvhejlkpxyfocura + +rvyfbicazduolwtgqk +qklnrgyaofdzvciwut + +qsw +qs + +nrfgxpujobhk +rxmpnokdgbjfi +lxbngkrfyjvcoz + +e +e +zegkx +e +e + +kon +k +k + +ekvi +iekv +ekvi +ivek + +jfbyxwhrne +nxjhrfbdwy +bewhryfjtnx +mfhoxyjbrsnw + +bn +n +sxv +d + +egrzknhbxfvqtdcu +edhrioxvjgnzbf + +yjoskmhw +kdtqfehazbyu + +zq +zq +qz +uqz + +ilbpcz +ibcqplz +gczbpil + +nikychwgab +caibgwklndy +ckbenqwuafyg + +qubikjdz +jkiuzdb + +gwmavrpfsdnkyizuelt +yuqnvjmlogpizcfetx + +tnsf +thnfs +tfsn +sntf +nstf + +vflagunhs +aiwvlhjfsunxg +ulvhgfsna + +yajtfdwh +hzdpalftjb + +nazpqismug +pznuismgq +mgiqnupwsz +mgptzusniq +boifzpmsuqgn + +ohu +ht +hpygo +ijkdfhcb +uhno + +kfzmrhyjvw +hzgxpjbkwvyr +zykmfrvwshj + +yqsezgcojbw +zjsgcoeqby +jgfsbozqyec +czsgoyfbjqe + +fjywktd +yjktfwd + +nwvrodtpqy +xtrvnosihzgq + +gdwcmlxiqtynsjozapeur +xwlgsjatqzycnodprmue +adxtgqujrcopnlwsmezy + +snep +shwz + +unvpgc +guncvp + +suctpbxogra +kcxvgteayu +ztgxuacy + +pewbhlvjtg +omskldnz +iafryucxq + +zoucjefxpdta +xbfijrelpucsot +ktoexjpcauf +jtezoxkpfhcduw + +xiaszncr +asxnircz +xzncrsai +rixseuzanc +nzaicrsx + +owtvxqcizrapl +alqxivcprzowt + +ltrhdykufvwex +ekxvfldwuhrt +ervktduwlhfjax + +ylvgpjthiex +snmbgjfzduxqearikc + +eml +bkhyl +rzsoitwqn +dacupjev +fldc + +uqigoj +ojui + +zgbsumeycaxvontwdkij +jbtelqcxnumsoakiwyvg +waseyvijugnkobptcmx +atesbkmjuhcvfngxywoi + +pc +pc +ikyp + +xtgvlenosarwubmfihz +txganvweourhbqslfmiz +lientrsuwghobfmvxaz +taluorneizhswmbxgvf +zginuholscexmftrbwva + +xjkv +xtouw +tywx +oxwt + +zk +cz +bz + +qcp +qpc + +ogptyeunzsqmarjc +jrvlopzynes +xoszpnjryle +zbrnypsoej + +nuigyflbxs +yxunspgj +vnuscztymqowgxr +ixnyshgu + +pdn +cyskxdp + +ewlkgbdxqtiz +eqgxitldbzkw +kbdexzgitwql + +c +p +t +v +gqh + +uvigbjqk +ibvugq +vbuiqg + +wzdca +dzawc +cawzyd + +mfaigwlu +pygxjmufwal +ugfwlam +glmafuw + +bewfkxsvl +yxdqnmaturov + +fdrbt +mxjnfdqpc +wdltfo +adwletfr + +t +pgo +e +tiabc + +zbthk +zbkhatr +zbhtk + +flxwhbzkei +lwkhxfezbi +xelfwbzhik +bhzefxkliw +klizhwbfxe + +btmwkoqs +bstomkqw +wskomtbqi +kswtbmqo +kqbswotm + +kdfbzj +bfdzjm + +bf +ef +f +fut +bf + +bvl +lvu + +kezwynmfrgahlbqsjtdxiovpu +wmaukoqsldvheztxrgjpifbny +qgkrwvaiznhpmtlxjubesdoyf +osverdamnxjufcybpkztqighwl + +nza +anz + +wfjsdaq +iwlrou +ykwftq + +zgtuvqxmljwyaifcbp +pcgytlqjvbaxwzimf +cmqzwaljvbufyigptx +sxgvcbweymiflqajtkpz +fhgmjpwclzibtvaqxy + +rohqjmnvlsdaigywbxe +xmhiarjdogqwbvnlsey + +jhz +jhz +jzh + +oemyvhgznpblsq +hpsvzycebqlmng +elhnwqdpbsgzyvm +cenomgyzhqlsbvp + +gdnc +wncd + +tnlprwbcsaygzqxuoev +rxqdasecgwbzmfvntpl + +jtucglizkohrafs +ebjhogu +hdugoj + +ncyvqk +oulfaxqnerid +ptmsynbvkwq + +mxihwyzetlbnkpfs +ksqwhxtzbenfpim +nqbtxwsepfmkih +khixywsmbnetpfl +peikctmafswhnbx + +phylqxrdtg +yxtapqni +nkiwytuveqxp + +lhqrfys +sqdfly +ysfhlq +sylfq + +sqpjuobilhmtvrxaz +kuwgncfdv + +dqzke +qezkd +kqezd +zkqed +kdqez + +lio +iol +loi +lio +oil + +hvpwi +rhvp +fpysmvd +tpvrl +vph + +idjeoxvyqaufgpnlc +xnplcqjvdyigsaef + +y +qw + +rhb +fpqsiadrjkl + +hinvdck +kvcahnid +fhcupntkvdqijmy +dvnchik +aivcnhxkd + +xqugmnktofslbpevzd +yaqztjnicrwd + +biadvoeznswx +iaxszcdwboj +isbdkxzwoanve +gikqxzorsadfwb +asozrwidqxvb + +bvotgwrxe +xbhryeov +ojrvxebi +vxeorb + +fb +rqwl +qlrjyfp +nkhgmov + +zexjvfbwro +wzvxorfjbe +vorwzexbjtf +xeovwfjbzr + +owfmx +uxomf +mfo +cfkmo + +atwsbvcn +mijkzngueoy + +twqprciyaxkb +barckwiptqyx +iabyqwtcrkxp +rqbkipctxywa + +vmhzjek +tx +aix +dsa + +byzxqpgureth +gbxryhptqiezuc +lqrzjwythegxubp +hqruytzegbxp +tepughsrqzybx + +hwydxbeflai +yhewcfbaixd +yhwadxfeib + +hi +h +h +h + +mhket +mtkh + +loacixzmfy +fmxlzaoyci +ylifaxopczm +czyafoxmli + +ymrfxiwbse +ihpqjuaczd + +ealixkwz +gocmqyfthp + +gedjwnt +wtdezgn +hgcuwrtnped +zjngtdlexw + +jk +jk +kj +jk +jk + +gkxldasfhqncbiyu +hnpfbycsgqkuldex +hquxfksigydlcnab +cxauqgdiyfbnkshl + +niahryvlxbekt +dyhknvbaleirtx +tknljyvrihbzxe +seyxknvihrcbtl +bxrhukldytvneiw + +vuq +cfawvlt +rhnvzu + +wxlhvnmispbot +whvbcxmolntips +snhtmbpwifulxov +itswhupmncvolbx +rhtlsdpiwonbkqvxm + +ojmyc +kfzuehvirps + +mk +km +km + +fjyx +jitrevpfy +yjs +jyxmiect +dykgjnzbl + +rbwpjflnoegkqt +hwxceyimsdzntvu + +golf +fzgol +dlxfomg +lfozg +floag + +dfbmcyi +yvzpkrbc +icybu + +mcbditlrfgeaoh +camdhrfbvoglei +riagefbmclvokqz +dbfogjmeacrpl +lwuogecanfxsbrmy + +lgsnwuockhmpxibedqzaf +cvmiepdsubkgwzhf +bsvipdjwcfkmezugh +wgfzicsmubpdkeh + +iyeorgvpmutnhqcwxj +jqoguadpnmrk +nmpquzglaorsj + +apjqhruongvztmiywecl +padwbieyshonfrtxqcukzglv +yolrhezqicgpmvtaunw +mljzahrwcpqygvonuite + +szhjetf +sdtozreuhmfp + +f +f +mf +f + +gnjqcad +idlhjay +rejbwamoud +danxj +zjkdia + +lupiwyqntjgekvsr +gwqupjykitrlnsbo + +ojcxmuqsrhyv +lgcovdyhnifsp + +wphvcu +lznsm + +wpq +qpw +wqp +pwq +fqwhp + +nyzx +ubpx +xwi +wtxhe + +vkujyxtido +tvouidyjxk +vidkjuoxty +uxtoivdkjy +yvukijdoxt + +fpuboyiwdktvc +hsqnzuagr + +swabt +mwsb +sbwm +bws + +idlshcnf +ficnd +tdfcin +nicdf + +ajodwgmsy +wmjvoygd +ojdwmyg +dovgwjmy + +yemtzisjpxchanuovwdkr +evxtomkyhrupwsnizac +ytevcsimkwrnzoauhpx + +whley +dhyetlqf + +fqx +xf +bfxz + +ipwvb +vdnb +rcvnf +chvr +xjtvyez + +sdpuoewx +wfqrphkdelosbvgyum +pudzioesnw +idatsupewo + +knfheau +kanehuf +unekfa +klcsnemaufy + +yhuvigcrp +rivgypcuh +urphgvciy +iyhrcvupg +vuphryicg + +flozkyvhnwxr +fvpsybhlwrz +hzqvmfgrl +irholckaveszf + +gypwufz +agspwqmuyz +yogwpzu + +c +oc diff --git a/day-6/src/main.rs b/day-6/src/main.rs new file mode 100644 index 0000000..9035577 --- /dev/null +++ b/day-6/src/main.rs @@ -0,0 +1,137 @@ +use std::collections::HashSet; +use std::fs; + +fn main() -> Result<(), Box<dyn std::error::Error>> { + let input = fs::read_to_string("input")?; + + // Part 1 + let groups = parse_groups(&input)?; + println!("{}", count_answers(&groups)); + + // Part 2 + let groups = parse_group_individuals(&input)?; + println!("{}", count_individual_answers(&groups)); + + Ok(()) +} + +fn parse_groups(input: &str) -> Result<Vec<HashSet<char>>, String> { + input + .split("\n\n") + .map(|group| { + group + .chars() + .filter(|c| *c != '\n') + .map(|c| { + if c.is_alphabetic() { + Ok(c) + } else { + Err(format!("Invalid answer: {}", c)) + } + }) + .collect() + }) + .collect() +} + +fn count_answers(groups: &Vec<HashSet<char>>) -> usize { + groups.iter().map(|group| group.iter().count()).sum() +} + +fn parse_group_individuals(input: &str) -> Result<Vec<Vec<HashSet<char>>>, String> { + input + .split("\n\n") + .map(|group| { + group + .lines() + .map(|individual| { + individual + .chars() + .map(|c| { + if c.is_alphabetic() { + Ok(c) + } else { + Err(format!("Invalid answer: {}", c)) + } + }) + .collect() + }) + .collect() + }) + .collect() +} + +fn count_individual_answers(groups: &Vec<Vec<HashSet<char>>>) -> usize { + groups + .iter() + .map(|group| { + let mut iter = group.into_iter().cloned(); + let first = iter.next().expect("Must have at least one element"); + + iter.fold(first, |cumulative, entry| { + cumulative.intersection(&entry).copied().collect() + }) + .len() + }) + .sum() +} + +#[cfg(test)] +mod tests { + use super::*; + use indoc::indoc; + + #[test] + fn test_simple() -> Result<(), Box<dyn std::error::Error>> { + let input = indoc!( + "abc + + a + b + c + + ab + ac + + a + a + a + a + + b + " + ); + + let groups = parse_groups(input)?; + let counts = count_answers(&groups); + assert_eq!(counts, 11); + Ok(()) + } + + #[test] + fn test_simple2() -> Result<(), Box<dyn std::error::Error>> { + let input = indoc!( + "abc + + a + b + c + + ab + ac + + a + a + a + a + + b + " + ); + + let groups = parse_group_individuals(input)?; + let counts = count_individual_answers(&groups); + assert_eq!(counts, 6); + Ok(()) + } +} From 9c9a5389c6baec3d928bfad8381c2c696d2df643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= <tm@tlater.net> Date: Mon, 7 Dec 2020 23:54:12 +0000 Subject: [PATCH 8/8] Complete day 7 --- day-7/.gitignore | 1 + day-7/Cargo.lock | 128 ++++++++++ day-7/Cargo.toml | 12 + day-7/input | 594 ++++++++++++++++++++++++++++++++++++++++++++++ day-7/src/main.rs | 182 ++++++++++++++ 5 files changed, 917 insertions(+) create mode 100644 day-7/.gitignore create mode 100644 day-7/Cargo.lock create mode 100644 day-7/Cargo.toml create mode 100644 day-7/input create mode 100644 day-7/src/main.rs diff --git a/day-7/.gitignore b/day-7/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/day-7/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/day-7/Cargo.lock b/day-7/Cargo.lock new file mode 100644 index 0000000..14366e2 --- /dev/null +++ b/day-7/Cargo.lock @@ -0,0 +1,128 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "aho-corasick" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" +dependencies = [ + "memchr", +] + +[[package]] +name = "day-7" +version = "0.1.0" +dependencies = [ + "indoc", + "lazy_static", + "regex", +] + +[[package]] +name = "indoc" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47741a8bc60fb26eb8d6e0238bbb26d8575ff623fdc97b1a2c00c050b9684ed8" +dependencies = [ + "indoc-impl", + "proc-macro-hack", +] + +[[package]] +name = "indoc-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce046d161f000fffde5f432a0d034d0341dc152643b2598ed5bfce44c4f3a8f0" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", + "unindent", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "memchr" +version = "2.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", + "thread_local", +] + +[[package]] +name = "regex-syntax" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" + +[[package]] +name = "syn" +version = "1.0.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "thread_local" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "unindent" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f14ee04d9415b52b3aeab06258a3f07093182b88ba0f9b8d203f211a7a7d41c7" diff --git a/day-7/Cargo.toml b/day-7/Cargo.toml new file mode 100644 index 0000000..a9ba4c2 --- /dev/null +++ b/day-7/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "day-7" +version = "0.1.0" +authors = ["Tristan Daniël Maat <tm@tlater.net>"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +indoc = "0.3" +lazy_static = "1.4" +regex = "1.4" diff --git a/day-7/input b/day-7/input new file mode 100644 index 0000000..d63893c --- /dev/null +++ b/day-7/input @@ -0,0 +1,594 @@ +dull silver bags contain 2 striped magenta bags, 2 dark coral bags, 1 bright orange bag, 4 plaid blue bags. +dark plum bags contain 3 wavy teal bags. +wavy turquoise bags contain 3 bright salmon bags. +mirrored gold bags contain 3 wavy brown bags, 5 posh beige bags, 3 light crimson bags, 3 vibrant salmon bags. +drab green bags contain 4 dull white bags, 1 posh indigo bag. +faded lime bags contain 1 dim magenta bag, 1 wavy salmon bag, 4 dull purple bags. +mirrored blue bags contain 5 bright orange bags, 1 muted black bag, 2 muted brown bags, 2 vibrant gold bags. +faded crimson bags contain 4 wavy teal bags, 4 mirrored fuchsia bags, 3 plaid white bags. +faded magenta bags contain 2 clear orange bags, 5 dull green bags, 2 pale white bags. +pale red bags contain 5 shiny gold bags, 4 dull gold bags, 2 drab black bags. +dark coral bags contain 1 light turquoise bag. +faded chartreuse bags contain 4 shiny brown bags, 4 mirrored beige bags, 4 clear purple bags. +muted coral bags contain 4 pale coral bags, 4 plaid brown bags. +bright teal bags contain 5 striped blue bags, 4 faded orange bags, 2 faded crimson bags. +wavy green bags contain 5 dim chartreuse bags. +clear white bags contain 2 mirrored fuchsia bags. +clear aqua bags contain 1 faded beige bag. +vibrant yellow bags contain 5 posh brown bags. +pale lavender bags contain 1 striped beige bag, 2 striped cyan bags. +mirrored lime bags contain 3 bright orange bags. +faded tan bags contain 2 drab beige bags. +dark indigo bags contain 1 dark brown bag, 5 shiny beige bags, 1 vibrant indigo bag. +drab teal bags contain 2 vibrant fuchsia bags, 3 muted green bags, 5 dotted magenta bags, 2 shiny lavender bags. +shiny aqua bags contain 1 shiny gold bag, 4 clear white bags, 4 faded gold bags. +dull bronze bags contain 4 vibrant teal bags, 1 vibrant violet bag. +dark aqua bags contain 4 posh white bags. +dim coral bags contain 2 light yellow bags. +faded salmon bags contain 5 muted brown bags, 2 dotted red bags, 3 drab yellow bags, 4 dark red bags. +bright lavender bags contain 5 wavy maroon bags, 5 light brown bags, 5 bright silver bags, 1 dark gray bag. +mirrored cyan bags contain 4 dotted cyan bags, 5 striped orange bags, 1 vibrant gold bag. +drab aqua bags contain 3 striped black bags, 4 dark salmon bags, 1 drab white bag, 4 faded crimson bags. +striped purple bags contain 5 faded yellow bags, 2 faded brown bags. +drab fuchsia bags contain 4 vibrant violet bags, 5 mirrored yellow bags. +shiny red bags contain 3 faded cyan bags, 1 dull beige bag, 1 shiny blue bag, 5 dull cyan bags. +mirrored teal bags contain 4 clear brown bags, 5 light bronze bags, 3 light teal bags, 2 pale tomato bags. +dotted orange bags contain 3 dull white bags, 2 wavy blue bags. +dotted lavender bags contain 1 vibrant aqua bag, 4 shiny magenta bags, 3 dull plum bags. +pale crimson bags contain 4 muted cyan bags, 1 posh brown bag, 3 light magenta bags. +shiny black bags contain 4 vibrant chartreuse bags, 1 mirrored yellow bag, 3 posh brown bags, 5 vibrant violet bags. +clear bronze bags contain 5 dull violet bags, 3 pale plum bags. +striped lavender bags contain 1 dark plum bag, 2 striped yellow bags. +plaid indigo bags contain 2 plaid chartreuse bags. +shiny teal bags contain 4 wavy gray bags, 4 drab teal bags, 1 dark silver bag. +dull turquoise bags contain 1 wavy gray bag. +striped brown bags contain 1 striped olive bag, 1 wavy olive bag, 5 posh brown bags. +dotted magenta bags contain 4 drab silver bags, 3 light olive bags, 1 bright tan bag, 4 dull gold bags. +plaid yellow bags contain 5 drab black bags, 1 wavy lavender bag, 1 drab silver bag. +muted blue bags contain 5 posh aqua bags. +shiny olive bags contain 4 dark salmon bags, 1 faded gold bag, 3 drab chartreuse bags, 4 dotted yellow bags. +vibrant lime bags contain 4 shiny aqua bags, 1 bright maroon bag, 4 striped orange bags. +dim crimson bags contain 5 faded crimson bags. +vibrant gray bags contain 1 mirrored coral bag, 5 wavy beige bags, 3 drab turquoise bags. +posh chartreuse bags contain 3 light plum bags, 2 pale green bags, 5 drab white bags. +striped beige bags contain 5 dull red bags, 5 drab salmon bags, 3 vibrant salmon bags. +dotted tan bags contain 4 wavy crimson bags, 4 shiny orange bags, 1 drab turquoise bag. +vibrant aqua bags contain 1 vibrant gray bag, 5 light violet bags, 3 dim yellow bags. +faded turquoise bags contain 2 faded yellow bags, 4 mirrored coral bags. +mirrored purple bags contain 3 pale orange bags. +dim white bags contain 1 drab turquoise bag. +bright purple bags contain 5 muted chartreuse bags, 1 dotted yellow bag, 3 bright salmon bags. +drab red bags contain 1 mirrored magenta bag. +clear coral bags contain 4 drab black bags, 3 dark black bags. +mirrored orange bags contain 1 muted chartreuse bag. +wavy cyan bags contain 3 posh lime bags, 4 dark magenta bags, 4 vibrant turquoise bags. +pale magenta bags contain 4 vibrant turquoise bags, 3 clear gold bags. +posh gold bags contain 5 dotted lime bags, 5 wavy silver bags, 4 muted crimson bags, 1 dull yellow bag. +clear silver bags contain 1 drab indigo bag. +faded violet bags contain 2 mirrored bronze bags. +muted turquoise bags contain 2 plaid green bags, 2 light yellow bags, 4 dark violet bags. +striped bronze bags contain 4 striped white bags, 1 dim yellow bag, 5 clear aqua bags. +muted aqua bags contain 5 plaid green bags. +wavy teal bags contain no other bags. +pale black bags contain 5 dark salmon bags. +clear gold bags contain 2 plaid white bags, 5 drab coral bags, 5 pale coral bags. +muted chartreuse bags contain 5 faded crimson bags. +dotted fuchsia bags contain 1 plaid brown bag, 1 dark violet bag. +bright tomato bags contain 1 bright blue bag. +dim bronze bags contain 1 dotted green bag, 5 pale violet bags, 4 vibrant chartreuse bags, 3 striped yellow bags. +bright beige bags contain 1 drab blue bag. +vibrant olive bags contain 3 dotted olive bags. +clear tomato bags contain 1 light gray bag, 2 light turquoise bags, 2 striped yellow bags. +mirrored beige bags contain 3 light coral bags, 2 bright teal bags, 1 wavy magenta bag. +shiny gold bags contain 3 pale silver bags, 3 mirrored yellow bags, 2 shiny black bags, 2 light magenta bags. +plaid aqua bags contain 4 plaid crimson bags, 4 dim gray bags, 3 plaid orange bags, 2 dotted blue bags. +light green bags contain 2 light violet bags, 5 striped violet bags, 5 drab brown bags, 4 dull white bags. +vibrant beige bags contain 3 posh violet bags, 2 plaid blue bags, 4 shiny lavender bags, 5 wavy orange bags. +drab orange bags contain 3 striped beige bags, 3 posh teal bags, 5 drab silver bags, 1 dark indigo bag. +shiny orange bags contain 3 dark aqua bags, 4 clear beige bags, 2 mirrored lime bags, 3 dark violet bags. +wavy maroon bags contain 3 vibrant chartreuse bags. +wavy olive bags contain 5 dark aqua bags, 1 light yellow bag, 1 shiny crimson bag. +dotted cyan bags contain 2 drab gold bags. +muted cyan bags contain 1 clear gold bag, 4 dark plum bags, 2 wavy lavender bags, 5 vibrant indigo bags. +posh cyan bags contain 1 light fuchsia bag, 1 dark maroon bag. +faded bronze bags contain 2 muted salmon bags, 4 dim violet bags, 5 dark tan bags, 3 vibrant white bags. +pale green bags contain 4 muted turquoise bags, 1 vibrant green bag, 1 drab white bag. +clear brown bags contain 4 wavy teal bags, 4 drab violet bags. +striped salmon bags contain 5 mirrored orange bags, 1 shiny yellow bag, 1 muted beige bag, 1 clear purple bag. +posh brown bags contain 3 posh white bags, 4 drab chartreuse bags, 5 dark violet bags, 4 wavy teal bags. +mirrored green bags contain 1 dim tan bag. +bright yellow bags contain 2 striped indigo bags, 2 dark silver bags. +wavy yellow bags contain 3 dotted gold bags, 3 posh green bags. +light chartreuse bags contain 3 faded blue bags, 3 mirrored yellow bags, 3 shiny plum bags, 4 light red bags. +dark lime bags contain 5 vibrant chartreuse bags, 2 clear brown bags, 1 posh brown bag. +muted magenta bags contain 4 shiny silver bags, 2 dotted yellow bags, 4 pale fuchsia bags, 5 muted tan bags. +light plum bags contain 4 drab gold bags. +dim tomato bags contain 1 light silver bag. +pale lime bags contain 4 dull blue bags. +dim black bags contain 1 dark plum bag, 1 dull crimson bag, 5 wavy white bags, 2 plaid chartreuse bags. +muted teal bags contain 3 dim black bags, 4 mirrored lavender bags, 5 dull indigo bags, 3 clear red bags. +muted purple bags contain 1 mirrored red bag. +dull coral bags contain 5 pale teal bags, 2 faded cyan bags, 4 pale black bags, 2 muted olive bags. +vibrant red bags contain 4 light teal bags, 5 shiny fuchsia bags, 1 drab purple bag, 2 muted olive bags. +mirrored tomato bags contain 4 posh brown bags. +shiny coral bags contain 5 clear turquoise bags, 2 wavy salmon bags, 1 drab brown bag. +wavy indigo bags contain 1 vibrant brown bag, 2 dim turquoise bags, 1 posh violet bag, 1 plaid green bag. +dotted gold bags contain 5 pale aqua bags, 1 bright olive bag. +dotted violet bags contain 2 drab olive bags, 1 plaid cyan bag, 2 posh beige bags. +pale fuchsia bags contain 5 faded beige bags, 5 dark purple bags. +shiny chartreuse bags contain 1 striped tan bag, 5 pale tomato bags. +clear gray bags contain 1 bright fuchsia bag, 4 dotted olive bags, 2 light teal bags, 4 shiny magenta bags. +vibrant tomato bags contain 1 clear crimson bag, 3 pale purple bags, 3 faded gray bags. +light orange bags contain 5 plaid brown bags. +shiny tomato bags contain 3 light olive bags, 5 dim silver bags, 3 posh violet bags, 2 striped lavender bags. +faded green bags contain 2 dotted gold bags, 1 dark plum bag, 1 dull gray bag, 5 dark brown bags. +dim gray bags contain 5 muted white bags, 2 mirrored yellow bags, 1 muted tomato bag. +faded black bags contain 3 faded teal bags, 3 striped lavender bags, 2 striped blue bags, 4 muted lavender bags. +clear lime bags contain 3 mirrored yellow bags, 1 light yellow bag. +dark silver bags contain 4 wavy orange bags, 2 muted green bags. +plaid black bags contain 3 wavy indigo bags, 1 pale red bag. +mirrored black bags contain 5 dull black bags, 4 clear coral bags, 1 wavy olive bag, 4 dull silver bags. +light coral bags contain 5 drab black bags, 1 dark magenta bag, 1 drab teal bag, 1 mirrored crimson bag. +shiny yellow bags contain 5 faded indigo bags. +posh plum bags contain 3 faded maroon bags, 2 vibrant indigo bags, 1 bright turquoise bag. +faded olive bags contain 1 vibrant gray bag, 4 drab teal bags, 5 wavy teal bags. +dim plum bags contain 1 plaid white bag, 4 wavy beige bags, 3 wavy green bags. +muted tomato bags contain 5 dotted red bags, 1 drab purple bag, 1 light orange bag. +clear fuchsia bags contain 1 mirrored olive bag, 2 faded salmon bags. +striped violet bags contain 2 light olive bags, 1 plaid olive bag, 5 light white bags. +dim aqua bags contain 2 vibrant purple bags, 5 drab silver bags. +striped crimson bags contain 5 muted coral bags. +bright indigo bags contain 3 muted gold bags. +dotted black bags contain 4 shiny crimson bags, 5 dark salmon bags, 5 faded crimson bags, 2 vibrant magenta bags. +faded indigo bags contain 1 drab tomato bag. +bright bronze bags contain 1 wavy lime bag, 4 pale violet bags. +drab turquoise bags contain 2 drab gold bags, 2 vibrant gold bags, 4 pale tomato bags. +wavy black bags contain 2 dotted brown bags, 1 light salmon bag. +posh green bags contain 1 striped olive bag, 5 vibrant turquoise bags, 4 pale coral bags. +clear green bags contain 4 dull bronze bags, 4 shiny crimson bags, 1 light white bag. +dull chartreuse bags contain 2 dim aqua bags, 3 shiny black bags. +drab lime bags contain 1 wavy chartreuse bag, 4 mirrored chartreuse bags, 1 posh olive bag, 5 mirrored lavender bags. +bright tan bags contain 4 muted tan bags, 5 shiny gold bags, 1 mirrored red bag, 3 dull crimson bags. +dim maroon bags contain 3 clear red bags, 5 dark brown bags, 2 bright maroon bags, 1 muted teal bag. +drab tomato bags contain 4 dim orange bags, 2 mirrored violet bags, 3 faded purple bags. +muted gold bags contain 1 dim cyan bag. +striped white bags contain 1 plaid white bag, 1 posh purple bag, 3 muted cyan bags, 2 pale crimson bags. +wavy beige bags contain 2 plaid white bags, 3 dark brown bags. +vibrant turquoise bags contain 2 muted turquoise bags, 3 plaid green bags, 1 shiny crimson bag. +dark fuchsia bags contain 1 pale purple bag, 1 dim fuchsia bag, 3 light teal bags, 3 vibrant magenta bags. +dotted aqua bags contain 1 bright white bag, 5 clear gold bags, 5 clear tomato bags. +faded silver bags contain 1 light lime bag, 4 wavy gold bags. +faded brown bags contain 4 light aqua bags. +bright gray bags contain 3 faded red bags, 2 muted plum bags, 1 wavy brown bag. +wavy tan bags contain 1 pale maroon bag, 5 posh black bags. +bright blue bags contain 5 posh purple bags. +striped gold bags contain 4 dull tan bags, 1 shiny crimson bag, 2 clear blue bags. +bright magenta bags contain 4 shiny orange bags. +dotted brown bags contain 4 faded teal bags, 5 mirrored coral bags. +muted silver bags contain 5 striped black bags, 3 faded beige bags, 4 plaid crimson bags, 2 wavy brown bags. +wavy purple bags contain 1 dim brown bag, 1 bright yellow bag, 5 shiny lime bags. +dull plum bags contain 1 posh black bag, 4 vibrant fuchsia bags, 5 dull bronze bags. +dotted red bags contain 5 striped tomato bags, 4 shiny orange bags, 4 clear magenta bags, 5 pale coral bags. +light violet bags contain 2 bright beige bags, 5 mirrored plum bags, 3 wavy fuchsia bags, 1 clear tan bag. +dark teal bags contain 3 dull gray bags, 2 dark aqua bags, 1 clear beige bag. +light fuchsia bags contain 2 muted silver bags, 2 striped beige bags. +posh blue bags contain 5 striped olive bags, 5 dim coral bags. +light black bags contain 2 drab coral bags, 2 shiny indigo bags. +pale chartreuse bags contain 5 pale tomato bags. +drab gold bags contain 1 faded gold bag, 5 shiny gold bags. +posh bronze bags contain 2 drab aqua bags, 5 pale gray bags. +light tomato bags contain 5 wavy lime bags. +dull tan bags contain 3 drab blue bags, 4 dull green bags, 4 clear violet bags. +muted beige bags contain 5 clear white bags, 5 faded crimson bags. +faded fuchsia bags contain 5 plaid purple bags, 1 shiny silver bag, 4 muted violet bags. +bright green bags contain 5 dim teal bags, 5 shiny crimson bags, 5 clear crimson bags. +mirrored fuchsia bags contain 4 posh white bags, 5 wavy teal bags, 2 dark violet bags. +vibrant plum bags contain 2 posh yellow bags. +plaid bronze bags contain 4 dotted coral bags, 4 dull green bags, 2 plaid chartreuse bags. +plaid fuchsia bags contain 5 bright white bags. +dull red bags contain 2 mirrored fuchsia bags, 3 vibrant violet bags, 2 bright olive bags, 1 dim orange bag. +faded gray bags contain 1 dull purple bag, 2 posh salmon bags. +wavy plum bags contain 4 pale violet bags, 3 striped magenta bags, 4 pale red bags. +dark crimson bags contain 4 dim yellow bags, 1 dotted purple bag, 2 wavy indigo bags, 4 clear black bags. +pale cyan bags contain 5 shiny coral bags, 4 shiny beige bags, 2 plaid olive bags. +dull violet bags contain 3 wavy olive bags, 1 dull gray bag, 5 vibrant turquoise bags, 1 plaid purple bag. +wavy chartreuse bags contain 1 dotted magenta bag, 3 bright orange bags, 1 mirrored red bag. +dark cyan bags contain 5 dotted turquoise bags, 1 clear purple bag, 1 dim teal bag. +posh coral bags contain 3 muted bronze bags. +pale yellow bags contain 1 drab tomato bag. +plaid turquoise bags contain 1 muted gray bag. +dotted purple bags contain 5 posh silver bags, 4 dark salmon bags. +light indigo bags contain 4 mirrored red bags, 4 light olive bags. +faded plum bags contain 3 mirrored gold bags. +faded coral bags contain 5 dull tan bags. +clear indigo bags contain 5 mirrored magenta bags, 1 clear maroon bag, 1 bright blue bag, 5 light aqua bags. +dim cyan bags contain 5 plaid green bags. +dotted maroon bags contain 5 pale maroon bags, 2 dark indigo bags. +faded beige bags contain 1 plaid chartreuse bag. +striped indigo bags contain 1 dark gray bag, 3 drab olive bags. +clear yellow bags contain 4 dull gray bags, 1 muted green bag. +light lavender bags contain 4 pale coral bags, 2 light yellow bags, 2 light indigo bags. +light turquoise bags contain 5 pale fuchsia bags, 5 vibrant fuchsia bags, 5 vibrant magenta bags, 3 pale indigo bags. +light purple bags contain 2 light cyan bags. +bright gold bags contain 1 dark aqua bag. +muted bronze bags contain 2 light teal bags. +striped gray bags contain 2 light cyan bags, 1 pale black bag, 5 plaid plum bags. +wavy orange bags contain 2 pale coral bags, 2 dim coral bags. +wavy silver bags contain 2 posh white bags, 1 faded beige bag. +clear chartreuse bags contain 1 vibrant lime bag, 2 faded plum bags, 1 striped chartreuse bag, 5 clear maroon bags. +vibrant tan bags contain 3 striped lime bags, 4 pale maroon bags, 2 muted turquoise bags, 4 dark lime bags. +posh aqua bags contain 2 muted tan bags, 2 shiny blue bags, 2 posh purple bags. +bright orange bags contain no other bags. +drab coral bags contain no other bags. +light white bags contain 5 striped yellow bags. +wavy violet bags contain 1 pale silver bag, 2 shiny fuchsia bags, 1 vibrant violet bag, 1 shiny plum bag. +dark white bags contain 4 shiny maroon bags, 2 dim brown bags, 2 dark beige bags, 1 pale blue bag. +vibrant violet bags contain 4 striped blue bags, 1 mirrored lime bag, 1 posh white bag. +vibrant lavender bags contain 4 dotted magenta bags, 1 wavy red bag, 3 pale coral bags, 3 clear indigo bags. +dark purple bags contain 4 posh white bags. +mirrored lavender bags contain 5 clear brown bags, 2 faded gold bags. +striped silver bags contain 3 light yellow bags, 1 drab violet bag. +faded blue bags contain 3 muted violet bags, 4 wavy plum bags, 2 pale indigo bags, 1 wavy bronze bag. +drab cyan bags contain 4 dim tomato bags, 1 plaid lavender bag, 4 pale red bags, 2 drab olive bags. +clear lavender bags contain 3 wavy olive bags, 5 bright gray bags, 3 wavy beige bags, 2 dim violet bags. +striped aqua bags contain 3 mirrored lavender bags. +plaid tomato bags contain 2 posh cyan bags, 3 pale silver bags. +plaid salmon bags contain 1 muted lavender bag, 5 muted green bags, 3 bright aqua bags. +light blue bags contain 1 light white bag, 4 clear violet bags, 3 dark brown bags. +dark blue bags contain 5 posh aqua bags. +faded teal bags contain 3 light beige bags. +plaid chartreuse bags contain 4 wavy teal bags. +wavy gray bags contain 3 drab white bags, 2 muted lavender bags. +pale maroon bags contain 4 faded crimson bags, 4 vibrant chartreuse bags, 1 plaid green bag, 1 vibrant turquoise bag. +dark bronze bags contain 4 faded turquoise bags, 2 faded silver bags, 5 faded salmon bags. +pale coral bags contain 3 mirrored yellow bags, 4 dark plum bags, 2 dark aqua bags, 4 plaid white bags. +mirrored magenta bags contain 5 vibrant lime bags, 4 vibrant chartreuse bags, 3 striped aqua bags. +mirrored salmon bags contain 4 striped salmon bags, 1 posh tan bag, 3 faded bronze bags. +drab tan bags contain 5 vibrant violet bags. +vibrant indigo bags contain 1 pale coral bag, 1 light teal bag, 2 light magenta bags. +plaid lavender bags contain 1 striped silver bag, 1 clear lime bag. +muted plum bags contain 2 plaid crimson bags. +posh gray bags contain 5 mirrored lime bags. +clear maroon bags contain 5 wavy bronze bags, 3 dim gold bags, 2 muted beige bags, 5 posh coral bags. +striped maroon bags contain 2 dotted violet bags, 4 bright fuchsia bags, 4 striped aqua bags. +faded yellow bags contain 2 wavy teal bags, 3 wavy lavender bags. +posh black bags contain 1 drab silver bag, 2 clear white bags, 5 muted silver bags. +muted indigo bags contain 1 dark green bag, 1 plaid chartreuse bag, 3 bright indigo bags, 5 wavy silver bags. +wavy brown bags contain 5 faded red bags, 4 bright orange bags, 3 dim black bags. +vibrant coral bags contain 5 plaid white bags, 5 vibrant indigo bags. +wavy white bags contain 1 plaid green bag, 3 drab chartreuse bags, 1 posh white bag. +pale violet bags contain 2 shiny orange bags, 4 plaid crimson bags. +clear black bags contain 4 wavy blue bags, 5 plaid tan bags, 4 clear magenta bags. +faded aqua bags contain 2 wavy teal bags. +dotted green bags contain 5 shiny orange bags, 1 light magenta bag. +bright coral bags contain 2 shiny fuchsia bags, 4 light lime bags, 1 shiny gold bag. +vibrant fuchsia bags contain 1 vibrant chartreuse bag, 1 striped black bag. +dark turquoise bags contain 5 shiny salmon bags, 2 light lavender bags. +shiny green bags contain 1 pale silver bag, 4 dim red bags, 3 dark lime bags, 4 drab coral bags. +clear red bags contain 5 light teal bags, 5 posh brown bags. +dull gold bags contain 1 drab tan bag, 4 striped tomato bags, 5 pale maroon bags, 2 dim crimson bags. +mirrored red bags contain 3 shiny crimson bags, 4 plaid brown bags, 2 shiny black bags. +pale blue bags contain 1 wavy crimson bag, 4 faded beige bags, 4 shiny chartreuse bags. +clear beige bags contain 4 plaid crimson bags, 5 shiny crimson bags. +drab salmon bags contain 4 dim crimson bags, 3 light magenta bags, 1 clear violet bag. +vibrant magenta bags contain 4 dim black bags. +dark salmon bags contain 3 dull green bags, 4 faded red bags. +posh white bags contain no other bags. +light lime bags contain 5 dark aqua bags. +vibrant salmon bags contain 4 striped tomato bags, 4 clear aqua bags. +clear teal bags contain 3 striped gray bags. +plaid silver bags contain 3 vibrant violet bags, 2 muted magenta bags, 3 dark olive bags, 4 mirrored gold bags. +striped cyan bags contain 4 light gold bags, 2 dotted magenta bags. +wavy bronze bags contain 1 plaid crimson bag, 1 dull gray bag, 5 dull tan bags, 1 mirrored teal bag. +dim olive bags contain 4 vibrant lime bags, 2 shiny crimson bags, 2 muted turquoise bags. +dotted blue bags contain 4 vibrant gray bags, 2 shiny beige bags. +plaid blue bags contain 5 drab silver bags. +dark olive bags contain 1 pale coral bag, 4 vibrant indigo bags. +pale gray bags contain 3 dotted crimson bags, 1 striped magenta bag, 5 wavy white bags, 2 vibrant blue bags. +mirrored brown bags contain 2 bright cyan bags, 4 plaid brown bags, 5 faded turquoise bags. +wavy gold bags contain 1 wavy coral bag. +pale teal bags contain 3 vibrant magenta bags. +mirrored turquoise bags contain 4 mirrored olive bags, 5 bright yellow bags. +dark chartreuse bags contain 4 dotted cyan bags, 5 shiny turquoise bags, 5 vibrant salmon bags, 4 wavy yellow bags. +muted gray bags contain 3 dim orange bags. +posh turquoise bags contain 4 clear lavender bags, 5 dim coral bags, 2 striped salmon bags. +shiny cyan bags contain 4 striped gold bags. +drab olive bags contain 2 plaid cyan bags, 1 mirrored lime bag. +posh tomato bags contain 2 drab tan bags, 3 shiny orange bags. +muted fuchsia bags contain 1 pale salmon bag, 3 wavy violet bags, 3 mirrored maroon bags. +pale bronze bags contain 3 drab yellow bags, 3 muted chartreuse bags. +striped green bags contain 3 striped orange bags, 2 dull green bags, 3 vibrant tan bags. +faded orange bags contain 3 mirrored plum bags, 5 mirrored lime bags, 5 faded red bags. +dull aqua bags contain 2 striped coral bags. +dotted olive bags contain 4 faded salmon bags, 1 wavy green bag. +vibrant silver bags contain 4 mirrored yellow bags, 2 dotted salmon bags, 3 drab silver bags. +striped olive bags contain 1 mirrored fuchsia bag, 1 faded gold bag, 1 mirrored lavender bag. +dark violet bags contain no other bags. +mirrored olive bags contain 5 dull teal bags, 1 dim white bag. +plaid tan bags contain 4 pale gray bags, 2 dim crimson bags, 1 clear violet bag, 1 wavy lime bag. +pale tomato bags contain 5 posh green bags, 4 faded red bags. +dim turquoise bags contain 1 shiny gold bag, 5 drab blue bags. +muted lime bags contain 3 vibrant lime bags, 1 pale plum bag, 1 dark indigo bag. +drab beige bags contain 3 vibrant magenta bags. +posh beige bags contain 2 dark violet bags. +muted olive bags contain 2 pale brown bags, 5 light gray bags, 3 wavy green bags, 2 drab tan bags. +dim orange bags contain 1 clear lime bag, 4 faded beige bags, 2 mirrored fuchsia bags. +dull salmon bags contain 4 striped coral bags, 3 striped aqua bags. +dull maroon bags contain 3 clear brown bags, 5 dull magenta bags, 1 dim red bag. +mirrored coral bags contain 5 muted tan bags, 4 dotted magenta bags, 5 dim olive bags. +posh olive bags contain 4 dull magenta bags, 4 wavy blue bags, 2 drab yellow bags, 5 dotted gold bags. +mirrored violet bags contain 2 pale fuchsia bags. +drab bronze bags contain 4 drab chartreuse bags. +wavy fuchsia bags contain 2 dark gray bags, 5 muted silver bags. +pale plum bags contain 3 vibrant salmon bags, 5 drab chartreuse bags, 2 posh violet bags. +mirrored aqua bags contain 2 pale aqua bags. +bright silver bags contain 3 drab black bags, 5 dark salmon bags, 2 shiny beige bags, 2 posh lavender bags. +plaid lime bags contain 4 faded teal bags, 5 pale brown bags, 5 dim red bags. +dotted turquoise bags contain 3 dim olive bags, 2 mirrored blue bags, 3 dull lime bags, 4 vibrant lavender bags. +drab maroon bags contain 5 bright red bags. +wavy lavender bags contain 1 striped lime bag, 1 posh brown bag. +shiny beige bags contain 5 shiny aqua bags, 3 muted teal bags, 5 clear gold bags. +dark gold bags contain 4 clear maroon bags, 2 dotted maroon bags, 3 light red bags. +light aqua bags contain 2 dim red bags, 3 pale red bags. +posh teal bags contain 3 muted brown bags, 5 shiny gold bags, 5 dotted purple bags. +dull lavender bags contain 5 shiny blue bags. +dark tan bags contain 1 muted tan bag, 5 vibrant turquoise bags, 4 dark violet bags, 4 muted plum bags. +light beige bags contain 2 mirrored fuchsia bags, 1 drab chartreuse bag, 1 muted tan bag. +pale olive bags contain 3 clear brown bags. +dark maroon bags contain 5 dull plum bags, 3 muted green bags. +muted red bags contain 4 pale tan bags, 1 bright white bag. +light tan bags contain 3 light purple bags, 2 pale aqua bags, 3 wavy bronze bags. +clear magenta bags contain 3 vibrant chartreuse bags, 1 dim crimson bag. +dark orange bags contain 2 posh cyan bags, 1 wavy brown bag, 5 dull black bags. +dim lavender bags contain 5 drab fuchsia bags. +dotted beige bags contain 5 light blue bags, 4 plaid tan bags, 2 wavy maroon bags, 5 dim crimson bags. +dim green bags contain 3 plaid tan bags, 1 drab blue bag, 1 clear aqua bag. +plaid brown bags contain 3 muted turquoise bags, 4 drab chartreuse bags. +bright black bags contain 5 striped white bags. +plaid gold bags contain 3 shiny lime bags, 1 plaid maroon bag, 4 bright blue bags. +pale white bags contain 4 drab chartreuse bags, 3 pale tan bags, 5 pale aqua bags. +drab violet bags contain no other bags. +light magenta bags contain 3 faded crimson bags. +light gold bags contain 1 dim lavender bag, 3 light magenta bags, 5 drab gold bags. +plaid coral bags contain 1 vibrant salmon bag, 3 striped tomato bags, 3 posh blue bags. +dotted white bags contain 1 wavy lavender bag. +striped yellow bags contain 4 drab black bags, 2 faded red bags, 2 shiny gold bags, 4 dark aqua bags. +dark yellow bags contain 5 wavy bronze bags, 5 bright purple bags. +faded white bags contain 3 light tomato bags. +muted white bags contain 5 faded gold bags, 1 plaid magenta bag, 3 drab white bags, 5 dim brown bags. +faded red bags contain 1 posh brown bag, 2 muted turquoise bags, 3 plaid crimson bags, 4 shiny orange bags. +dark red bags contain 5 shiny salmon bags. +dull gray bags contain 2 posh white bags. +bright salmon bags contain 2 shiny aqua bags, 3 dotted crimson bags, 1 drab violet bag, 4 pale chartreuse bags. +mirrored chartreuse bags contain 1 vibrant magenta bag, 3 plaid salmon bags, 1 plaid chartreuse bag, 3 muted violet bags. +vibrant orange bags contain 5 posh yellow bags. +dark gray bags contain 1 plaid chartreuse bag, 2 drab violet bags, 1 bright chartreuse bag, 1 muted purple bag. +mirrored crimson bags contain 3 drab coral bags, 5 dull lime bags. +muted violet bags contain 3 dotted crimson bags, 3 light olive bags. +shiny brown bags contain 2 dark lavender bags, 2 vibrant yellow bags, 1 dark black bag, 2 drab olive bags. +muted green bags contain 1 dull cyan bag, 5 dull red bags, 4 pale chartreuse bags. +drab yellow bags contain 3 pale tomato bags. +dotted tomato bags contain 2 shiny magenta bags, 3 mirrored tomato bags, 5 plaid chartreuse bags. +plaid red bags contain 3 pale cyan bags. +bright red bags contain 1 shiny beige bag. +plaid purple bags contain 5 dull gold bags. +dark green bags contain 3 pale salmon bags, 3 dim brown bags, 2 wavy violet bags, 2 pale chartreuse bags. +plaid orange bags contain 1 vibrant chartreuse bag, 2 dotted coral bags, 1 posh teal bag. +plaid violet bags contain 1 shiny maroon bag. +posh tan bags contain 1 shiny beige bag, 2 dim magenta bags, 1 dark violet bag. +bright aqua bags contain 1 drab brown bag, 4 dotted purple bags. +vibrant white bags contain 4 light gray bags, 2 dark fuchsia bags, 1 pale cyan bag. +striped red bags contain 5 faded gold bags, 5 drab crimson bags, 3 faded turquoise bags. +dull purple bags contain 1 pale crimson bag. +shiny blue bags contain 1 pale violet bag, 5 mirrored plum bags, 3 posh white bags, 1 light yellow bag. +clear salmon bags contain 2 striped lime bags, 1 dull violet bag. +faded gold bags contain 3 light teal bags, 3 wavy teal bags. +mirrored yellow bags contain 2 muted turquoise bags, 4 drab chartreuse bags. +plaid gray bags contain 4 plaid plum bags. +plaid white bags contain no other bags. +drab black bags contain 2 mirrored yellow bags, 2 drab chartreuse bags, 1 shiny orange bag. +dotted chartreuse bags contain 2 vibrant cyan bags, 2 light salmon bags, 3 vibrant red bags, 5 light turquoise bags. +faded lavender bags contain 3 dark tomato bags, 5 muted lime bags, 4 light fuchsia bags, 4 dull lavender bags. +vibrant cyan bags contain 2 clear crimson bags, 3 pale orange bags, 4 dull indigo bags, 3 light red bags. +bright maroon bags contain 2 muted tan bags, 2 light teal bags. +drab silver bags contain 3 bright chartreuse bags, 4 pale crimson bags, 5 dotted crimson bags, 5 faded yellow bags. +drab purple bags contain 5 drab blue bags. +dim gold bags contain 1 bright cyan bag, 5 dull white bags, 3 vibrant blue bags. +dark beige bags contain 4 pale coral bags, 1 pale indigo bag. +dotted salmon bags contain 2 drab violet bags, 5 posh white bags. +vibrant crimson bags contain 5 faded teal bags, 3 dotted green bags, 1 clear maroon bag. +dim chartreuse bags contain 3 clear white bags. +bright violet bags contain 1 dim yellow bag, 1 muted purple bag, 4 muted teal bags, 5 striped cyan bags. +dim magenta bags contain 1 pale aqua bag, 4 pale maroon bags, 5 mirrored red bags, 4 drab yellow bags. +dim brown bags contain 5 faded salmon bags, 4 dotted magenta bags, 5 drab tomato bags, 2 faded teal bags. +shiny lime bags contain 5 dotted black bags, 4 plaid turquoise bags, 2 dim tomato bags, 2 clear magenta bags. +drab magenta bags contain 3 dark beige bags. +faded cyan bags contain 2 striped lime bags, 4 bright red bags. +dark brown bags contain 4 mirrored lime bags, 1 bright orange bag. +posh fuchsia bags contain 5 shiny gold bags, 5 pale salmon bags, 1 light coral bag, 1 mirrored plum bag. +shiny magenta bags contain 4 dark aqua bags. +dark lavender bags contain 1 pale purple bag, 3 vibrant yellow bags. +vibrant brown bags contain 2 posh teal bags, 1 wavy silver bag, 2 pale plum bags. +muted black bags contain 5 faded crimson bags, 3 dim crimson bags, 4 vibrant magenta bags. +muted brown bags contain 5 striped olive bags, 5 dark brown bags, 2 clear brown bags, 4 plaid white bags. +pale orange bags contain 4 bright blue bags, 3 dark aqua bags, 1 clear gold bag. +light cyan bags contain 3 muted silver bags. +drab white bags contain 2 drab tan bags, 2 striped tomato bags, 4 dull gray bags, 5 drab blue bags. +dim tan bags contain 3 mirrored bronze bags, 3 faded salmon bags, 4 drab purple bags. +dull tomato bags contain 3 clear lime bags. +wavy aqua bags contain 3 dotted orange bags, 5 shiny crimson bags. +shiny lavender bags contain 5 vibrant blue bags, 4 pale purple bags, 1 wavy bronze bag, 2 posh violet bags. +shiny white bags contain 5 faded blue bags, 5 pale cyan bags. +wavy blue bags contain 4 vibrant chartreuse bags, 4 plaid brown bags, 3 plaid white bags, 2 faded gold bags. +striped magenta bags contain 2 dark olive bags, 5 bright chartreuse bags. +vibrant black bags contain 4 plaid white bags, 2 dull silver bags, 5 striped purple bags, 1 dark plum bag. +dull green bags contain 2 dull crimson bags. +vibrant chartreuse bags contain 2 bright orange bags, 4 dark aqua bags. +dim violet bags contain 2 dark teal bags, 4 plaid brown bags, 4 mirrored yellow bags. +clear blue bags contain 5 posh maroon bags. +faded tomato bags contain 5 clear beige bags, 4 bright orange bags. +posh violet bags contain 3 clear gold bags. +striped tomato bags contain 2 shiny black bags. +muted crimson bags contain 4 light aqua bags, 3 dim gold bags. +clear tan bags contain 4 drab tomato bags, 4 mirrored bronze bags, 1 shiny chartreuse bag. +posh magenta bags contain 4 posh red bags, 3 light bronze bags. +dim blue bags contain 5 dim gray bags, 1 light turquoise bag, 5 muted bronze bags. +drab plum bags contain 1 vibrant plum bag, 4 striped coral bags. +pale silver bags contain 5 drab black bags. +posh purple bags contain 2 dark brown bags. +drab indigo bags contain 1 muted lavender bag, 2 posh salmon bags, 1 pale brown bag. +striped blue bags contain 4 wavy teal bags. +wavy magenta bags contain 1 dotted salmon bag, 1 drab black bag, 2 dull tan bags, 1 drab silver bag. +pale turquoise bags contain 4 dark lime bags, 4 drab maroon bags. +shiny tan bags contain 4 plaid coral bags, 3 dim black bags, 1 dull plum bag. +light teal bags contain 3 dark violet bags. +mirrored silver bags contain 1 striped salmon bag, 1 clear chartreuse bag, 2 clear orange bags, 2 posh aqua bags. +wavy coral bags contain 2 muted teal bags, 1 wavy white bag. +wavy crimson bags contain 1 shiny aqua bag, 3 muted beige bags. +shiny bronze bags contain 1 posh indigo bag, 5 wavy blue bags, 1 faded gold bag, 3 striped tomato bags. +shiny maroon bags contain 1 clear tomato bag, 1 wavy crimson bag. +bright turquoise bags contain 3 dull tan bags, 3 vibrant teal bags. +faded purple bags contain 1 plaid chartreuse bag. +bright white bags contain 2 faded gold bags. +clear orange bags contain 4 striped blue bags, 2 mirrored lime bags, 5 muted turquoise bags. +clear cyan bags contain 1 dim plum bag, 3 shiny brown bags, 1 muted purple bag, 2 plaid lime bags. +plaid teal bags contain 2 faded aqua bags, 4 wavy olive bags. +dotted lime bags contain 5 posh olive bags, 2 pale orange bags. +muted tan bags contain 1 dull gray bag, 2 dark aqua bags, 1 pale violet bag. +striped orange bags contain 3 mirrored lime bags, 2 dull crimson bags, 4 faded gold bags, 3 pale silver bags. +light olive bags contain 2 dark tan bags, 3 dim orange bags, 5 mirrored yellow bags. +plaid magenta bags contain 2 wavy orange bags, 1 wavy chartreuse bag, 5 striped coral bags. +dark magenta bags contain 3 bright white bags, 3 plaid purple bags, 3 striped black bags, 4 light beige bags. +dark black bags contain 3 pale tan bags, 4 mirrored orange bags, 3 dull teal bags. +posh orange bags contain 4 bright aqua bags, 1 dim crimson bag, 4 dim turquoise bags, 1 dotted bronze bag. +dull crimson bags contain 4 vibrant violet bags. +clear turquoise bags contain 1 muted brown bag, 2 dull yellow bags, 3 pale black bags, 1 plaid crimson bag. +vibrant blue bags contain 2 clear beige bags. +dull lime bags contain 4 shiny plum bags, 3 vibrant magenta bags, 3 dark olive bags. +drab brown bags contain 4 clear green bags. +mirrored plum bags contain 2 faded red bags. +shiny fuchsia bags contain 2 muted cyan bags, 4 dark aqua bags, 3 light olive bags, 2 clear gold bags. +vibrant purple bags contain 3 pale aqua bags, 3 dark lime bags, 1 bright chartreuse bag. +bright crimson bags contain 1 vibrant gold bag. +shiny plum bags contain 2 clear olive bags, 4 dark plum bags. +shiny crimson bags contain no other bags. +dull beige bags contain 1 mirrored coral bag. +dim salmon bags contain 1 clear tomato bag, 2 shiny teal bags, 4 plaid olive bags, 3 plaid purple bags. +muted maroon bags contain 2 muted violet bags, 4 dark white bags. +pale aqua bags contain 4 dark beige bags, 1 muted brown bag. +bright plum bags contain 4 dim black bags. +striped tan bags contain 3 bright orange bags, 3 dark violet bags, 4 drab blue bags, 2 vibrant lime bags. +clear crimson bags contain 3 wavy brown bags, 1 faded blue bag, 2 striped cyan bags. +dim indigo bags contain 3 dotted lime bags, 1 dotted purple bag. +pale tan bags contain 2 drab blue bags, 5 dim orange bags, 5 wavy olive bags, 3 striped tomato bags. +vibrant bronze bags contain 5 clear red bags, 5 posh red bags. +dotted bronze bags contain 1 light yellow bag. +wavy salmon bags contain 2 striped olive bags, 4 muted teal bags. +shiny turquoise bags contain 3 dark teal bags, 1 plaid yellow bag. +faded maroon bags contain 1 vibrant salmon bag, 5 dotted magenta bags, 1 faded tan bag, 5 striped tomato bags. +vibrant teal bags contain 4 light teal bags, 3 pale orange bags, 5 drab white bags. +vibrant gold bags contain 1 muted cyan bag, 2 mirrored plum bags, 1 drab coral bag, 4 dark lime bags. +bright cyan bags contain 2 muted silver bags, 5 plaid bronze bags, 3 light beige bags, 2 faded crimson bags. +shiny silver bags contain 4 mirrored fuchsia bags, 2 clear violet bags, 3 faded beige bags. +dark tomato bags contain 4 clear lime bags, 2 light beige bags, 3 bright turquoise bags. +mirrored indigo bags contain 5 posh chartreuse bags, 5 clear tomato bags. +dotted indigo bags contain 2 drab olive bags, 2 dim indigo bags, 5 dotted magenta bags. +shiny gray bags contain 4 muted chartreuse bags, 4 plaid gray bags, 3 dull red bags, 5 striped orange bags. +dim yellow bags contain 1 muted cyan bag, 4 mirrored fuchsia bags, 1 faded gold bag, 1 drab turquoise bag. +bright lime bags contain 5 shiny bronze bags, 3 wavy aqua bags, 4 plaid turquoise bags. +dotted gray bags contain 2 shiny gold bags. +striped black bags contain 1 wavy teal bag, 5 dim chartreuse bags, 4 mirrored lavender bags. +pale beige bags contain 2 posh black bags, 4 clear white bags. +posh indigo bags contain 5 plaid white bags. +dull blue bags contain 4 dark violet bags, 2 clear magenta bags, 4 dotted crimson bags. +mirrored white bags contain 5 faded yellow bags. +bright brown bags contain 3 pale gray bags. +light gray bags contain 3 clear magenta bags, 5 wavy brown bags, 3 dotted salmon bags. +muted orange bags contain 1 bright magenta bag, 1 bright plum bag. +clear purple bags contain 1 shiny gold bag, 1 dark white bag. +striped coral bags contain 5 pale gray bags, 3 wavy chartreuse bags. +plaid green bags contain no other bags. +plaid maroon bags contain 5 posh brown bags, 3 striped crimson bags, 4 plaid green bags. +light maroon bags contain 3 muted gray bags, 5 dull crimson bags, 2 shiny maroon bags. +pale purple bags contain 2 striped white bags, 3 plaid chartreuse bags, 1 mirrored lime bag. +muted yellow bags contain 5 vibrant purple bags, 1 dark teal bag. +plaid olive bags contain 1 light crimson bag, 1 faded gold bag, 1 vibrant blue bag. +dim beige bags contain 4 muted silver bags, 3 mirrored beige bags, 4 striped violet bags. +striped chartreuse bags contain 3 dull teal bags. +muted salmon bags contain 2 posh salmon bags, 2 posh silver bags. +dim red bags contain 2 drab blue bags, 4 plaid crimson bags, 3 vibrant gold bags. +dull magenta bags contain 5 faded crimson bags, 1 shiny orange bag, 1 dark tan bag. +plaid beige bags contain 1 vibrant turquoise bag. +striped teal bags contain 2 dim chartreuse bags, 4 dark green bags. +dotted plum bags contain 2 light cyan bags. +dotted yellow bags contain 5 posh black bags, 5 dull tan bags, 2 dull violet bags, 5 muted plum bags. +dotted coral bags contain 1 striped tomato bag, 2 light crimson bags, 3 clear violet bags. +dull fuchsia bags contain 3 plaid purple bags, 4 mirrored red bags. +dull yellow bags contain 5 vibrant violet bags, 2 dark olive bags. +dull white bags contain 5 posh olive bags, 5 pale tomato bags, 2 bright teal bags. +pale brown bags contain 3 dim crimson bags, 3 pale indigo bags, 1 dim chartreuse bag, 4 muted teal bags. +shiny violet bags contain 1 muted tomato bag, 2 dull yellow bags, 1 drab teal bag. +drab blue bags contain 3 vibrant gold bags, 4 drab black bags. +posh lavender bags contain 5 shiny plum bags, 3 drab salmon bags, 4 dim brown bags, 4 plaid blue bags. +dull teal bags contain 2 drab turquoise bags, 1 shiny crimson bag, 5 shiny aqua bags. +shiny purple bags contain 3 drab orange bags, 4 dark red bags, 4 vibrant fuchsia bags, 2 light fuchsia bags. +pale salmon bags contain 2 plaid chartreuse bags, 3 striped white bags. +posh silver bags contain 4 clear magenta bags, 5 light magenta bags. +light salmon bags contain 4 vibrant olive bags. +striped turquoise bags contain 1 faded magenta bag, 3 shiny indigo bags, 4 striped lavender bags. +dotted crimson bags contain 2 pale silver bags, 2 striped magenta bags, 1 striped white bag. +dull brown bags contain 5 clear crimson bags, 1 dotted green bag, 4 dull magenta bags, 3 dim tan bags. +plaid cyan bags contain 1 striped orange bag, 2 muted cyan bags. +muted lavender bags contain 5 mirrored fuchsia bags. +dim lime bags contain 1 muted black bag. +light bronze bags contain 1 dull crimson bag, 5 dim chartreuse bags. +dull olive bags contain 2 vibrant coral bags, 3 shiny teal bags, 4 plaid purple bags. +posh yellow bags contain 5 dark lime bags, 3 mirrored plum bags. +bright fuchsia bags contain 1 striped silver bag. +posh maroon bags contain 4 dotted magenta bags, 4 posh yellow bags, 2 drab beige bags. +posh salmon bags contain 2 muted green bags. +mirrored gray bags contain 4 striped silver bags. +dull cyan bags contain 2 bright orange bags, 4 dark plum bags. +light crimson bags contain 3 drab fuchsia bags, 3 bright blue bags, 1 dark purple bag. +light red bags contain 3 dim maroon bags, 4 muted green bags, 3 dotted olive bags. +dull indigo bags contain 2 plaid brown bags, 1 wavy white bag, 2 vibrant turquoise bags, 5 drab chartreuse bags. +drab crimson bags contain 2 vibrant salmon bags. +posh red bags contain 3 mirrored violet bags, 1 striped tomato bag, 2 striped olive bags. +drab chartreuse bags contain no other bags. +posh lime bags contain 3 drab violet bags, 1 bright coral bag. +wavy red bags contain 4 striped gray bags, 3 posh salmon bags, 1 dotted violet bag, 3 striped aqua bags. +striped fuchsia bags contain 3 bright crimson bags, 3 dark silver bags, 1 clear magenta bag, 3 drab salmon bags. +striped plum bags contain 2 drab tan bags, 5 pale gold bags, 1 dull white bag, 1 clear coral bag. +mirrored maroon bags contain 1 dark magenta bag, 1 plaid purple bag, 2 light gray bags. +shiny indigo bags contain 2 drab teal bags. +dim silver bags contain 1 striped aqua bag, 3 dull tan bags, 3 striped tan bags, 2 wavy maroon bags. +shiny salmon bags contain 5 faded beige bags. +dull black bags contain 3 vibrant plum bags, 2 plaid chartreuse bags, 1 muted brown bag, 2 clear tomato bags. +clear plum bags contain 3 striped maroon bags, 2 dark white bags. +vibrant green bags contain 5 light orange bags, 5 mirrored magenta bags, 3 bright teal bags, 2 striped brown bags. +drab gray bags contain 1 plaid maroon bag, 2 pale tan bags, 1 plaid white bag. +wavy lime bags contain 2 clear gold bags, 2 bright chartreuse bags, 1 faded crimson bag. +light silver bags contain 4 dim maroon bags, 1 mirrored teal bag. +light brown bags contain 5 muted magenta bags. +dim fuchsia bags contain 5 pale purple bags, 5 wavy orange bags, 5 clear lime bags. +vibrant maroon bags contain 4 light gray bags. +dim purple bags contain 2 muted white bags, 2 shiny aqua bags. +clear olive bags contain 3 bright olive bags. +drab lavender bags contain 4 mirrored crimson bags, 3 bright violet bags, 5 posh gold bags, 2 bright olive bags. +light yellow bags contain 1 posh brown bag, 2 pale violet bags. +plaid crimson bags contain 1 plaid green bag, 3 shiny crimson bags. +pale indigo bags contain 3 clear aqua bags, 2 pale silver bags. +mirrored bronze bags contain 4 muted tomato bags, 4 bright white bags, 1 faded crimson bag. +dim teal bags contain 1 muted salmon bag. +clear violet bags contain 2 dim coral bags, 2 faded beige bags. +dotted silver bags contain 2 posh plum bags, 4 pale chartreuse bags. +pale gold bags contain 2 vibrant gold bags, 1 dotted magenta bag. +posh crimson bags contain 4 dull yellow bags, 3 clear fuchsia bags. +dull orange bags contain 3 dull silver bags, 3 clear violet bags, 4 clear chartreuse bags, 3 faded salmon bags. +striped lime bags contain 5 mirrored plum bags, 4 faded gold bags, 3 wavy white bags, 3 light teal bags. +mirrored tan bags contain 4 dull silver bags, 4 light coral bags, 2 plaid lavender bags. +wavy tomato bags contain 4 clear orange bags, 5 shiny fuchsia bags, 3 light red bags. +dotted teal bags contain 5 dark salmon bags, 1 light indigo bag, 4 pale white bags, 5 clear olive bags. +bright olive bags contain 1 dark tan bag, 4 striped orange bags, 3 bright orange bags. +plaid plum bags contain 1 shiny maroon bag, 1 dotted coral bag. +bright chartreuse bags contain 2 wavy blue bags. diff --git a/day-7/src/main.rs b/day-7/src/main.rs new file mode 100644 index 0000000..a427514 --- /dev/null +++ b/day-7/src/main.rs @@ -0,0 +1,182 @@ +use std::collections::HashMap; +use std::fs; + +use lazy_static::lazy_static; +use regex::Regex; + +fn main() -> Result<(), Box<dyn std::error::Error>> { + let input = fs::read_to_string("input")?; + let rules = parse_rules(&input)?; + + // Part 1 + println!("{}", count_containing_bags(&rules, "shiny gold")); + + // Part 2 + println!("{}", count_contained_bags(&rules, "shiny gold")); + + Ok(()) +} + +fn parse_rule(input: &str) -> Result<HashMap<String, usize>, std::num::ParseIntError> { + // Rules look something like: + // + // <value> <key> bags?, <value> <key> bags?. + // + // or: + // + // no other bags. + + lazy_static! { + static ref RULE_RE: Regex = Regex::new(r"(\d+) (.+?) bags?").expect("Should compile"); + }; + + if let "no other bags." = input { + Ok(HashMap::new()) + } else { + RULE_RE + .captures_iter(input) + .map(|captures| Ok((captures[2].to_string(), captures[1].parse::<usize>()?))) + .collect() + } +} + +fn parse_rules(input: &str) -> Result<HashMap<&str, HashMap<String, usize>>, String> { + input + .lines() + .map(|line| { + // Each line looks something like: + // + // <key> bags contain <rule> + // + // So we simply split on " bags contain " and pass the + // rest to the rule parsing function. + + // Note this will be a lot easier once str::split_once is stable + let (key, rule) = { + let temp: Vec<&str> = line.split(" bags contain ").collect(); + if temp.len() != 2 { + Err(format!("Invalid format for bag rule: {}", line)) + } else { + Ok((temp[0], temp[1])) + } + }?; + + Ok(( + key, + parse_rule(rule).map_err(|e| format!("Could not parse rule '{}': {}", rule, e))?, + )) + }) + .collect() +} + +fn count_containing_bags(rules: &HashMap<&str, HashMap<String, usize>>, color: &str) -> usize { + fn contains_recursively( + rules: &HashMap<&str, HashMap<String, usize>>, + rule: &HashMap<String, usize>, + color: &str, + ) -> bool { + // A bag contains the given color recursively, if either it + // contains the color, or any bags it contains contain the bag + // recursively + rule.contains_key(color) + || rule.keys().any(|bag| { + if let Some(rule) = rules.get(bag.as_str()) { + contains_recursively(rules, rule, color) + } else { + // The bag should always be in our index, but in + // case it's not, we treat it as if it contains no other bags. + false + } + }) + } + + // Count from how many bags the given bag is reachable + rules + .iter() + .filter(|(_, rule)| contains_recursively(rules, rule, color)) + .count() +} + +fn count_contained_bags(rules: &HashMap<&str, HashMap<String, usize>>, color: &str) -> usize { + if let Some(rule) = rules.get(color) { + // Count how many bags are reachable from this bag; except + // multiply the numbers by the number of each bag contained + rule.iter() + .map(|(contained, number)| number + number * count_contained_bags(rules, contained)) + .sum() + } else { + // The bag should always be in our index, but in case it's + // not, we treat it as if it contains 0 other bags. + 0 + } +} + +#[cfg(test)] +mod tests { + use super::*; + use indoc::indoc; + + #[test] + fn test_simple() -> Result<(), Box<dyn std::error::Error>> { + let input = indoc!( + " + light red bags contain 1 bright white bag, 2 muted yellow bags. + dark orange bags contain 3 bright white bags, 4 muted yellow bags. + bright white bags contain 1 shiny gold bag. + muted yellow bags contain 2 shiny gold bags, 9 faded blue bags. + shiny gold bags contain 1 dark olive bag, 2 vibrant plum bags. + dark olive bags contain 3 faded blue bags, 4 dotted black bags. + vibrant plum bags contain 5 faded blue bags, 6 dotted black bags. + faded blue bags contain no other bags. + dotted black bags contain no other bags. + " + ); + + let rules = parse_rules(&input)?; + assert_eq!(count_containing_bags(&rules, "shiny gold"), 4); + + Ok(()) + } + + #[test] + fn test_simple2() -> Result<(), Box<dyn std::error::Error>> { + let input = indoc!( + " + light red bags contain 1 bright white bag, 2 muted yellow bags. + dark orange bags contain 3 bright white bags, 4 muted yellow bags. + bright white bags contain 1 shiny gold bag. + muted yellow bags contain 2 shiny gold bags, 9 faded blue bags. + shiny gold bags contain 1 dark olive bag, 2 vibrant plum bags. + dark olive bags contain 3 faded blue bags, 4 dotted black bags. + vibrant plum bags contain 5 faded blue bags, 6 dotted black bags. + faded blue bags contain no other bags. + dotted black bags contain no other bags. + " + ); + + let rules = parse_rules(&input)?; + assert_eq!(count_contained_bags(&rules, "shiny gold"), 32); + + Ok(()) + } + + #[test] + fn test_simple3() -> Result<(), Box<dyn std::error::Error>> { + let input = indoc!( + " + shiny gold bags contain 2 dark red bags. + dark red bags contain 2 dark orange bags. + dark orange bags contain 2 dark yellow bags. + dark yellow bags contain 2 dark green bags. + dark green bags contain 2 dark blue bags. + dark blue bags contain 2 dark violet bags. + dark violet bags contain no other bags. + " + ); + + let rules = parse_rules(&input)?; + assert_eq!(count_contained_bags(&rules, "shiny gold"), 126); + + Ok(()) + } +}