diff --git a/README.md b/README.md new file mode 100644 index 0000000..3962d26 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# adventofcode2020 + +Hi all! + +My AdventOfCode is node.js based. Step into each day folder and run `node program.js` to run it. + +Replace my input.txt with your content and see if it works for yours as well. + +I am always curious to better solutions, so feel free to PR on an existing day any improvements to the code. As long as they're actually improvements, not just for the sake of shorter. My code should be production-deployable (in my mind) so they should be easily readable. diff --git a/day1input.txt b/day1/input.txt similarity index 100% rename from day1input.txt rename to day1/input.txt diff --git a/day1.js b/day1/program.js similarity index 93% rename from day1.js rename to day1/program.js index c874e4f..fa54b97 100644 --- a/day1.js +++ b/day1/program.js @@ -24,7 +24,7 @@ function findSumPart1(nums) { }); } -fs.readFile('./day1input.txt', 'utf-8', (e, data) =>{ +fs.readFile('./input.txt', 'utf-8', (e, data) =>{ const items = data.split("\n"); items.forEach((num, i) => { items[i] = parseInt(num); diff --git a/day10/input.txt b/day10/input.txt new file mode 100644 index 0000000..e15aff5 --- /dev/null +++ b/day10/input.txt @@ -0,0 +1,104 @@ +2 +49 +78 +116 +143 +42 +142 +87 +132 +86 +67 +44 +136 +82 +125 +1 +108 +123 +46 +37 +137 +148 +106 +121 +10 +64 +165 +17 +102 +156 +22 +117 +31 +38 +24 +69 +131 +144 +162 +63 +171 +153 +90 +9 +107 +79 +7 +55 +138 +34 +52 +77 +152 +3 +158 +100 +45 +129 +130 +135 +23 +93 +96 +103 +124 +95 +8 +62 +39 +118 +164 +172 +75 +122 +20 +145 +14 +112 +61 +43 +141 +30 +85 +101 +151 +29 +113 +94 +68 +58 +76 +97 +28 +111 +128 +21 +11 +163 +161 +4 +168 +157 +27 +72 \ No newline at end of file diff --git a/day10/program.js b/day10/program.js new file mode 100644 index 0000000..691869b --- /dev/null +++ b/day10/program.js @@ -0,0 +1,53 @@ +const fs = require('fs'); + +const data = fs.readFileSync('./input.txt', 'utf-8'); +let adapters = data.split("\n"); + +adapters.forEach((a, i) => { + adapters[i] = parseInt(a); +}); + +adapters.sort((a,b) => { return a > b ? 1 : -1}); +findAdapterJumps(adapters); +calculateArrangements(adapters); + +function findAdapterJumps(items) { + let jump1 = 0; + let jump3 = 1; + let currentCharge = 0; + + items.forEach(i => { + if (i - currentCharge === 1) jump1++; + else if (i - currentCharge === 3) jump3++; + currentCharge = i; + }); + + console.log(jump1, jump3, 'answer part 1: ', jump1 * jump3); +} + +function calculateArrangements(items) { + let sequenceLength = 1; + let lastNum = 0; + + let multi = { + 1: 0, + 2: 0, + 3: 0, + 4: 0, + 5: 0 + } + + items.forEach(item => { + if (item - lastNum === 1) sequenceLength++; + else { + multi[sequenceLength]++; + sequenceLength = 1; + } + lastNum = item; + }); + multi[sequenceLength]++; + + // 2,4 & 7 are hardcoded. Calculation is on todo here + let res = Math.pow(2,multi[3])*Math.pow(4,multi[4])*Math.pow(7,multi[5]); + console.log('part 2', res); +} \ No newline at end of file diff --git a/day2input.txt b/day2/input.txt similarity index 100% rename from day2input.txt rename to day2/input.txt diff --git a/day2.js b/day2/program.js similarity index 96% rename from day2.js rename to day2/program.js index e135497..6d50394 100644 --- a/day2.js +++ b/day2/program.js @@ -61,7 +61,7 @@ function parseItems(input) { } -fs.readFile('./day2input.txt', 'utf-8', (e, data) =>{ +fs.readFile('./input.txt', 'utf-8', (e, data) =>{ const items = data.split("\n"); const pws = parseItems(items); diff --git a/day3/input.txt b/day3/input.txt new file mode 100644 index 0000000..8285f03 --- /dev/null +++ b/day3/input.txt @@ -0,0 +1,323 @@ +.....#....#...#.#..........#... +...#.................#......... +......#...#.#.#.....#..#.....#. +.........#.#.............##.... +#..####..#..#.##.....#......... +...#........#..##...........#.. +..##.#.#..#....#..#......#.#... +.......#.##....#.....###....#.# +.#..#...#......#..#....##.#.... +...#...............#.#.....#... +..#............#..#.........#.# +#.#.#.............##.#......#.. +#...#..............##...#.#.... +...#....#................#.#..# +..#.#..#.#.#..#.....#.........# +#.............#..#..........#.. +.#...#.#........###.#....#...#. +#......#....#.#..#.##..#....... +.##......###.#......#..##...#.. +#..#....#........#......#.#.... +.#..................#.....#.### +.#......#.#.#.....#...#.#...... +....#.............#.#.......... +....#..#.#........#..###....... +.....#....#...#........#....... +...........#.###....##.......#. +....#...........#.#..#...#..... +...........#.....#.#........... +.....#........#.....#.#..#....# +#.#......#.......#.......#..... +..........#.............#.#.#.. +#...#..........#....#....#..... +.#.#......#..##...#.....#...##. +.#....#...#.#.......#.#........ +....#....##.##...#............. +#...#....#..#.........#........ +...#.....#.#...#.......#..#.... +#.......#...#....##........#..# +####........#........#....#.#.. +............##..........#...... +.......#.....#.#.#.##..#...#... +..........#....#...##.........# +..##..####.......##......#.##.. +.....#.#......##...#..#...#.... +....#.#.#.........#........#... +...........###...#.........##.. +.......#.#....#......#.##...##. +.................#...##.#...##. +.......#.......#..#.#.......... +.#....#..#....#........#....... +...............#.##..#...##..#. +.###.#....#......#...#.#.....#. +.#.....##.......#.......#...... +....#..#.....#.....#........... +.......#....#.................# +.......#.##...#...#......#..... +.#.....#...####.............#.. +......#.........#..........#... +.........#....#....#........### +....#.........#......##.....#.. +....#........##...##.....##...# +.#..#....#..........#...#.###.# +#..#......#...#........#....... +...#.........................#. +.............#........#........ +.......#.#.#.....##.....#..#... +..##..##.........#............. +.#...#..#......#...##..##..###. +.....#....#...#...##.##........ +.#.#..#...........#..#..#...... +##..#...#..#...##..#....#...... +...#...#...#.........#....###.. +...##..#....#.#.#.......#...#.. +..#.#.....#..#....#..##.......# +.....#.#.....#......#....#.#... +.......##....#.....#...#.....#. +..##..#.................#.#.... +..............##....##.#..##... +.#..#.....#....#.#.#........... +......#.#.#..#..#...#.....#..## +..#.........#.#.......###...##. +#.....#...........#.....#.##.#. +#..........#....#....#..#....#. +.#.....#...#.......###......#.. +....##..##......#....#....#.... +.......#.#.............#....#.# +.#..#.##.##.##....#.#.....##.## +....#..##.#..#.............##.. +....#...........#...#....#..#.. +...........#..#....#....##.#.## +......#....#....#.....#......#. +.##.##....#.....#.#......#...#. +.....##.......#.#.#........##.. +#..........##..#....#..#.#....# +...#........................... +...#..#...#..#.#.#.#.......#.#. +.....#.........#..###.......... +...#.#......##....#......#..### +#..............#....#.......#.. +.........##......###..###...... +..#......##...........#.##..... +#.#..#......#...##............. +......#.#.............#....#..# +#.....##..#.#.................# +..##....#.....#....#.....###... +.#.#.##.....#.................. +.#......#.#.#.....#..#....#.... +..#.#.....##.#...#..#.#.##..... +..#.#..#......##.#.#..........# +.......##.....#..#...#....##.#. +...#.....#..........#.......... +......................##......# +...###.........##.........#.... +....#..................#.....#. +.##..#.............#........##. +....#....#...###..........#.... +.....#.#..........###.......... +..#......##......#.#.##.#..#... +##...........#.#..#.....#..#... +.........#......#..........#.#. +...#.##.#..#..###..#........... +....##.#.##...........#.....##. +....#...................###.... +#.......#......#......#.....#.. +#..........##.................. +...#..#.#....#..#.........##.#. +......#...##.#...............#. +.........#....#.#...#..#..#.... +...#......###..#......#.....#.# +#..###.#.............#......... +......#...........#............ +..#..#.##.....#......#.#..#...# +.........#..............#...... +........#.....#..#...#.....#..# +.....................#........# +.##.......##...#.###.........#. +.#...#.......#.#....##....#.... +........#......#...........#.#. +....#......##...#.....#...#...# +..#.........#.#...............# +....#.....#......#............. +.............##.....#....#..... +........#......#.#.....#....#.. +#.........#...#......#....#...# +.#........###...#.#.#...#....#. +.###...........#..#............ +....##.........#..#...##.#..### +.####..#.#...............##.#.. +#.....#...#....#.......##....#. +..#.....##...##.#...#..#....... +..#.###.......#.....#.......#.. +...........#.......#....##....# +..#...#....##........###......# +...#..#..............#...#..... +##.#.............#....##.#..##. +##.#..#..............#.#....... +.......#....#....##............ +.##..##.#..........#.#...#.#... +.........##.......##...#...#... +............#...##....#...#.... +........#...#..#...#.##......#. +..#...#.#.........#.#....#..... +..#...#.#..#.......#.#......... +.......#.....#...#.#..###....#. +.#......#.#....#.#.####....#... +.......##..#......#...#......## +#####.....#........#.#.......#. +.....#...#..#...#.#.....#..#... +....#...#....##.....##....#.#.. +.#..#......#.####.....#....#..# +...#.......#..#.....##........# +.#.....#.#.#.....##...#..#..... +.............#...#..#.....#.... +...#.....##.......#...##..#...# +..#.............#...#..#..##... +...#........#........#...#...#. +##..........#.#.#.............# +....#....#..............#..#... +....#..####..##....#.......#.#. +.#..#.....##....#.#.....#...#.. +#............##..#..#.#......#. +....#..........##..#........... +..#.##.#.......#...#.##....#... +....#.#.............#.#.##....# +...#..#.#.#......#..#....#....# +.............#...........#..#.. +#.............##.......#..###.. +..##....#.#.#...#...#....#...#. +##.......####........##..#..... +.###..#..#..#..#...#.#......... +............#............#..... +#...#.....#.#.##.##...#.......# +#........#....#...#.........#.. +#....#.#......#.............#.. +....#............#......##...#. +.......#........#..#.......#..# +#.#...#.#.#..#..#........#....# +#.#.##...........#.....#.....#. +.#...##.#..#................... +###...#.#.....................# +.#....##...##.#....#..#........ +........###...#.#....##...#..## +...#..#..........###..#.......# +..#..##.............#.....#.... +....##..#..............#....... +...##...##.#....#.#...#...#.#.# +..#..........#.....##........#. +.#.#.....#......#..#....#...... +...##.#....#.......#......#.... +...##..#........##......#..##.. +#..###...#...........#.#....... +..##...#...#.#.#...#.#.....#... +..#.....##.#....#.....#..#..... +..#.#......#.......#........... +....##......##.............#..# +.......#.........##...#..#...#. +.#........#.##.#.....#.#....... +#..#...#..#.....##...........#. +..##..............#....#....... +.#..#....#.#...........#..##.#. +#....#..###..........#...#..... +.......#...##........#.#...###. +....#..#......##......#.....#.. +.#..##..#..#......#......#.##.. +....#.#...........#..#.#.##.#.. +.....#......#.....#.....#..#... +..........#...........#...##... +#..#.#.#..#....#.....##......## +..#.....#.....#................ +...#.#..##.........#..#..##.... +.#.....##..#.#.#.#.....#....... +...........##...#.............. +...#.#....##..#.............### +...#.#...........#.........#... +#.....#.....##..#.#.#.#....#... +##..................##.##...... +......#.....#....#.....#..#...# +.............#.......#....#..## +.#..#.##..#..#.........##...#.. +..#.#....#........#....#....##. +.#.#.#.#.#.......#.......#..#.. +#.....#..##..#.........#....... +.............#.#..............# +.........#......#....#.#......# +.........#.#...##..#.#......... +...........#..........#........ +.......#...#...#......#..#..... +#.....#...............#.....#.# +..#....#..........#.#...#..#... +#....##..#..#.....#.#..#.#..... +.#....#..###............##..... +......#.##...........#....#..#. +...#........##....#...#...#.... +..#.#.#.....#..#.#..........##. +..................#...........# +##........#.#......#.#.......#. +......#..#.............##...... +.#..###..#...###......#....#..# +..#...........#...#...##..#...# +..#..........#..............#.. +.....#......................... +..#.#..##...........##...#..... +...........#......##.....##.... +......#.......#................ +.........#.......#.#........... +#......#...#........##.....##.. +...#.....#....#..#.....#....... +....#.#......#...#..#.##.##...# +..#..#.#.....#...#...........#. +.#....##.####.....#..........## +...##.##.....##..###...#....... +.......#.#...#....#.......#..#. +.#..#.###.#.............#...... +.###.........####..#........... +#..#.#.###.....#.......#....... +.#.....#.....#.....#.........#. +..#...#......#.......##.###.... +.......##.............##.#..... +.....................#.....##.# +##.#...#........#..##........#. +...#..........#.#.#..#......### +.#....#.#.#..........##........ +....#....####....#.#....#..#.#. +..#.........#....##..........## +...##.#.......##.#.......#.#... +........#..#......#...#.#.....# +.....##............#.#.......#. +.........##...##..#.....#..#... +#...#....#........#...#....##.# +..#.....#..........#...##.....# +.##..#.........#...........#... +.....##.#.#.#.#..#...#.....#.#. +.#..#..##.........#.......#...# +#....#.....#...#....#.........# +...#..#.......#.........#...... +.#....##..#......##.#.#......#. +....##.##...........#...#...... +..#.#....#.##...#......#....... +...#........#.............#.... +...##....................#.###. +.#.......#.........#......##... +....#..#..............#....#... +....##.#............#.......... +.#...#....#...##..........#.... +....#............#.....#....... +.......#........#.............. +....#.#....#.#..#..#........... +......................#.#...... +#......##.....#..#.......##.... +...#........#........#.#...##.. +##.#....##....#................ +#..#....#..............#.##.... +......#........#...........#... +#....##.##...#...#..#...##..... +............#............#..#.. +#....#...#..#..#.#...........#. +.......#..........#..........## +.....#......#....##.#.......... +.#....#....#....#....#..#...#.. +.....###....#...#.#.#........#. +.......#...#..........##..#...# +..##........................##. +.....#....#..............#....# diff --git a/day3/program.js b/day3/program.js new file mode 100644 index 0000000..6c2aae4 --- /dev/null +++ b/day3/program.js @@ -0,0 +1,35 @@ +const fs = require('fs'); +let items; + +fs.readFile('./input.txt', 'utf-8', (e, data) => { + items = data.split("\n"); + const resultPart1 = progress(0, 0, 0, [3,1]); + const resultPart2 = checkPart2(); + + console.log('result!', resultPart1, resultPart2); +}); + +function checkPart2() { + const oneone = progress(0, 0, 0, [1,1]); + const threeone = progress(0, 0, 0, [3,1]); + const fiveone = progress(0, 0, 0, [5,1]); + const sevenone = progress(0, 0, 0, [7,1]); + const onetwo = progress(0, 0, 0, [1,2]); + return oneone*threeone*fiveone*sevenone*onetwo; +} + +function progress(trees, currentRow, currentColumn, nextStep) { + const block = items[currentRow].substr(currentColumn, 1); + if (block === '#') trees++; + + currentRow += nextStep[1]; + if (!items[currentRow]) return trees; + + currentColumn += nextStep[0]; + + if (currentColumn > items[currentRow].length - 1) { + currentColumn -= items[currentRow].length; + } + + return progress(trees, currentRow, currentColumn, nextStep); +} \ No newline at end of file diff --git a/day4/input.txt b/day4/input.txt new file mode 100644 index 0000000..646dcfe --- /dev/null +++ b/day4/input.txt @@ -0,0 +1,1169 @@ +byr:2024 iyr:2016 +eyr:2034 ecl:zzz pid:985592671 hcl:033b48 +hgt:181 cid:166 + +hgt:66cm +pid:152cm +hcl:cfb18a eyr:1947 +byr:2020 ecl:zzz iyr:2029 + +ecl:gry hcl:#888785 eyr:2023 cid:63 +iyr:2019 hgt:177cm +pid:656793259 + +pid:#5e832a +ecl:dne hcl:#7d3b0c byr:2018 eyr:1928 hgt:61cm iyr:1936 cid:241 + +hcl:#888785 ecl:oth eyr:2025 +pid:597580472 +iyr:2017 hgt:187cm byr:1957 cid:247 + +eyr:2029 cid:145 iyr:2026 pid:178cm hgt:162in ecl:gry +hcl:#a5d09f byr:2002 + +eyr:2024 +ecl:amb +pid:349191561 iyr:2018 hgt:156cm byr:1972 +hcl:#341e13 + +byr:1998 pid:408617933 +hcl:#fffffd hgt:193cm eyr:2021 ecl:brn iyr:2013 + +eyr:1964 byr:2026 +hcl:#cfa07d hgt:154cm pid:175cm cid:85 iyr:2018 ecl:gmt + +hgt:161cm +pid:021086946 +iyr:2020 ecl:blu eyr:2024 +byr:1921 + +pid:173cm cid:235 eyr:1935 iyr:1952 ecl:utc byr:2015 hgt:187 +hcl:6239ed + +iyr:2015 hcl:#18171d pid:2691566700 ecl:gmt hgt:68cm eyr:2032 byr:2016 +cid:341 + +hcl:#c0946f +iyr:2010 pid:941290886 eyr:2023 ecl:brn +hgt:190cm +byr:1927 + +pid:423210256 eyr:2026 iyr:2011 byr:1926 hcl:#efcc98 +ecl:grn +hgt:185cm cid:135 + +ecl:blu eyr:2030 +byr:1996 hgt:154cm iyr:2019 pid:809421142 +hcl:#b6652a +cid:250 + +hcl:39615c iyr:1934 byr:2009 pid:7752456272 hgt:191cm +eyr:2024 ecl:#5b7a58 + +iyr:1938 hgt:160in hcl:#623a2f eyr:2031 +ecl:grn pid:169cm byr:1964 + +ecl:grt byr:2004 hcl:026249 hgt:176in iyr:1933 eyr:2023 +pid:176cm + +hgt:167cm +pid:023312072 ecl:oth iyr:2018 hcl:#866857 eyr:2024 byr:1994 + +hcl:#c0946f +ecl:blu iyr:2016 +eyr:2023 hgt:193cm +pid:190756361 byr:1943 +cid:306 + +iyr:2013 hgt:179cm ecl:oth +cid:290 eyr:2020 pid:953948851 +hcl:#6b5442 +byr:1973 + +pid:795414848 +cid:51 +ecl:oth iyr:2020 hcl:#ceb3a1 eyr:2026 byr:1995 hgt:186cm + +iyr:2020 +byr:1993 hgt:159cm pid:905121332 +ecl:brn eyr:2023 +hcl:#341e13 + +ecl:hzl iyr:2017 eyr:2020 hcl:z byr:2003 hgt:163 + +eyr:2038 +cid:342 hgt:116 iyr:2019 hcl:73db63 byr:1973 ecl:gry pid:468207739 + +pid:022772899 eyr:2040 hgt:181cm +ecl:dne +hcl:#866857 +byr:1931 iyr:2012 + +pid:36127238 eyr:2038 cid:227 iyr:1985 hgt:103 byr:2004 +hcl:z ecl:#45a680 + +hgt:183cm +iyr:2013 byr:1933 cid:112 +eyr:2024 pid:795616425 +hcl:#7d3b0c +ecl:gry + +cid:236 byr:1985 hgt:160cm +hcl:#6b5442 eyr:2028 +ecl:gmt pid:277781460 iyr:2018 + +ecl:amb +byr:1948 pid:750948701 eyr:2025 iyr:2013 hgt:62in hcl:#7d3b0c + +eyr:2029 iyr:2020 pid:385941629 byr:1998 hgt:153cm cid:321 +hcl:#623a2f + +byr:1966 hgt:69in iyr:2012 +pid:423254216 +eyr:2020 hcl:#602927 ecl:blu + +byr:2004 pid:14257358 cid:338 iyr:2010 +ecl:gry +hcl:#602927 +hgt:152cm + +ecl:gry eyr:2027 hcl:#341e13 +iyr:2018 pid:298762877 hgt:162cm byr:1968 + +hcl:#ceb3a1 +iyr:2019 ecl:brn eyr:2020 pid:575413143 byr:2030 hgt:185cm +cid:159 + +eyr:2025 pid:628251539 ecl:blu byr:1953 hgt:63in hcl:#18171d iyr:2016 + +pid:973247326 byr:1925 hcl:#341e13 ecl:grn eyr:2028 hgt:156cm +iyr:2014 + +byr:1957 hgt:154cm +hcl:#7d3b0c +pid:062760305 eyr:2023 ecl:brn +iyr:2012 + +ecl:brn eyr:2029 +cid:250 +pid:477431667 hgt:177cm +byr:1993 iyr:2020 hcl:#ceb3a1 + +pid:155471269 iyr:2010 byr:1985 hgt:169cm eyr:2026 hcl:#694b7d cid:337 ecl:gry + +ecl:grt hgt:152in byr:2012 +pid:#b9d022 iyr:2030 +eyr:2037 hcl:z cid:201 + +hcl:9270b3 eyr:2028 +hgt:71cm iyr:2017 pid:#6c7af7 ecl:grn byr:1971 + +pid:#0ab7e1 hgt:166cm byr:1929 +cid:289 +hcl:#623a2f iyr:2005 +ecl:amb + +pid:967754435 +hgt:175cm hcl:#341e13 ecl:utc iyr:2023 eyr:1949 byr:1988 + +byr:1942 ecl:brn eyr:2023 pid:898126666 hgt:182cm cid:138 +hcl:#866857 +iyr:2010 + +eyr:2027 iyr:2019 byr:1953 pid:760664328 hcl:#b6652a +ecl:grn hgt:155cm + +iyr:2018 +ecl:brn hcl:#18171d pid:953129359 hgt:167cm eyr:2030 byr:1974 + +cid:77 +pid:975070417 hcl:#b6652a ecl:amb iyr:2013 byr:1995 +eyr:2025 hgt:184cm + +hgt:168cm +eyr:2026 byr:1938 ecl:gry pid:037135813 hcl:#6b5442 +iyr:2010 + +iyr:2017 hcl:4cc74b byr:1980 hgt:176in +pid:460622356 ecl:xry eyr:2030 + +hcl:z +ecl:oth pid:872514537 hgt:175in eyr:1984 iyr:2011 cid:145 byr:2024 + +iyr:2014 ecl:blu +pid:332729196 hgt:63in +eyr:2020 +hcl:#602927 + +hcl:#7d3b0c pid:369981570 byr:1996 ecl:gry +eyr:2024 iyr:2017 + +pid:446117373 hgt:158cm +iyr:2010 ecl:gry eyr:2024 hcl:#e54715 + +cid:341 pid:842156559 +hgt:167cm hcl:#602927 byr:1939 ecl:amb iyr:2016 + +byr:2017 +cid:176 +ecl:#9e42ae iyr:2029 pid:8965345 eyr:2038 hcl:z +hgt:116 + +eyr:2027 iyr:2014 hcl:#ceb3a1 +cid:280 pid:871521406 ecl:oth byr:1957 hgt:166cm + +cid:303 iyr:2019 +eyr:2021 pid:579593282 ecl:gry hcl:011a46 byr:1981 +hgt:184cm + +iyr:2015 byr:1936 cid:61 ecl:brn pid:307248029 hgt:172cm hcl:#18171d eyr:2029 + +pid:708687506 ecl:brn hcl:#602927 +iyr:2014 byr:1987 +hgt:193cm +eyr:2021 + +ecl:gry +iyr:2015 hcl:#efcc98 byr:1950 +cid:150 eyr:2023 pid:569864726 +hgt:161cm + +byr:1920 hcl:#602927 iyr:2018 +ecl:gry eyr:2020 +hgt:192cm pid:020336420 + +hcl:#539335 byr:1949 +hgt:152cm +cid:95 pid:002018679 +eyr:2030 iyr:2015 ecl:brn + +hcl:#b6652a eyr:2023 +pid:515291463 iyr:2013 byr:1990 +ecl:blu hgt:160cm + +eyr:2030 iyr:2012 +ecl:grn pid:416049447 hgt:188cm +hcl:#a97842 byr:1976 + +iyr:2017 hgt:61in ecl:oth byr:2001 eyr:2028 +hcl:#733820 +pid:078720467 + +eyr:2021 hgt:151cm iyr:2020 +hcl:#efcc98 ecl:oth +byr:1985 +pid:876231883 + +iyr:2019 hcl:#ceb3a1 hgt:156in +eyr:2004 pid:093465895 ecl:amb byr:2026 + +pid:103964845 hgt:178cm cid:320 ecl:oth +hcl:#fffffd byr:2002 eyr:2021 iyr:2019 + +ecl:brn byr:1920 pid:499363957 +cid:217 hcl:#341e13 hgt:164cm +iyr:2017 eyr:2028 + +ecl:brn pid:5837609946 iyr:2011 +byr:1971 eyr:2030 hgt:189cm +hcl:#866857 + +byr:1974 iyr:2015 hcl:#cfa07d +hgt:190cm ecl:grn pid:330115418 eyr:2020 cid:173 + +iyr:2010 +eyr:2024 byr:1943 pid:227557868 +cid:102 hgt:72in +hcl:#6b5442 + +hgt:151cm byr:1994 +pid:050723476 +cid:104 iyr:2010 hcl:#b6652a +ecl:brn eyr:2030 + +ecl:gry byr:1942 +hcl:#c5e354 hgt:192cm iyr:2019 +eyr:2027 pid:192177566 + +ecl:hzl hcl:#c0946f byr:1997 pid:853199076 hgt:166cm +iyr:2019 +eyr:2020 +cid:329 + +eyr:2027 iyr:2029 hcl:#602927 +pid:#1b8593 byr:2028 hgt:172in ecl:grn + +eyr:2036 iyr:2030 ecl:utc +pid:22330365 hcl:z byr:2016 hgt:65cm + +pid:936740771 +ecl:grn byr:1976 +hcl:#602927 +iyr:2017 hgt:192cm +cid:257 eyr:2027 + +eyr:2021 pid:415535681 +hcl:#b6652a hgt:191cm +ecl:hzl +iyr:2013 byr:1985 + +hgt:193cm +pid:499609129 +iyr:2014 ecl:oth +eyr:2029 hcl:#cfa07d byr:1973 + +ecl:gry byr:1996 cid:85 hgt:174cm iyr:2013 pid:444611265 hcl:#6b5442 eyr:2028 + +pid:170343402 +iyr:2029 +hgt:167cm +byr:2016 eyr:2034 ecl:hzl hcl:z cid:254 + +hcl:4893d5 ecl:blu byr:1960 +eyr:2027 pid:573029479 iyr:1952 hgt:74in + +eyr:2021 hgt:192cm pid:729836929 iyr:2020 byr:1973 +cid:155 ecl:grn hcl:#602927 + +hcl:#a97842 byr:1946 +iyr:2018 cid:172 hgt:162cm eyr:2030 ecl:amb pid:028768413 + +iyr:2020 hcl:#c0946f ecl:grn pid:601040247 cid:237 hgt:177cm eyr:2024 +byr:1941 + +iyr:2014 byr:1959 +eyr:2028 +hcl:#fffffd +ecl:#7df42b cid:165 hgt:68cm + +byr:1944 hcl:#18171d +pid:009636175 hgt:155cm ecl:amb eyr:2032 iyr:2015 + +byr:1987 hgt:150cm +hcl:#b6652a eyr:2021 +ecl:blu +pid:723709387 iyr:2017 + +byr:1937 ecl:oth eyr:2022 hcl:#733820 pid:143694811 cid:175 hgt:150cm + +pid:562911401 +cid:80 hgt:61in byr:1922 eyr:2027 ecl:amb iyr:2014 +hcl:#602927 + +iyr:2013 ecl:amb pid:826291674 hcl:#ceb3a1 eyr:2021 byr:1968 hgt:75in + +hcl:#5e0e07 +hgt:164cm pid:572114080 eyr:2028 iyr:2016 +byr:1922 ecl:oth + +ecl:blu eyr:2029 hgt:155cm +byr:1950 hcl:#866857 cid:271 iyr:2015 +pid:216813084 + +iyr:2018 byr:2009 cid:212 ecl:#71a98c pid:3467231102 hcl:z hgt:173cm +eyr:2026 + +eyr:1945 cid:302 iyr:2030 +hcl:z pid:0411732179 +byr:2004 hgt:165in +ecl:grt + +iyr:2010 hgt:169cm +hcl:#ceb3a1 +eyr:2022 pid:659709686 ecl:hzl +byr:1931 + +hcl:z pid:5077677466 +eyr:2021 hgt:184cm +iyr:1973 +byr:2009 ecl:#35575e + +hgt:190cm cid:103 iyr:2018 +byr:1970 ecl:gry +eyr:2028 +pid:549406360 hcl:#18171d + +byr:1964 eyr:2023 iyr:2015 hgt:174cm pid:305268492 +hcl:#b98e00 ecl:blu + +hgt:162cm +ecl:brn iyr:2019 byr:1951 +cid:169 pid:755632568 eyr:2030 hcl:#ceb3a1 + +iyr:2010 ecl:oth hgt:192cm eyr:2025 +hcl:#efcc98 pid:003868873 byr:1925 + +hcl:z +ecl:gmt hgt:62 eyr:1991 +byr:2012 +iyr:2025 pid:1835041269 + +hgt:162 +iyr:2026 byr:2024 +pid:6463124513 hcl:#602927 ecl:oth eyr:2028 + +hcl:bfb027 iyr:1945 byr:1989 eyr:1944 pid:826897563 ecl:dne cid:117 hgt:177 + +hcl:#b6652a iyr:2013 +ecl:blu byr:1952 eyr:2020 pid:737726601 cid:308 +hgt:167cm + +eyr:2028 iyr:2012 hcl:#6b5442 +byr:1986 ecl:blu +pid:365821409 hgt:180cm + +hgt:101 eyr:2037 pid:2457985649 +ecl:gmt +hcl:4c0784 iyr:2029 + +hcl:#341e13 iyr:1954 ecl:dne byr:2007 +eyr:2028 pid:552497791 hgt:189cm cid:263 + +ecl:blu +hgt:71in pid:360012597 eyr:2029 hcl:#18171d byr:1949 +iyr:2014 + +hgt:164cm cid:237 iyr:2016 byr:1966 +hcl:#623a2f ecl:oth +pid:129809894 eyr:2027 + +hcl:a2243b eyr:2031 +ecl:#de9183 +byr:1982 hgt:109 iyr:1968 pid:848311277 + +eyr:1950 +hcl:45470a byr:1983 +pid:82580746 cid:321 +hgt:191cm ecl:dne iyr:2013 + +iyr:2018 ecl:blu eyr:2021 +byr:1983 pid:045613120 + +hgt:164cm byr:1926 +hcl:#cfa07d +eyr:2030 +iyr:2010 +pid:360787918 cid:61 ecl:amb + +pid:#d6dddd iyr:1967 ecl:gmt hcl:z byr:1947 eyr:1943 cid:93 hgt:97 + +ecl:oth hgt:172cm +hcl:#efcc98 byr:1957 +pid:729531506 iyr:2017 +eyr:2030 + +ecl:#5a51b9 byr:2023 eyr:2021 iyr:2027 +pid:174cm hgt:80 hcl:6b4f6e + +hgt:157cm +ecl:amb +eyr:2020 pid:994733990 iyr:2020 cid:174 byr:1966 +hcl:#7d3b0c + +eyr:1986 +byr:2020 hcl:#c0946f +pid:499981246 +iyr:1926 cid:214 ecl:amb hgt:161cm + +hcl:#18171d byr:1971 +pid:#ef8a06 +eyr:2019 ecl:blu +hgt:158cm iyr:2011 + +byr:1959 cid:298 pid:876132993 +ecl:blu iyr:2011 hgt:176cm +hcl:#6b5442 eyr:2030 + +eyr:2030 +byr:1926 hcl:#733820 iyr:2017 +hgt:150cm pid:165cm ecl:blu + +byr:1991 eyr:2027 +hgt:183cm +pid:178cm +ecl:grn hcl:8a6142 iyr:2017 +cid:265 + +hgt:183cm +eyr:2027 hcl:#602927 pid:530884763 byr:1959 ecl:brn iyr:2013 + +hcl:#b6652a eyr:2030 hgt:171cm cid:97 byr:2002 pid:166795809 +ecl:hzl +iyr:2016 + +pid:479944517 hgt:166cm byr:1976 eyr:2022 hcl:#a97842 +ecl:grn iyr:2018 + +byr:1949 +eyr:2013 +hcl:z ecl:hzl +pid:152cm hgt:139 iyr:1962 + +pid:278193062 hcl:#c0946f iyr:2013 byr:1950 eyr:2020 hgt:167cm +ecl:oth + +eyr:1955 +iyr:2018 pid:#ffd4de byr:1922 hgt:178cm hcl:z +ecl:lzr +cid:154 + +ecl:grn hcl:#a189d5 byr:1977 pid:120286096 +eyr:1966 +hgt:178cm +iyr:2011 + +eyr:2028 +hcl:#fffffd iyr:2013 byr:1956 pid:565425333 cid:207 ecl:gry hgt:67in + +hgt:188cm eyr:2028 cid:90 +iyr:2019 pid:574624890 hcl:#b6652a byr:1937 ecl:oth + +hcl:#efcc98 hgt:152cm ecl:hzl iyr:2010 cid:217 byr:1936 eyr:2027 pid:857984889 + +hgt:124 iyr:2015 byr:1989 ecl:oth eyr:2023 hcl:#ceb3a1 pid:917440765 + +ecl:#61e880 cid:82 +pid:165cm byr:2019 eyr:1930 hgt:152in hcl:z iyr:2030 + +byr:1974 +hgt:60in ecl:gry +hcl:#c0946f +pid:215085889 +iyr:2017 eyr:2020 + +ecl:grn hcl:#ceb3a1 +pid:602147794 hgt:180cm eyr:2028 byr:1927 iyr:2018 + +hcl:#ceb3a1 byr:1958 ecl:gry +pid:210246609 iyr:2018 hgt:169cm +eyr:2023 +cid:255 + +eyr:2025 +byr:1950 hgt:177cm +ecl:gry pid:547034188 +iyr:2018 +cid:218 hcl:#341e13 + +pid:380369950 +eyr:2022 hgt:65in iyr:2019 ecl:brn +byr:1996 + +hgt:167cm +iyr:2014 +eyr:2029 cid:199 pid:144048588 byr:1963 ecl:oth hcl:#733820 + +byr:1962 ecl:brn hgt:161cm eyr:2022 hcl:#cfa07d +pid:247699670 iyr:2016 + +hgt:192cm ecl:#8bdb3e pid:#b152a9 hcl:#18171d iyr:2012 byr:2011 cid:335 eyr:2040 + +hcl:11f8f4 ecl:#86f885 iyr:2022 +hgt:75in +pid:920078124 byr:1952 eyr:1994 + +pid:718378772 cid:282 +hcl:#fffffd hgt:166cm eyr:2023 iyr:2019 byr:1944 +ecl:grn + +eyr:1963 pid:562051556 +ecl:#793853 +hcl:z byr:2030 iyr:2026 + +byr:1980 +cid:143 hgt:161cm eyr:2022 +pid:778422225 +hcl:#7d3b0c iyr:2011 ecl:blu + +byr:1940 eyr:2021 hgt:74in cid:161 hcl:#a97842 ecl:blu +pid:864682628 iyr:2014 + +byr:1991 pid:163871357 ecl:oth +hgt:189cm cid:229 eyr:2024 +hcl:#efcc98 +iyr:2012 + +iyr:2013 hcl:#ceb3a1 ecl:hzl byr:1985 pid:801995950 hgt:73in +eyr:2029 + +byr:1931 hcl:#ceb3a1 iyr:2013 +cid:289 eyr:2027 ecl:blu +hgt:150cm pid:969679765 + +iyr:2015 hgt:176cm eyr:2025 ecl:blu +byr:1935 pid:388582890 hcl:#efcc98 + +iyr:1956 eyr:2034 pid:049440894 ecl:xry byr:1950 cid:228 +hgt:186cm + +iyr:2014 hcl:#fffffd byr:1985 +eyr:2022 +hgt:176cm pid:556889061 ecl:amb + +pid:994755123 hgt:165cm +ecl:brn +eyr:2022 byr:1937 iyr:2011 + +byr:2012 +hcl:z cid:217 iyr:1958 +ecl:brn hgt:160cm +pid:871866608 +eyr:2027 + +hcl:#a97842 +ecl:hzl byr:1929 +iyr:2016 +eyr:2029 pid:220410871 hgt:192cm + +pid:332596122 byr:1986 +hcl:#cfa07d +eyr:2022 hgt:189cm ecl:grn iyr:2016 + +hgt:167cm +hcl:#6b5442 eyr:2026 +iyr:2020 ecl:grn cid:231 pid:521486150 + +cid:299 +hgt:178cm byr:1945 ecl:brn iyr:2012 +hcl:#fffffd eyr:2022 +pid:264693268 + +ecl:lzr pid:157cm hcl:f0a766 +iyr:2029 hgt:175in byr:2004 + +hcl:#888785 +hgt:159cm eyr:2025 +iyr:2012 ecl:oth +byr:1995 pid:135442622 + +eyr:2024 hcl:#a97842 +iyr:2013 pid:186863004 ecl:brn byr:1929 hgt:162cm + +pid:518619727 ecl:grn +hcl:#866857 byr:1954 +iyr:2016 +hgt:69in + +eyr:2022 iyr:2018 +byr:1926 +ecl:oth pid:073817633 +hgt:167cm hcl:#b6652a + +hgt:190cm iyr:2019 +ecl:dne byr:2010 eyr:2023 pid:979671212 + +hgt:190 +ecl:#5ddbda byr:2025 iyr:1973 pid:#a082dc eyr:1998 cid:177 hcl:z + +iyr:1976 eyr:2026 pid:4862485 hgt:71in +byr:1975 ecl:#41855f hcl:#ceb3a1 + +ecl:brn +byr:1927 iyr:2012 hgt:67in +pid:479646443 eyr:2039 hcl:z + +pid:779458123 +cid:263 hcl:#efcc98 +byr:1951 +hgt:153cm iyr:2011 +ecl:amb eyr:2030 + +hgt:187cm +eyr:2028 +byr:1957 +hcl:#b6652a iyr:2015 pid:616963706 ecl:brn + +hgt:154cm byr:1947 +pid:51196404 +eyr:2020 iyr:2001 +ecl:hzl + +hgt:157cm iyr:2013 eyr:2021 +ecl:blu hcl:d9e6e0 +byr:2023 + +iyr:2010 +hcl:#866857 +ecl:brn eyr:2022 +cid:163 byr:1962 pid:458396337 hgt:160cm + +ecl:amb eyr:2027 +byr:1987 +hgt:184cm +pid:125222897 cid:214 +iyr:2020 + +ecl:grt eyr:1942 +iyr:2023 +hcl:901862 hgt:159in +byr:2009 + +eyr:2028 +byr:1973 hgt:151cm iyr:2013 ecl:hzl pid:229165831 + +eyr:2024 hgt:190cm ecl:grn byr:1962 iyr:1921 pid:531272718 hcl:#ceb3a1 + +hgt:169in pid:1747598652 ecl:dne +iyr:1974 eyr:2031 hcl:#602927 byr:2030 + +hgt:177cm iyr:1963 eyr:2006 +cid:276 hcl:#7d3b0c +pid:192cm +ecl:grn byr:2022 + +pid:893346945 hcl:#733820 ecl:oth iyr:2013 byr:1973 hgt:186cm eyr:2025 + +hgt:177cm +eyr:2025 +byr:1997 hcl:#733820 +cid:295 iyr:2016 pid:019887743 ecl:grn + +iyr:2019 +byr:1982 eyr:2030 ecl:brn pid:041140029 hcl:#a97842 hgt:189cm + +pid:165cm iyr:1962 hcl:e5c590 ecl:#e394a4 +eyr:2040 +hgt:70cm byr:2006 + +byr:1940 eyr:2025 iyr:2020 hcl:#a97842 ecl:brn pid:502841851 cid:121 +hgt:160cm + +eyr:2015 ecl:zzz hgt:174 pid:154cm iyr:2021 +hcl:z +cid:113 +byr:2003 + +iyr:2020 +eyr:2023 pid:402183362 hcl:#120eb2 +ecl:amb +hgt:150in +byr:1921 + +pid:059311672 cid:290 hcl:#7d3b0c byr:1996 +iyr:2021 hgt:155cm ecl:hzl eyr:2030 + +pid:790768270 hgt:167cm ecl:gry +byr:1973 +hcl:#b6652a eyr:2028 iyr:2017 + +hcl:#18171d eyr:2024 pid:062349624 +byr:2002 iyr:2019 cid:230 ecl:oth + +iyr:2015 +hgt:170cm +cid:193 +eyr:2025 ecl:hzl byr:1947 +pid:484823445 +hcl:#623a2f + +pid:5792950369 cid:343 +hcl:1d16b7 eyr:2024 +hgt:185in iyr:1965 +ecl:gmt byr:1948 + +pid:#a1a101 +ecl:grn +byr:1945 +iyr:2013 hcl:#ceb3a1 hgt:156cm cid:279 eyr:2026 + +pid:936593230 eyr:2026 hgt:179cm +hcl:#7d3b0c +iyr:2015 byr:1976 +ecl:gry + +eyr:2021 pid:210678956 hgt:153cm cid:72 iyr:2018 ecl:grn + +pid:995512119 +byr:1937 eyr:2021 hcl:#4d8fe2 ecl:brn +iyr:2019 +hgt:187cm + +hcl:#341e13 pid:282336259 eyr:2022 +cid:95 byr:1977 hgt:101 ecl:#955529 +iyr:2029 + +pid:934992980 hcl:#fffffd iyr:2028 eyr:1945 ecl:gry byr:1926 + +iyr:2018 ecl:gry +hgt:179cm hcl:#866857 pid:573616710 +byr:1987 + +byr:2010 eyr:2021 hcl:z pid:018180068 hgt:74 +cid:183 iyr:2027 ecl:dne + +iyr:2020 hgt:160cm +pid:760124779 hcl:#b6652a ecl:grn eyr:2030 byr:1951 + +pid:354858055 ecl:hzl hgt:192cm +hcl:#ceb3a1 byr:1983 cid:314 +iyr:2016 eyr:2027 + +eyr:2028 iyr:2013 hgt:171cm hcl:54be83 ecl:xry byr:2021 +pid:89895052 + +byr:1963 iyr:2019 +pid:298992037 eyr:2024 +hgt:63in hcl:#341e13 + +hgt:64cm +pid:7645482607 ecl:#c94773 cid:231 hcl:621e9d eyr:2000 byr:2013 + +hcl:#ceb3a1 ecl:gry iyr:2015 hgt:178cm byr:1945 +pid:416960939 + +hgt:178cm +cid:121 +byr:1961 iyr:2019 hcl:#6b5442 +eyr:2028 pid:098226989 + +iyr:2015 eyr:2028 +ecl:amb +hgt:154cm +pid:364426658 byr:1960 +hcl:#623a2f + +byr:1998 +pid:#e5ab03 hcl:z ecl:grn +iyr:2006 hgt:61cm eyr:2038 + +hcl:#866857 eyr:2020 +hgt:187in +pid:#8239dc iyr:2010 ecl:#6259e7 byr:1939 + +pid:#6082fa eyr:2028 ecl:gry hcl:937410 iyr:2010 +hgt:173cm + +eyr:1922 ecl:grt pid:228396726 hgt:65cm +hcl:#6b5442 byr:2024 iyr:2010 + +hcl:#c0946f iyr:2016 byr:1978 +pid:774430678 eyr:2026 +ecl:oth hgt:61in + +cid:208 pid:714195768 iyr:2019 eyr:2022 byr:1937 ecl:gry hcl:#ceb3a1 hgt:159cm + +eyr:2028 ecl:gry iyr:2010 byr:2001 hgt:163cm pid:409136005 hcl:#623a2f cid:200 + +pid:471094613 eyr:2028 hgt:165cm iyr:2010 ecl:amb byr:1995 hcl:#a97842 + +ecl:oth iyr:2011 pid:907249487 eyr:2020 +byr:1924 cid:68 hcl:#a97842 +hgt:155cm + +byr:1983 +hgt:69cm +eyr:2027 iyr:2010 hcl:#866857 +pid:671371092 +ecl:amb + +hgt:97 pid:168cm cid:67 +eyr:1957 hcl:#623a2f byr:2027 ecl:gry iyr:2019 + +ecl:blu iyr:2012 pid:287999130 hgt:178cm eyr:2020 +byr:1940 +hcl:#888785 + +hcl:z hgt:63cm ecl:grt +iyr:2024 eyr:2031 pid:167cm +byr:2013 + +hgt:65in hcl:z cid:300 ecl:amb pid:58257193 +byr:1969 iyr:2011 eyr:1985 + +hcl:#341e13 eyr:2036 hgt:189in +pid:58541401 +ecl:#d793f2 iyr:2010 byr:2006 + +cid:259 ecl:grn +hcl:#a97842 +hgt:167cm +pid:641690548 eyr:2021 +byr:1930 +iyr:2010 + +eyr:2027 +hgt:75in +cid:335 hcl:#602927 iyr:2012 ecl:blu pid:724014178 +byr:1928 + +eyr:2027 +hcl:#8345d8 ecl:grn byr:1965 pid:728151722 +hgt:182cm iyr:2016 + +iyr:2020 pid:794922933 +hcl:#341e13 +ecl:oth +byr:1985 +hgt:71in +eyr:2022 + +ecl:#025c94 +hcl:#fffffd +iyr:2027 +byr:1987 hgt:186cm cid:135 pid:005852205 +eyr:2021 + +byr:2020 +ecl:grn +pid:91200233 +iyr:2014 eyr:2020 hgt:179cm hcl:be0c95 + +ecl:gmt iyr:2010 pid:171cm byr:2010 eyr:2036 hgt:159in hcl:424df0 + +ecl:gry iyr:2013 hcl:#7d3b0c hgt:175cm pid:337611432 byr:1953 eyr:2021 + +byr:1926 pid:678688040 +hcl:#cfa07d +cid:311 eyr:2027 hgt:183cm iyr:2018 +ecl:blu + +byr:2021 +pid:156cm +ecl:dne +hgt:156cm +hcl:#6b5442 +iyr:2027 + +pid:380639402 eyr:2025 +cid:196 +hgt:163cm +hcl:#602927 ecl:hzl +iyr:2015 + +eyr:2039 hcl:5aa018 byr:2007 ecl:dne +hgt:77 pid:#d30c1c iyr:2025 + +ecl:blu +iyr:1986 pid:3544865154 eyr:2027 byr:2007 hgt:74cm hcl:ca33b3 + +pid:#b05294 byr:1951 hcl:#ceb3a1 cid:221 +iyr:2000 hgt:110 eyr:2021 + +byr:1954 hcl:#efcc98 iyr:2018 ecl:#f4ea81 +pid:414210788 hgt:174cm eyr:2037 + +pid:#abbdd9 +hgt:164in +iyr:2003 cid:319 eyr:2035 +byr:2015 +ecl:#9b38c7 + +ecl:amb +iyr:2018 byr:1922 +hgt:157cm pid:801421993 eyr:2029 +hcl:#efcc98 + +eyr:2022 +hcl:#b6652a +ecl:amb byr:1942 +hgt:153cm iyr:2018 +pid:805225382 + +byr:1925 +hcl:#efcc98 ecl:amb pid:539625393 cid:269 +hgt:161cm iyr:2013 eyr:2025 + +cid:305 hgt:154cm +hcl:#18171d byr:1998 +eyr:2029 iyr:2011 pid:634235387 ecl:gry + +hcl:#6b5442 pid:504467634 iyr:2018 cid:96 byr:1970 +ecl:gry eyr:2023 hgt:167cm + +iyr:2020 hgt:163cm hcl:#fffffd pid:762271916 byr:2029 eyr:2022 +ecl:#12027c + +byr:1978 +cid:134 hcl:#6b5442 +iyr:2010 pid:627335191 ecl:blu eyr:2023 hgt:171cm + +pid:260340768 hcl:#a97842 byr:1947 ecl:#2150e3 iyr:2019 +cid:153 +hgt:65in eyr:2025 + +byr:1973 eyr:2022 +cid:229 pid:515108192 ecl:amb hcl:z +iyr:2013 hgt:178cm + +ecl:hzl +hgt:158cm hcl:#a97842 +pid:657117959 byr:1977 eyr:2023 iyr:2018 + +ecl:gry eyr:2024 +hgt:163cm byr:1976 iyr:2017 +pid:653769092 hcl:#18171d + +ecl:amb pid:161694953 +hcl:#602927 hgt:188cm eyr:2021 byr:1946 +iyr:2016 + +eyr:2021 +hgt:178cm ecl:grn +byr:1961 pid:472866063 iyr:2011 hcl:#cfa07d cid:160 + +eyr:2037 iyr:2011 +hgt:187cm byr:1973 pid:163cm hcl:#b6652a +ecl:brn cid:283 + +iyr:2017 hcl:#18171d eyr:2020 pid:059926864 hgt:160cm ecl:brn + +byr:2010 +hcl:8217d4 hgt:153in iyr:1989 eyr:2037 pid:#74e0a4 ecl:#ba5782 + +ecl:#28f922 +byr:1951 hgt:65cm +iyr:2025 pid:151cm hcl:z eyr:2028 + +pid:302959013 +hgt:167cm eyr:2022 ecl:hzl iyr:2014 +cid:168 +hcl:#888785 byr:1969 + +pid:013861920 hcl:#623a2f +ecl:gry +byr:1928 +iyr:2017 hgt:174cm eyr:2028 cid:250 + +byr:1997 hgt:74cm hcl:#efcc98 eyr:2039 ecl:#d3dc6a +cid:243 +iyr:2030 pid:189cm + +hgt:67cm byr:2011 eyr:2040 pid:192cm ecl:#b7a5a8 hcl:281b25 + +iyr:2014 ecl:brn byr:1954 hcl:#fffffd pid:285922660 hgt:76in eyr:2028 + +iyr:2021 byr:2028 +eyr:2023 +hgt:69in hcl:e832ef pid:714568559 ecl:#f10004 cid:208 + +ecl:brn hgt:166cm hcl:#cfa07d +cid:59 pid:4884483993 +iyr:2012 +eyr:1932 + +iyr:2029 byr:2025 +cid:238 ecl:utc +eyr:2022 +pid:887425834 hgt:177in + +pid:014383055 cid:342 hgt:183cm eyr:2025 +iyr:2014 ecl:blu byr:1969 hcl:#7d3b0c + +eyr:2033 +hcl:#341e13 +iyr:2014 +hgt:71cm ecl:#750eec +byr:1980 pid:#e2d3ac + +hgt:154cm iyr:2019 hcl:#341e13 ecl:hzl byr:1942 pid:393181243 eyr:2025 +cid:316 + +ecl:amb +hgt:158cm +eyr:2025 byr:1986 hcl:#fffffd pid:379180765 iyr:2014 + +pid:8191674491 eyr:2028 hcl:#efcc98 byr:2015 iyr:2012 +ecl:amb cid:140 + +byr:2015 hcl:8e3e81 eyr:2024 hgt:180cm iyr:1984 pid:#56cd0e +ecl:zzz + +pid:247138863 eyr:2022 hgt:176cm iyr:2014 byr:1929 +ecl:gry cid:87 hcl:#b6652a + +hcl:z pid:#c4cdee ecl:#ca97a6 byr:1971 eyr:2032 +iyr:1997 hgt:156in + +ecl:gry +hgt:167cm eyr:2030 byr:1984 hcl:#cfa07d iyr:2016 + +hcl:#a97842 hgt:163cm +pid:373461578 iyr:2017 +byr:1926 ecl:amb +eyr:2021 + +cid:161 hcl:#b6652a byr:1930 ecl:brn eyr:2028 hgt:166cm iyr:2016 + +ecl:amb cid:126 +eyr:2024 +hcl:#18171d iyr:2019 +byr:1991 hgt:183cm + +ecl:lzr iyr:2026 byr:1996 +hgt:69in pid:#ccef7e eyr:2028 +hcl:#fffffd + +hgt:68cm iyr:1945 +ecl:brn byr:2009 pid:#56e987 hcl:fdd212 eyr:2023 + +pid:72039060 eyr:2036 hgt:172cm +hcl:#fffffd iyr:2011 +byr:1944 ecl:xry cid:202 + +ecl:hzl +eyr:2025 +byr:1922 hcl:#efcc98 +pid:795790549 +iyr:2020 hgt:150cm + +hgt:155cm +hcl:#373de2 pid:#707dc6 iyr:2017 byr:2002 eyr:2038 +ecl:oth + +hcl:#888785 iyr:2011 +hgt:159cm +byr:1962 eyr:2026 ecl:amb pid:672792762 + +cid:217 eyr:2025 hgt:164cm byr:1999 pid:975218035 ecl:grn hcl:#18171d iyr:2011 + +pid:655501194 eyr:2029 byr:1999 iyr:2013 +hgt:183cm hcl:#a97842 ecl:hzl + +byr:1986 hcl:#efcc98 pid:160cm ecl:oth eyr:2022 iyr:2022 hgt:150cm +cid:63 + +hgt:69in byr:2002 pid:0528229881 ecl:blu hcl:z iyr:2022 +eyr:2033 + +iyr:2020 pid:007754028 hcl:z cid:232 ecl:dne hgt:73in + +ecl:hzl +iyr:2016 hcl:#7d3b0c byr:1948 +eyr:2021 +cid:269 hgt:173cm pid:176430746 + +cid:310 +ecl:xry +eyr:2032 hgt:64cm +pid:190cm hcl:z byr:2019 + +hgt:150cm pid:660176034 hcl:#c0946f +ecl:hzl byr:1986 eyr:2021 iyr:2019 + +pid:7876582 +eyr:2021 iyr:2020 +hgt:185cm hcl:#18171d cid:319 ecl:amb byr:1943 + +ecl:hzl hcl:#623a2f iyr:1950 byr:2012 cid:334 eyr:2028 + +eyr:2028 +byr:1992 hcl:#b6652a ecl:hzl cid:222 +hgt:189cm iyr:2016 +pid:092856842 + +hcl:a3c52a +iyr:2025 byr:2023 +hgt:182cm ecl:#be1503 pid:9311657615 eyr:2005 + +eyr:2035 +byr:1988 hgt:193cm +iyr:2028 cid:128 hcl:#18171d ecl:utc pid:9743739773 + +ecl:zzz hcl:z +hgt:64cm pid:160cm byr:2026 eyr:1943 iyr:2028 cid:74 + +ecl:oth +pid:874577361 +iyr:2010 eyr:2021 +hgt:160cm hcl:#c0946f +byr:1959 diff --git a/day4/program.js b/day4/program.js new file mode 100644 index 0000000..2530f7e --- /dev/null +++ b/day4/program.js @@ -0,0 +1,94 @@ +const fs = require('fs'); + +fs.readFile('./input.txt', 'utf-8', (e, data) => { + const start = Date.now(); + const items = data.split("\n"); + const rawPassports = findPassports(items); + const passportsCheck1 = splitPassportData(rawPassports); + + const toValidatePart2 = []; + + passportsCheck1.forEach((p, i) => { + if (validatePassport(p)) { + toValidatePart2.push(p); + } + }); + + console.log(`Part1: Found ${toValidatePart2.length} valid passports`); + + let validPassports = 0; + + toValidatePart2.forEach((p, i) => { + if (validatePassportProperties(p)){ + validPassports++; + } + }); + + console.log(`Part2: Found ${validPassports} valid passports`); + console.log(Date.now() - start); +}); + +function findPassports(data) { + const passports = []; + let passportdata = []; + data.forEach((row) => { + if (row.length === 0 && passportdata.length > 0) { + passports.push(passportdata); + passportdata = []; + } else { + passportdata.push(row); + } + }); + + return passports; +} + +function splitPassportData(raw) { + const passports = []; + raw.forEach(p => { + let passport = {}; + p.forEach(row => { + const parts = row.split(' '); + parts.forEach(part => { + let split = part.split(':'); + if (split[0] === 'byr' || split[0] === 'iyr' || split[0] === 'eyr' ) split[1] = parseInt(split[1]); + + passport[split[0]] = split[1]; + }) + }); + passports.push(passport); + }); + return passports; +} + +function validatePassport(passport) { + if (Object.keys(passport).length === 8) { + return true; + } + + if (Object.keys(passport).length === 7 && !passport.hasOwnProperty('cid')) { + return true; + } + + return false; +} + +function validatePassportProperties(passport) { + if (passport.byr > 2002 || passport.byr < 1920) return false; + if (passport.iyr > 2020 || passport.iyr < 2010) return false; + if (passport.eyr > 2030 || passport.eyr < 2020) return false; + if (!validateHeight(passport.hgt)) return false; + if (!passport.hcl.match(/#[0-9a-f]{6}/)) return false; + if (['amb','blu','brn','gry','grn','hzl','oth'].indexOf(passport.ecl) === -1) return false; + if (passport.pid.length != 9 || !passport.pid.match(/[0-9]{9}/)) return false; + return true; +} + +function validateHeight(height) { + let replace = height.indexOf('in') > -1 ? 'in' : 'cm'; + height.replace(replace,''); + height = parseInt(height); + if (replace === 'in' && (height > 76 || height < 59)) return false; + if (replace === 'cm' && (height > 193 || height < 150)) return false; + return true; +} \ No newline at end of file diff --git a/day5/input.txt b/day5/input.txt new file mode 100644 index 0000000..2e65bf1 --- /dev/null +++ b/day5/input.txt @@ -0,0 +1,888 @@ +BFBFBFFRRL +FFFFBBBLLL +FFFBBFBRRR +FFFFBBBRLR +FFBFFBBRRL +BFBBBBBRRR +BBFFFFFRLR +FFFFBBFRLR +BBFFFBBLLL +FBBBBFBLRL +FFBBFFBRLR +BBFFBBFRLL +BBFFFFFLRL +BBFFFFBRLR +BFFFFBFLLL +FFFBFFFRRL +FBBBBBBLLR +FFBFBBFRLL +FBBFFBFLRL +BFBFFBBRLR +BFFBFBBLRR +FFFBFFBRRL +FFBFFBFRLL +FBBBBBFLRL +FFBBFFFRRL +FFBFBFBLRR +BFFFFFBRRL +FFBFBBBRLR +FFFBFFFLRR +BBFFBFFLRR +BFFFBBBRLL +FFBBFFBLRL +BFBBFBFRRR +BFFBBBBLRL +FFBFBFBRLL +FBFFBBBRRR +FBFBBBF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FBRRL +FBBFFFFRLL +FFBBBFBLRL +BFFFBBBLLL +FFFFFBFLLL +BFBBBFBLLR +FFBBBFBLLL +FFFFFFBRRR +BFBBBFFRLR +FBBBFBBRLL +FFBFBBBRRL +FBBBFFFLRR +BBFFFBFLLL +FBBBBBBLRR \ No newline at end of file diff --git a/day5/program.js b/day5/program.js new file mode 100644 index 0000000..1c13684 --- /dev/null +++ b/day5/program.js @@ -0,0 +1,60 @@ +const fs = require('fs'); + +fs.readFile('./input.txt', 'utf-8', (e, data) => { + const boardingPasses = data.split("\n"); + let maxSeatID = 0; + const seatIDs = []; + boardingPasses.forEach(boardingPassCode => { + const [seat,row] = calculateSeatAndRow(boardingPassCode); + const seatID = row * 8 + seat; + if (seatID > maxSeatID) maxSeatID = seatID; + seatIDs.push(seatID); + }); + + console.log('max seat ID', maxSeatID); + + seatIDs.sort((a,b) => { + return a > b ? 1 : -1; + }); + + const mySeat = findMissingNumber(seatIDs); + + console.log('missing seat', mySeat); +}); + +function calculateSeatAndRow(boardingCode) { + let seat = [0,7]; + let row = [0,127]; + const chars = boardingCode.split(""); + + chars.forEach(c => { + // console.log(c, row); + if (c === 'F') { + row[1] = row[1] - Math.ceil((row[1] - row[0]) / 2); + } else if (c === 'B') { + row[0] = row[0] + Math.ceil((row[1] - row[0]) / 2) + } + + if (c === 'L') { + seat[1] = seat[1] - Math.ceil((seat[1] - seat[0]) / 2); + } else if (c === 'R') { + seat[0] = seat[0] + Math.ceil((seat[1] - seat[0]) / 2) + } + }); + if (row[0] === row[1]) row = row[1]; + if (seat[0] === seat[1]) seat = seat[1]; + + return [seat, row] +} + +function findMissingNumber(seatIDs) { + let curId = 0; + let yourSeat = 0; + seatIDs.forEach(id => { + if (curId === 0) return curId = id; + console.log(curId, id); + if (id - curId > 1) yourSeat = id -1; + curId = id; + }); + return yourSeat; +} \ No newline at end of file diff --git a/day6/input.txt b/day6/input.txt new file mode 100644 index 0000000..3fa5775 --- /dev/null +++ b/day6/input.txt @@ -0,0 +1,2040 @@ +gsvdkufnoawjmhp +wvhusojpnikgfadb +vshnpfedgwajkou +aujodhskfvnpgw +okpdnwhsfvjguqa + +juedvq +vqeduj +veqdju +eqduvj + +cdajbuernxm +mnucjearxbd +axrmdejuncb +jrebucmdxna + +kutplibdoqzfvhw +qcewmrkdvhl +qobdwvlkgxhpasyjn + +psbjhnatxe +pnaxesjhbt +tpxhbnseaj + +yskvjqacinfdrphwltxgzomueb +jwprnxzvkeofthuqbyimadgslc + +hzwepdg +lwf +wy +lw +rw + +sdgateubqmznhjk +xyphltd + +dbhl +hdlb +dbhl +hbld + +inkxywsbgjuvpztrecadqmhf +qkaxszcujwvmbhdietpgr +krupsdgibzecxwvhqatmj +qtpxerobhisgcumkwjvdaz + +bgakcmh +gxasvzu + +cjtrvhinaqsbpk +jvxtspaqbhkfnrc + +nab +bex +qmkudf + +uot +out +tuo +uto +out + +sbtkzf +hbkfzs +szbkf +fuzksbx +jskrzbf + +dkphfoybsagcrnq +oybunchapqrdks +bokpysdhqnarc + +bchumknwairvlf +cvbuhwzirkalfy + +bwnseiaoqyjf +josqanfbew +nealmqbfwojs +jqnbfaoesw + +sowzuji +wojizu +wzojiu +jwozui +ujiwoz + +kcopqbt +tpkudorbc +pmtwogjb + +uxkfthszqdbelomwri +tlusezbomwfqrdxhki +rsdfkbteoqilzmxhuw +bwkqmdsxhrfulietoz +izkwomsdlbfxetqhru + +kzhwyodlvpt +kvfhldwpo +lvhypokdw +opwjhvdkcl +kpahtdolvw + +cldyjpuitah +upcthlijyda +icdauhpytj +haypidtucj +jidaptcyhuo + +mi +ti +qjwiz +oudehsxyiv +bpirjl + +stlyornuk +cxapqwie + +kharunjiebzvoy +gvaihtklnqmcebf + +t +lt +t + +ohca +lznkumqfgyjsbeot +owxdivpr + +dy +yo +xsy +yo +pyrvh + +iaxp +afpikux + +hpsfqrnevzxl +fnrsvexzhqup + +cp +fpc +cp + +nbuojxgqckrwzspehf +mhguoxsfkejwcq +kedqujsomfxhwcvg +ouqefsxchgjkw +qcjohwxfseugk + +rybnlomq +fmxsngauo +embkon +nlmvob +bomhnv + +gptixlduzjeqkorsamwnh +pgzwohfjkuvbtylmc + +thcgo +vhrlxmo + +kbfgmhpzoqysac +ockazbsmhpgqfy +kmcqfyzhapgsxb +qcfdlwyarzuskhmbg + +surovlcihp +irvlpuhosc + +rd +d +td +d + +koasgulh +kroumtzl +yubkwolnpj + +dqykvasneb +easknpbovyjd + +wqvop +nwqvpo +wovfrqizh +onqpwv + +uskotfndjeplixhycbqrmw +mbxoewypcfdhistn +ydtvpbfemcnsihoxw +ynwbtosmcipxhfde + +urgvbqechawznsjltixody +swdbnevcatrflguhziyoqxj +sgiwelhanovrbjuzyqtdcx +vyenojuhxwzbtigsdqarkcl + +jxcwblszo +khrwvnbdolgjufyz + +n +r +d +r +bd + +tolrypvdwmb +lwrmopdvybt +rdybwmvplto +vlwpyrbmotd +ybolwtvprmd + +radvoplnq +lrqpondva +lpanovqrd +lpanvoqdr +dqorvalpn + +fvxca +vacfx +fvcxa + +jbeixdakgolpfhqyntw +purbsxvjfwhetlmcnz + +jztfgbmnkadiehv +djhpntcizmkgvbfe +btegdfknizvmhjl +igbdeztjfkhmnv +iqvtgejanzfdbhmk + +jpi +ijp +ijp + +kydp +viykd +dgyqmftwx +vdye + +sewpkrvh +ekorswnp + +bplerysifmzvwoncjxqk +nsbeqowitcpjymxvl + +nexbskamprd +xsmdbkaupner +dsbnekarctvmpx +nkapxcbsmrlde +ezfdhnakwrsmyxpb + +olnuzvxcgpdtfb +tgzcfdbnxp + +vjliksorxpmwecaznu +giuoxsvnzewljpmc + +fuljpkt +cplftukj +lfptjku +futpjlk + +tqcgihveyswu +ywvqecthgs +cqhwetvsyg +qvshwcegty +gyctwqsfvhe + +uhezlyxwvpcidr +hvucplszbxywer + +jchyntk +revwzsm +kdn + +cotikdlpxauzb +uxzptoksqbdiw + +nqvruwhtombs +tebfnykzmlgcj + +ciwkhzbmgfqo +uwmzgbcoihqkfs +fkwmziohcgbq + +shezgrvq +gprveokq + +jvqcdiuyrnpgh +dyjqvhrpic +xjiklpfzmthrwdsyqv +pdyvochrunaqjgi + +denpjgywacrk +jbypwarecukdgn +zacqyxdgejrmpwkfnh +uwldpkrgaenjcy + +q +mq +q + +d +c +d +d + +cdazeitlrpxnfqs +nrqxelfocsihpz +cnkveyiujlbzfgrpxq +cqznxrfliedp + +qicgkpjzlxonv +cijozlhkqxnp +pgkcnloyxzj +japmxlknszotc + +bytg +mwetjayhgiup +gyt +ygt +tyg + +zx +elxz +z +vncto + +nryw +rywn + +takqgijzforxpshm +ztmrxfqgsiphjaok + +fsaoqe +wcavsldeytn +auoekhzsi +hgseja + +whqyvldpintefaxgurjc +xluqrgsvnacykptefbdhmj + +oylknhsgmpawziqte +znhmatkpolsw +pkvmtznhlwsoa +onzamhltkpsw + +zs +zs +zs +sz + +e +a + +xmi +gahfrd +yt +jmy +nqy + +zkbtfdjom +ot +uoqtr +eot + +g +er +g +g + +ncvwupezd +cnvdwzpeu +cuwnzvedp +cdnzevwpu + +bkuwcsv +bqcsgwve +mbhcovjsw +qwrnbeycsv +lisvbwc + +vlys +omvzl +ptlejv +xylv +vxol + +mqgohwtz +rqomlcw + +rgopxhkslqcjmzbatnd +phgzmojlstadqrxkbn + +pcbziv +pivzbc +jilczbpv + +gmrecszl +zgrecslm +melzcrgs +gezcrlsm +mcsezrlg + +ceotvxaydplfiu +vbzcaxuokwd + +gy +g + +lj +neocbiqjt + +foyawivmhs +fayowsmzrv +mksfowvzayg + +sivthk +yh +lh +ybhq +hy + +fk +ka +vka +qhjxrzmckpb +kf + +s +s +s + +iyth +tyhri +yrtaih +htyi +utifydhq + +hwxd +xhwd +hxwdb + +kfhsvbjdwxcnt +dbfjhsctkvw +sogzdhjqiwmlyuvf + +v +nyx +v +i + +ncimwelvbudtp +piwvudaer + +aktpdrhm +dtapkhr +dhapktri +taprnhdko +krpdhta + +fvpaxk +zgmrwja +ar + +vxoisla +olisvxa +kioqvrlxjhsya +oixgalsv +savloix + +ac +gr +c +tl +c + +fndwqsruzagei +dwunqfaesgzri +bzarmfnqwuisgde + +jr +rj +jr +jr + +zrevhj +xigdmqatk +wjlpzvsy + +qijznvobp +nzbojivdpc +vzipojnb + +srbtecvpixam +hdvctplmfxuow + +bf +bf +bf +bfex + +g +g +g +g +mag + +b +y +b + +vmbwhdfiqteglnpkxucjoa +wmqdconxbuaetjlgphivkf +upadfnhkwtjioqcbvxelmg +gofjubptnmkelihwxacqvd + +alev +evla +alve +avel +aelv + +uceyogrhl +oqcafluvhewgr +ugcxlhorpez +nduzshrceglox +odmgbeucrplh + +ugesfliovyzja +nlizsujfadgo +lfguaszotij +osznifulgadkj +xadguljioszf + +kpgve +vqsfezungalxidb +gwteov +gpvcyjrmeh + +apuonkxtc +xithys +hfvtsx + +pgtzamyqeu +gtiuwpcqzvya +tpqauezyg + +souvmglcqbekzi +miuzvksocgqbel +gzqkmsubevolci + +ndvahciz +jaoyhepsbirw + +bghijfkotcxwu +uaokxsfbleyhgqr +hucfokpwbxg +nbfuztgovhxk + +zghianxtlq +qthdvingxalkz +wfqnixgteza + +lhzcrodupwqsv +phsvrzcldoqwu +hogspqwcvukdz +hwzpucdsqvrol + +txkqmsfbglhnoypaduiv +navlozmpthwsbkiqxdfu + +gidnojlbtfpskuwavyxczr +irvsyznbtedxougfwc +sovxhcqdbwytzmugrinf + +mcjnraketsgvqyxpbuwlhzdof +kqudanprgiejcftzlywhsoxmb +rcxmkdqfohjzgtsalbpunywe + +o +cm +rc +m + +tmkbedxgzsw +tdgmsxbzkernw +ktdbxzsemgw +gwkmestbdxz +xzdewgtmskb + +evpdgzcu +gepcvzu +vegzpuc +vpuzgec +cvpgeuz + +wfsadgtuizejmylxq +aspmuqigbxeljdtwfy + +ygbtdp +tye +fryaitjcukhl +ytdm + +jfm +m +m + +cl +cl +lc + +qbodnftrsygi +iztorbfskqdvng +onpsgqrdtif +mnrofcuqwdtils + +mhavcgzlrtbo +jrldgavzqbcxoh + +pshtdbifrvzqmklyae +tfajgrpkidzyhslebmvq + +cuzbjepnvis +isjbenvyzlcup +nagieshzcpqmfuvbj +ezvpsjrnciub + +ywgdsafzuxbrmhvqkljnoipc +hjcntvrzwdfbxksyiqolpumag +kwvpybmjeoualxcsqgidhfnrz + +zubvkn +cuwfsnv + +isknfdalujeg +hikagvpzx + +szgfhjtxid +stdgjzxfih +xghsjfdzit +gfjixszhtd +fzjshdtixg + +uibgxka +abigukx +xubakgi +gxabiuky +bkaxgui + +tjzor +slaore +gxwnoifudmcqvpk +obhr +tyo + +q +y +e +r +ifdcxzm + +fvtqrjsblkhuoiey +gyfnizlqupvscobt +bouiftlcvqsy +qdvlyfiusgotb +qvbycwsifluto + +ifmnxbcvpkylruh +nckrmfphluixvby +vbcmxyhurnpilfk +suiqbvyrxcphmfnlk +ynuxkrfvibclpmh + +pmvdyexsoilatqfgk +lpidgatmqevkxyso +gkpsaoleymqxvtdi +gmvxeyplqdoasitk +vkpdylstquegaiomx + +ymogxuswkce +vbxznpscg +xlcgs +xclbdsng + +zovwtiy +zrjlciov +ksxefuvqdam + +cwvsx +xeuwyhsfb + +hxwgolksbrdmpifye +lwpyefxmiohdnbksgr +gzoehypbldxikmwtrfs +sdlwpeymxifrbghok +glmbhykiofdxpwervs + +ndcphgqfuvsekaxozri +xofkqnbschdaveruizgp + +ptkvdhjaw +skhtapidwjn +thunakpjwd +eaglphkdtjcfw + +pnezvfgiouahmslkdxcrqb +fpiqsecxaukbvzgnorjhwdm + +emcwblgxuvnkzrdsoyjf +rvsxeugkmwzfncojlb +nhbiclvskjrupgxzfeomw +gcxlbjozeiufwnskvrm +eonjkwbzfxgpruvcmsl + +ntgia +ia +ai + +scoernukhwtigpd +bogiserhpucnkt + +eaipzg +gne +lughe + +tbipylmnrague +tbargijepmhuynl +triyzgupnbmale +prtnumgaibley +peblaytmgnrui + +rqlsepfhiv +fvelqphsri +ilfhvqerps +fheqplsvir +sfpvehirlq + +jciwxfbhqkadgzloprnuvsty +qwouetsmhykavxfbjzrglc + +fjmz +mjczf +unkzjm + +gebyncxsphfokwm +gmchsnbwkpfyxeo +fybkhcesogxpwmn + +ud +whjn + +ihm +hmi + +p +p +yp +sp + +ytrwx +yrtxw + +p +d + +ieltygdukac +yiudeakg +kpegdaiyu +audykegi +aeqydwiguk + +lb +ei + +zjvctfndgiqbeu +abfwndutvecqigz +fznbdutevigcq +qtvzfnueibdcg + +g +i +x +g +g + +qhm +lq +nq +pqsb +lvq + +qnxpslvajf +xuavcnst +nsyabxv + +ocu +uco +acoux +cluo +coun + +jtgzodebq +ojztqdgbe +oejrqzgtbda +tjzbqedgo +gzqtejobd + +ubglorcsyvmxd +oentwfgulpqikdcbzhj + +jwkmxdnyvbiz +qebnoyfz + +bepdfi +ikepbof + +cofgekndbatpruhqmwvsiy +bsqtrakeudopghvyfmcnw +qgusdwvabytmfkcnehorp +qfhruygwkvmbpaoestcdn +prmkbuvynseatdoqwfhcg + +enczdvbkiyjgruqp +bdiqvwjurpycngzk +bnrcejupvqiwgzkyd +pqgybrcjzkudonvi + +fygasxjwrb +ijsgafwyrbx +syjawbxgfr +wfbrgvsjyax + +xtp +bfnzuadh +xlce + +rxmeqcbv + +fjtdihkrbyn +htfjyinkgdrb +fibgtkdryhnj +hkbnjrftidy +intbxjrkfdyh + +nhkiqjocfgxmrvwetd +ghnfdjvqtxwermokci +xnrtfkhdwcmjvoeigq +mcvfjhwiqtnrekogdx +imhxgjwrodtcknqvef + +sabwqu +yqamws + +usei +xkvnyfi + +rcewysztbiamhpgldj +kibrfndmgeazcsh +adrzgchmwjsbie + +pnrwvx +lwjxnu +vwxinb +pfxybwng + +wnvxgfdkubzrmip +kmjhoigltwbz + +znlgbx +fla +dl +l +l + +jgeqcikplduzxrwby +kwplxgcbndjqyizuer +ewrqujilgyxpdzcbk + +guteykxsqrfwhz +mhiurkswtqbxz +sdlqxvowujrhkz + +zrejn +nzrje +jnerz +rzjen + +fvkouigderaqbjth +eqrvwjinfltzpcuag + +stqcrpy +ctsqpyr +ptyqrsc +ymsqrcaptb + +egftpqosiv +ecjdqlnmwouf +spxaqofre +epogyfqi + +oxwgtshjqef +pbtgjfeqhnoxw +jfhewygoxtq + +jwavgo +ogevbwdjai +ogvahjw +wrajvog +ogsjwarv + +rpucvg +cgpr +htfelpc + +hqrwapscubelovxntd +jisztpnbcahlfdoqmvexgk + +pmadwutiejznofcgvsbqyxh +qvmzbaisgfcunwjexhpdktyo +xtvsdnqaucyehgzbjiopwmf + +vjqih +himjwdv +hsojivb +jtrklivehyg +mvnaizoqpfxhj + +j +j +j +j +j + +dpnwmtvklc +ndjpkm +ndmpk +ndmpk +ndmpk + +ucojsptiqymhewbxvrfdkngl +ebpjwuxrdqkmsochvfgliznt + +esroiaqdbxnjhut +xibuqhmensdajo +feukjbahdxwqnsiocv + +vkxzclpmtujngerawod +azdrgcenvjxptkuolmw +onrluajvcgewpdzkmtx +xamlobkrvzwpjgnucdte +tvenjdmlzpwugkoracx + +ywpfhztklgjmoien +nyelduixgvwmojpzhtk +lehpigtmoknjyzw +gmhwzokylpnteji +tmypejhwgzlniko + +fmd +jf +fj + +l +v +ntobg + +drmzvt +rxtsfuk + +vxdlpjkrsz +dgxkprvzsl +dsklxpvzr +pdvxzlrsk + +gwip +gakpw + +kbcadn +bakcd + +mhpstqcgvoalkwxinebryzujd +qwhirveoczyatgjdsmkpxnl +mejazlincwodtshxkrpgqyv +fsaizhnkcvwolgjpdqxtmrye + +rxubznovy +yvudnrbz +zvunwcyrkb +ntzbryuav +ndvytuzrb + +utvklrxypgbnimsdofwa +fyzliqswjmtpvdka + +byctfzx +pxzf + +g +ik +ykei + +bcajzwogvetd +gedbcwtzvoaj +hcwogaxjbzvted +eoczjagtdwbv +atvdjbcozgew + +wsclketugyaz +qvfbjcxtmilgow + +amgirw +yf + +iletugq +hnoxbfkaspt + +qjdfcpvksmxzywahgn +wnzceyskgpoxdhlmravjqf +xjgvhcsqyfankpzmdw +jyncdxwsqkvphfamgz +dvznygwjkcmqsxahfp + +fkuwiezpljbdayhsr +rphwbeujdzlfiasyk +erdhpafkzbwjlusiy +jwfhkrzdeabpliusy +wfipeujhylazbsrkd + +fqmbwapvouelydgicj +uelvqwomtyfjgcpadi +qkpcsdeyjiwarovnglfum +ijvgqdauoefpcylwbm +ydmqpfewaovlicugj + +sgbq +ltqambf +djbuvn +zmtbgy + +egvifnsaztxqcrywumj +aqcxujnzvfwetrhgm +fxdmtkgawplobqjenv + +bxuwpnl +ztdkau + +ecylsbdv +cvzlsbeyd +yqcveblsd +beyvlqcsd +ebsvdycl + +eb +xpnyter + +cbhqyzresnpxfwm +cwksfvhxqperbimz +whqzpbcsjxafre + +beodiasvj +jbisdoave +iedaovbsj +jxovacsiebd + +prxsnyehgwifbzo +ozpbsxynfiwrge +ribozypewsxngf +nyoxspzbfihgewr +rxzewpbnimfoysg + +shviadjcue +weduziolmcbngp +vqdieycu +cudeif +dicyuqke + +nvcwhuo +sltchuwnq +unwhci + +ekrisbvx +rsxiev +exnrvsi +srxevi +xhsvnrei + +rs +rs +sr + +fuzjmek +tihf + +ptlzxreqfdchibogvysmku +pceyizvdkqxbhrtulsfmog +gvkrxfsbipqedlyzomhtncu +suyzgrobilxhmcfdtvkeqp + +okfvjneqyicuthwsmpxl +wdojlsqknyhmptvicfe +nyfjthmpivqgsulwkboec + +ufrpkliqjgwxeybmcztasovh +qvkpyghxblewsaitrmzuonjc +giptzywrejquxkoavslcmhb +peaywubjozmcgrihlqsvxktf +lehjpzguiksacobxywtmvrq + +egryz +ergyz +yzegr +yfcgzre + +j +j +j +p +j + +bjt +tbj +tjb +tbj +jbt + +cklp +lpck +lckp + +fea +eaf + +qgm +dz + +yri +yi +zypdi + +ekwjxhtmgiudpz +xepuhgwjizkdrmt +ezghmliwtxujdpk +wdhxpjizugkemtl + +gyokbspj +kbgsopyj +pykhdsjbgio +opjykusbg +jygbsopakc + +ixorlekwgnbcjm +lrjkwxgie +wgeikxjrlh +rlkjxipeqgw + +ecgmdrykq +myrclqdgek +guqmzyceprkd +dygckwerqm +yrcgkiqempd + +u +u + +bcwnvl +fcvsib +hcnvb +cpgveoaby +ivbcn + +n +n +n + +macuqyp +fs + +pbout +suota +cuotm +atmuo + +nlravibecfj +eilcjafn +aeibjfl +jxfeilauo +jafesdnli + +xfwroij +fxwijor +irxjofw +rfjwboxi + +dj +dvj +dj +dj + +mikhxcqensrodu +imcvkhewgljupsxonq +kceuqxltinhsom +kzqanoemcxhius +vmuoxineqpzhacbks + +hklcsoaywpfrdntmu +xirbzckwjvpfygeno + +o +to +o + +zvirefunh +ezhirnvfu +runifzhev +ezivhnrfu + +zfsoducbpai +cupdisobazf +aozbsucfdiypv +bcfazodiups + +njfprukxamlg +kpfrjgynulxma +pijflgnuxkram +pkuxalrmjfgn +nkvrlmxustpfjga + +dszgm +rsmu + +iaw +aiw +wai +aiw +iwa + +s +s +s +sl +s + +eyavhnk +keov +qeiwfkcgvrpsld +kuvze + +a +mh + +ilqchdfsog +igscolmdzq + +fnyhxmpct +lchdpamfu + +vijz +vj + +dhpxjrmyuefclvqgni +uicskweohgvfryxmdq +tqgdifymexbwckruvh + +c +c +c + +lthidumvycszw +cvpqjeuhlwrfyzg + +keocuw +uckowe +oekwcu +cwukoe + +c +c + +lkxjv +jkvxl +vxklj +jkvxlwg +zkxvjly + +sqlamxeuhpgwjbdcioy +bumyjxsiqweholpgcda +gecswjlqhadiuboxmpy +syahibgopexwlucdqjm + +igebmv +tawqvezdsmpunk +rimocvgje +evmbhc + +ykjisvfatux +jfaisyvktux +itksajfxuvy + +fclkush +slcykdbgu +fskuchl + +xjhulywagzeioq +oejlfsquhbriayxwg +jiexgylwzhuqao +wyxhqljagieou +hwladixguqejyo + +sofcbhuwyqtid +icofdwsb +dfwovimbcs +cwibodnsxf + +jqnestpyaczfmxhwrbuvldi +mxanrhbfcujvyzditwlo + +ntfgivkyszmarc +qrajdhowuvpclbex + +kliwy +ukwlryi +ilkyw + +pmgltzsk +ljmipztvgow +zltmgup +umztglp +ftzmlpgk + +twepi +teq + +ohyd +mytjrwk +hfy +exyh +ye + +rzsqhtlowavy +twvhzyrjsqaol + +yzagcqrjeimwxokh +fmxtiagboleqcwdrhzk +opvemhasrguxkcqzwi + +atcpeyosnrjbg +kcesobgua +fagsev + +ca +ac + +xahmtil +hximtla + +hyutnjdrbsmofl +dswjfyothmblrnq + +et +te +eqt +tuje + +nbhpwzgtrcx +gqcxobhriznw +hwnbugrejxtczs +cujrbxfhnwzg +gcwzhrxndjb + +qwrfxhlyzcptvmkdeauigob +zbchavlkmryxiptegwfouqd +cfhuiptgqkoalrewzmvbyxds +hudmwcgbfepyitovkaqzxrl + +eysuozkm +ndgloqyv +ignhwrovy + +iqufgnvxspdcjtylkbrozh +inuzqktrvcxyhbgfosljdp + +qhfknsyeuirzagvcwd +yfcgqnxewlkrsuazhi + +lj +jl +lj +lyj +jl + +kpholfxewrdt +opdfhtlmkwex +hpwftoxderlk +ylxhwdofnztkpe +rwfpxlhtdkoe + +ubml +yvohg +zeasf +plum +qhnjxg + +cjgzwmdyuakvixlprhfe +kmplfuxywergchzjvani +xcvlzmewyujgirhpfka +fwhgrxkjcvpeuilzyam + +eclsiqp +ivgspoe +scepi +pmiadtskyze + +akmdfivwgct +yvgcwakhdimts +lcvgirakwudtp +aftnckwmidgv + +zuqblv +blvzqu +uvbqlz +qbuzvl +bzqxvlmu + +by +betlcdvry +yb +bxy +gybjx + +waoqdxpkmfnyrhjebcuvzs +qprvfczedowxknhausmyjb +cufdqvknwrajzybospmxeh +qkjzybeadvncwhxumpfsro +nwfkjxumpabzodvqychsre + +shdfctjrkwbvemoxluyzipnqag +sgbwpeuqcilxojfynmrdhvktaz +lhgkxfwuzbevojmrpnqydsacti +gflnzjasbuyimxqcvwrdpohetk +ynwedhbskjtvoucgapiqlzfxrm + +wlmjxp +ylnxoajk +luxjidte +xjrvlcdeu + +pv +vbpw +wvuap +kceavp +rdphvoitqf + +dlxzwkhtmc +twzhlmkdc +tcylhkdwzm +zwmlkdcth +gdhikmctlwsz + +hpekwtlufyragqvb +kbrwatlupqyfvh +ucbvwlhfqatpkry +hlakvyuqrfpwbt +rubvwpfqlatkhy + +npxobl +ckuhnplvx + +edkpjycofasulrthw +rpuhcdyxlftosewa + +stuvhwaexykzdorbfpi +shjuwgpfqmtacvlbirkzd + +frph +wo +h +zumtyngcj +pfse + +zivsgurp +szirpvg +gikvsprz +zigpvsrk +nvpsgzir + +rfimu +hmqrlfxpbgu +nrmoyftu +nmujfr +rfum + +bidzwmearovjkgcl +ogdbirkzqmclejvaw +gealcqozmijkbrvdw +gzakwmdbejclrivo +eolwifvgmrbjdazkc + +iurfyqgwk +ymkvqfpwrig +aqrfywikg +bfdryxikgnwoq +cjfgkryiuwq + +jvb +x + +qkxnvfuopdytrzjgbm +bmqkuyarjgtdpfzsnox +obwjxyeqtingzmdrfkplu +gamupstryfokbzqdxnj + +ymanp +npfshjya +pundyklatc +ypfanh + +garp +grpa +arpg +argp + +inedmtpwrvub +vwibertnudmp +idurbepwtmnv + +yczoaplwmxibqgsfn +wbiuxyqzpncvgmsl +gpoltrbisqfznwxcymj + +a +a +a +a + +cgjviyufped +pcuvygzkjid +ptvigyjdcku + +u +i +tqa +j +ul + +zitbfuer +uzfithernb +uftbzire +uitefbzr + +jcwkroamnegxvqsh +kejhanqmvcrxwsog +gaqmkexjvcsnrowh + +taegslmuyqcipz +asytxrgdpfbcqliwz +tpgoschavqjlkyzi + +oc +oc +oc +co + +mrfvjlykquz +fzmvuleykqt +vykmzlgquf +kqfzuvygetml + +a +s + +ionve +eailo +jiomexwh +beziqpdco +ihtoe + +cfjvrqosnwyedaubmhgtlxzk +olxzjfwrcytkbgudasvqhnme +tuwfnckrzsvjgbxdmyhqlaeo +txnydgufbmjaqkrzlwhoevcs +bgakxqmfsdwyjvelntchzour + +njvkobzs +bsjvkwn + +qmnluxw +ovgtikpdbrya +nchfsjqez + +khtdryej +hdrtv +qnaodtm + +as +aus + +omjaixvgklq +vgkaxjihdrlq +ycxkzatpusiljqgv + +jtepylmrqbiwk +xerlpmynqtkfbjwi +timwpbkegljqry +lqijkebmgpwyrt +qrkljpbytemiw + +q +xqint +dkqb + +trjmdxpoeqcwf +tfedxqcprwom +kmftwxqporncde + +fpcmndhr +dzepjngqikcfrh +nhfpcrd + +c +c +c +y +c + +t +t +ti + +tgfspxdy +sytgpfxd + +zov +voz +ovz + +ic +ieuc + +vhesndkizjgwcpobulam +szjymxwopckfqtgdib + +jdfzgqsbrmnticl +fbcdgqtznmjri +doitrczjqfbgmn +otzbjfidmnrqcg + +cb +bc +cb +cb + +aspjvghyurx +vcarwsbh +laeshvzrb +hsrvia + +kpxzdhasfmltouvrc +duvpkascromz +vmcskupzorad + +pguayqbwm +gpyaqbwum +ywaqgpmbu + +ypdlnjse +elskbyz +jesylo +lyse + +zlokqmjiurpwgbn +xzvurhgmlkwqnibjpo + +wpzenbojcykqxvt +wnyzlbjkeoqtvcpx +itkjzydbpvoxcewnq + +gfuvenodsizwmh +hwfuvsntdg + +gkibnpalc +inkcgpal +gnpzliakfc + +ibektdpuhg +iwbgjke +iycnergfqkbo +egxadvlmbijk + +l +yjg +l + +ymuoc +oymcu +oymcu +youcm +ycomu + +wifoqy +zksfrict +bdpvhuilgejn +acoi +mqi + +qrcukhwvzdjilpto +hqrmwkupclvjtizo + +gdizlfawobuk +dihqfswcgukzrbla +gmukawbdfizlo + +zwdrpv +dzvpwr + +ycidkpfrqjelha +pjahykfecdqrli +kfqlajhdepyirc +pkhaceijlqdfry + +pwuxbqotey +okbphqutfx +xvsgodubtlpqijr +puoewaxtbmq + +qtbaoex +xpoqa +agiweqtop +nozuadmjrq + +huvqdaij +fkuvaijdhq + +biewrdlzc +rjlcikbzmdwve +leucwfpoizndbxr + +avgtnubqcpxrhwdoml +vrkqgyndcmohtupswa + +dmjqfesnxyciz +hfzudcjxsmno +mfjhrcsxznd +lcmbjnxzfadrs + +tvayrhpqskd +qrtkvhyus +epjsytzhvrqk +yzqohmvtgsrk +hvlysqtwirbk + +ieyd +aipeyg + +r +rg +rm +r + +qcweajhfmlgyzpv +ouqdxmsphkbatenr + +fba +kfba +baf + +vxpblsyjnrmkai +vpyhagcwqbzxmik +rpbytexdijnfavkom + +fpmytnk +cyaw + +jhyimdg +mhyij +hmvyij +mihezcovyj +yhmciej + +sqfaopkgze +kxsecfphozq +qsotezpfk + +ewcvoaurmjhq +cuqvjwreaohm +ewvjmqacuorh +wauhojecqmvrs + +lyieuqdjcb +vkpctdmywzsreubn +delchbujy +jbcyegdou +xduayceb + +nidxswarcqtk +kciqdarnbewsxt +acqrdkntipxlsw +ikpawtcdsqnrx + +gikrfhwltveap +yeplvatowncgxirf +griadtewmvblpf + +htjkmzxlvbygcwqioe +jzwtymxvigbheolckq +cxmvjyklobhtwgqzie +teczbxvlmgojqiwkyh +oxvejlbtiqywhzgmkc + +jkfapozdwcie +bmushwjgltrn + +rpnbxkoij +exjdri +uirjegxsa + +zawoncbymgsrhv +dvctxgeusr +cvizgyhlmrwsfp + +shnyujedctwfq +yscahxndftreq + +xrnysi +itcluvmd +niqwozjber + +gjobshlayxvctnfq +ljcxaonvbstqfgyh +ybhxgntqcsvfaojl +rjoxblqavncusgheytf +sncqlvybxfjtghao + +uozb +ldewrck +xbg +xhg +z + +yubqaznf +imwhrgnkjls + +msvgjrnkcloaup +csxjnkgrpiuoveamy +pknvrajmcudswgzo +tnupacsxrgkvmoji +bpnkfarqumsvhcojg + +bzvyuenaihfdcgwk +puchyenmzgksrijoa +ugebciktnlzhay + +cedfutpnsivjlobrkaxy +denscvpbmlkxaojrfh + +vugjrq +jqgtuwcnrv +grvkuqj +gbmvqsyxjueplzirhf +avudnjqgr + +vpidajtmgozxwuksh +ughiwmakpjszdtvox +wugipxzdvastkhmj +sxughjakmnwfpdivzt +wimvaupjhgxstkzd + +mqsuwhdxpcozfr +rsdwhfpakzxjmo +eysprldfqzowmhx +fodhrtmswxyzp + +vsmzfbjhwqxiugtlc +gcqdsfmpletnhbxr + +uxbgkfjwesmlchr +feakldxqnpwcjgvrzbhs +hjosrixfmlcgbkew + +dszv +zsvd +vsdz +zvds +sdzv + +pdw +lxudjpiwz +advnkpqw +hswpdog + +gslpira +neuzf + +ifjt +tjif +jfit +jitf +ifktj + +jrnzb +unkjshpe +njza + +ydigxaqm +iaeokqgmyhr + +bkxmngtdlyev +nmbuzoveixlprkys + +zjloghmtu +ermvzn +qzdncfm +afczxmp + +aptscynieqmfgjhbr +bmsirnafyepthgcqj + +q +qlr +fq +qk + +v +v + +ucrmbsozjkfy +buscrmofkzy +uosmfkryzbc +sqirbfzmocuynk +mbucykofrzs + +lrp +plz +lrp +lp +lp + +yfzmpgcsw +prycgfm +rfcmgpy +scgmyqpf +flcyvpohmgu + +g +g +g +e + +lxoaibjch +wudyrfvkzn +gtpmkeyqd + +zjhlwbtfuvick +wujtvblzchkif + +ksdfpvqbtxaluneo +dqofprhnxamskujeb + +hacwigyftqblx +xwlqahitbgcyf +ahyxlwgtqifbc + +mb +m +mg +m + +ecrasdtyljuqimhnwfb +qleiaydjcugrwn +jdyewaqnrcliu + +g +lqfio +adhstybz + +gryzuxenhlvopbtmfwqcas +yeqzalmogbncxpsfujwh +mflqzhoaupcseygnbwx +myswzuonfqlaxecbhpgj + +uwvzati +uzcjvtai +savuizt +atiuzv + +cozuin +abuizo +tiozua +wilfzeoqu +roictxuz + +gndpkojqu +gunkpsjoa +rtmzjpgkovwxlnuc + +lrj +rjl +mrjl + +udlpevjgzrfawitqs +qgrtiujslfeovza +surivgtfqjleaz +ezavgjtlfrusiq + +g +fx +mf +tx +iyqd + +sljgmdztynvrqexhwfi +gvwdyerlqnxthmjifsz +qgmjlfwrxztynivdhse + +zkvuir +kvruiz +vriukz +kriumzv +zruikv + +zyqgnvda +kdygvqanz +zyagvqdnu +qnwdmlaxgzyfvo +dnzgyavq + +o +s +q + +cbroy +qiyocmjdt +uyoc + +lkqj +kjql +jqlk +ljqk \ No newline at end of file diff --git a/day6/program.js b/day6/program.js new file mode 100644 index 0000000..9fa0045 --- /dev/null +++ b/day6/program.js @@ -0,0 +1,40 @@ +const fs = require('fs'); +fs.readFile('./input.txt', 'utf-8', (e, data) => { + const answers = data.split("\n"); + const groups = findYesses(answers); + + let allSum = 0; + let commonSum = 0; + groups.forEach(group => { + allSum += Object.keys(group).length - 1; + const groupFilter = Object.entries(group).filter(key => key[1] === group.groupSize); + commonSum += groupFilter.length - 1; + }); + + console.log('Unique yesses', allSum); + console.log('Common answers', commonSum); + +}); + +function findYesses(data) { + const groups = []; + let groupAnswers = {groupSize: 0}; + + data.forEach(row => { + if (!row){ + groups.push(groupAnswers); + groupAnswers = {groupSize: 0}; + return; + } + + groupAnswers.groupSize++; + + const answers = row.split(""); + answers.forEach(a => { + if (groupAnswers.hasOwnProperty(a)) groupAnswers[a]++; + else groupAnswers[a] = 1; + }); + }); + groups.push(groupAnswers); + return groups; +} \ No newline at end of file diff --git a/day7/input.txt b/day7/input.txt new file mode 100644 index 0000000..a3b91d0 --- /dev/null +++ b/day7/input.txt @@ -0,0 +1,594 @@ +light gold bags contain 2 light lime bags, 1 faded green bag, 3 clear olive bags, 2 dim bronze bags. +muted beige bags contain 3 clear lime bags, 5 dark salmon bags, 1 pale olive bag. +vibrant violet bags contain 3 dark tomato bags, 3 muted indigo bags, 3 plaid turquoise bags, 3 light silver bags. +dull purple bags contain 2 wavy turquoise bags. +posh purple bags contain 4 bright lavender bags, 2 wavy chartreuse bags, 3 vibrant aqua bags. +striped gold bags contain 4 light magenta bags. +dark lime bags contain 3 plaid brown bags. +shiny salmon bags contain 5 light olive bags. +dull gold bags contain 2 dim plum bags. +dim olive bags contain 3 faded cyan bags. +faded white bags contain 2 clear brown bags, 1 mirrored green bag, 3 plaid bronze bags. +dull salmon bags contain 1 plaid gray bag, 4 vibrant aqua bags, 5 mirrored cyan bags. +striped orange bags contain 4 vibrant maroon bags, 2 dark orange bags. +dotted silver bags contain 2 posh red bags, 1 muted yellow bag, 5 light aqua bags, 3 pale red bags. +light orange bags contain 1 striped coral bag, 3 dim lime bags, 4 muted yellow bags. +wavy lime bags contain 5 light silver bags, 1 bright coral bag, 5 drab silver bags, 1 dark plum bag. +bright tan bags contain 3 clear magenta bags, 2 muted white bags, 2 drab beige bags, 5 plaid green bags. +dim violet bags contain 1 striped fuchsia bag, 2 mirrored green bags, 1 bright teal bag. +mirrored gold bags contain 1 pale aqua bag. +bright plum bags contain 1 faded fuchsia bag. +muted aqua bags contain 2 muted red bags. +plaid bronze bags contain 2 dim lime bags, 2 wavy coral bags, 1 vibrant lime bag, 1 dotted beige bag. +dim chartreuse bags contain 5 mirrored lime bags, 2 dotted tomato bags, 1 plaid turquoise bag. +muted lavender bags contain 4 faded salmon bags, 3 bright white bags, 3 posh fuchsia bags, 1 dotted green bag. +mirrored yellow bags contain 1 wavy purple bag, 5 shiny teal bags, 5 shiny cyan bags, 1 shiny crimson bag. +striped magenta bags contain 4 dim white bags, 2 pale white bags. +dull crimson bags contain 3 muted black bags, 4 dull lavender bags. +mirrored beige bags contain 2 posh indigo bags, 3 shiny gray bags. +bright blue bags contain 5 mirrored fuchsia bags. +plaid beige bags contain 3 mirrored cyan bags, 1 vibrant tan bag, 5 muted purple bags, 1 wavy red bag. +dotted indigo bags contain 5 pale fuchsia bags, 5 posh tomato bags. +muted coral bags contain 4 dim crimson bags, 3 dark brown bags, 2 drab fuchsia bags. +drab tomato bags contain 1 muted tan bag, 2 dark salmon bags, 4 faded red bags, 5 shiny olive bags. +dark tomato bags contain 5 mirrored salmon bags. +bright yellow bags contain 4 light teal bags, 1 posh white bag, 2 shiny blue bags. +dotted salmon bags contain 3 drab olive bags. +vibrant olive bags contain 2 posh teal bags, 1 clear aqua bag. +dotted gold bags contain 4 striped violet bags. +light tan bags contain 2 plaid fuchsia bags, 1 faded turquoise bag, 2 muted tomato bags. +drab orange bags contain 3 wavy violet bags, 1 dark fuchsia bag, 2 mirrored green bags. +dull coral bags contain 1 dark crimson bag. +light purple bags contain 4 dark gold bags, 3 plaid purple bags, 4 clear chartreuse bags. +wavy yellow bags contain 3 striped silver bags, 2 dull chartreuse bags. +dull tan bags contain 1 dim gold bag. +vibrant plum bags contain 4 dotted turquoise bags, 1 faded gray bag. +wavy tan bags contain 4 shiny plum bags, 5 faded white bags, 1 plaid plum bag. +dim indigo bags contain 2 clear blue bags. +muted teal bags contain 4 mirrored fuchsia bags, 5 faded black bags. +dark maroon bags contain 5 mirrored gold bags, 5 bright red bags, 1 faded gray bag. +mirrored aqua bags contain 4 faded turquoise bags, 1 mirrored tan bag. +muted violet bags contain 4 mirrored lavender bags, 3 faded salmon bags. +wavy orange bags contain 3 drab crimson bags, 5 posh indigo bags, 2 faded cyan bags, 5 light blue bags. +mirrored blue bags contain 1 dark teal bag, 4 pale orange bags. +muted silver bags contain 2 dim orange bags, 1 posh plum bag, 2 wavy fuchsia bags. +plaid magenta bags contain 3 faded blue bags, 5 vibrant lime bags, 2 faded beige bags. +dark lavender bags contain 3 clear olive bags. +posh salmon bags contain 4 dark orange bags. +dim silver bags contain 3 plaid blue bags, 1 posh brown bag, 1 striped white bag. +posh chartreuse bags contain 3 drab plum bags, 3 mirrored brown bags. +shiny cyan bags contain 4 faded plum bags, 5 wavy yellow bags, 2 drab maroon bags. +drab bronze bags contain 2 shiny turquoise bags, 4 faded white bags, 4 drab white bags. +dotted cyan bags contain 1 posh brown bag, 2 dark orange bags, 4 plaid bronze bags. +shiny beige bags contain 5 dotted cyan bags, 2 pale indigo bags. +drab violet bags contain 4 posh chartreuse bags, 1 drab fuchsia bag. +muted tomato bags contain 2 posh aqua bags. +drab plum bags contain 5 drab gold bags, 4 dark fuchsia bags, 5 pale gold bags, 3 dim olive bags. +dim brown bags contain 1 drab indigo bag, 2 pale gold bags, 5 posh fuchsia bags. +plaid cyan bags contain 1 light orange bag, 2 bright violet bags. +striped silver bags contain 2 shiny silver bags. +plaid tomato bags contain 3 drab cyan bags, 4 clear chartreuse bags, 3 dim coral bags, 4 shiny gray bags. +posh tomato bags contain 1 plaid bronze bag, 1 dim lime bag. +vibrant orange bags contain 5 bright aqua bags, 2 drab coral bags, 4 dull aqua bags, 3 vibrant lavender bags. +drab brown bags contain 1 bright orange bag, 3 drab salmon bags. +plaid crimson bags contain 3 dull red bags, 3 posh maroon bags, 2 dull beige bags. +clear aqua bags contain 5 muted cyan bags, 1 dotted teal bag. +pale magenta bags contain 2 light brown bags. +mirrored chartreuse bags contain 3 striped gold bags, 3 light silver bags, 3 dim red bags, 3 dim chartreuse bags. +mirrored plum bags contain 2 striped tomato bags, 1 posh aqua bag, 1 muted teal bag, 2 faded indigo bags. +posh teal bags contain 5 clear indigo bags, 5 plaid purple bags, 4 pale white bags, 3 drab gray bags. +wavy aqua bags contain 4 drab beige bags, 5 plaid black bags. +drab coral bags contain 3 striped tomato bags, 1 dotted cyan bag. +shiny chartreuse bags contain 2 mirrored cyan bags. +striped gray bags contain 5 striped tomato bags. +shiny orange bags contain 4 muted purple bags, 4 dim silver bags, 5 shiny gold bags, 3 pale orange bags. +dark teal bags contain no other bags. +dark magenta bags contain 4 pale gray bags, 1 dim purple bag, 4 drab coral bags. +vibrant fuchsia bags contain 4 dull olive bags. +light bronze bags contain 2 plaid gold bags, 2 dark white bags. +dotted yellow bags contain 5 bright indigo bags, 2 light silver bags, 3 wavy red bags. +muted purple bags contain 1 shiny blue bag, 5 faded red bags, 1 dim olive bag. +faded cyan bags contain 1 dark teal bag. +dull brown bags contain 5 vibrant aqua bags. +shiny white bags contain 2 dull red bags, 1 plaid orange bag, 5 muted turquoise bags. +light brown bags contain 4 dim coral bags, 3 faded red bags. +bright orange bags contain 5 dull olive bags. +light lime bags contain 4 light magenta bags, 5 muted violet bags. +shiny indigo bags contain 2 bright blue bags, 1 dotted turquoise bag, 2 clear bronze bags. +faded teal bags contain 4 bright brown bags, 1 light silver bag. +posh bronze bags contain 3 dark salmon bags, 2 plaid fuchsia bags, 1 dim white bag, 5 faded maroon bags. +shiny yellow bags contain 1 posh lime bag. +dotted beige bags contain no other bags. +vibrant blue bags contain 2 posh green bags, 1 faded white bag, 2 plaid red bags, 4 posh violet bags. +posh lime bags contain 4 bright aqua bags. +posh coral bags contain 5 plaid white bags, 3 faded coral bags. +dark yellow bags contain 3 wavy violet bags, 5 clear chartreuse bags, 5 light turquoise bags. +wavy bronze bags contain 2 clear brown bags, 2 muted cyan bags. +faded brown bags contain 5 dim lime bags, 4 dotted beige bags, 3 wavy coral bags, 1 faded gray bag. +vibrant gold bags contain 2 dotted maroon bags. +vibrant red bags contain 4 dull black bags. +clear beige bags contain 4 dim olive bags, 3 plaid bronze bags, 3 clear brown bags, 5 vibrant lime bags. +dim teal bags contain 4 plaid bronze bags, 5 striped tan bags, 1 muted olive bag. +dim aqua bags contain 1 faded lime bag, 4 faded gray bags, 1 posh coral bag. +faded tan bags contain 5 clear lime bags, 4 shiny violet bags, 2 dull aqua bags. +mirrored green bags contain no other bags. +light magenta bags contain 5 plaid gold bags. +striped white bags contain 1 wavy coral bag, 1 faded gray bag, 3 vibrant lime bags, 2 mirrored fuchsia bags. +plaid violet bags contain 3 faded indigo bags, 1 striped fuchsia bag, 5 drab salmon bags, 4 mirrored cyan bags. +dull cyan bags contain 4 dark chartreuse bags, 3 light gray bags. +light salmon bags contain 2 dark teal bags. +drab crimson bags contain 3 vibrant tan bags. +striped yellow bags contain 5 faded brown bags, 4 posh olive bags. +pale orange bags contain no other bags. +faded gold bags contain 5 light magenta bags. +faded beige bags contain 1 faded indigo bag, 5 wavy green bags, 5 faded crimson bags. +striped crimson bags contain 2 posh brown bags. +dark black bags contain 4 plaid lavender bags, 5 mirrored salmon bags. +bright beige bags contain 1 bright brown bag, 5 posh aqua bags. +bright gold bags contain 3 light lime bags, 2 shiny white bags. +bright tomato bags contain 4 dull orange bags, 4 dull blue bags. +light olive bags contain 4 dull blue bags, 4 plaid gray bags, 4 faded gray bags. +vibrant lavender bags contain 1 clear salmon bag, 2 bright lavender bags. +drab yellow bags contain 1 plaid black bag. +faded green bags contain 1 clear brown bag, 4 mirrored orange bags, 1 striped tan bag. +vibrant black bags contain 4 mirrored fuchsia bags. +bright indigo bags contain 5 plaid red bags, 1 striped chartreuse bag, 3 vibrant plum bags, 5 dark lavender bags. +dull plum bags contain 2 mirrored plum bags, 2 light silver bags, 1 pale indigo bag. +striped bronze bags contain 2 dotted blue bags. +muted magenta bags contain 2 dim silver bags, 5 clear purple bags. +striped teal bags contain 5 vibrant white bags. +dim bronze bags contain 2 dim crimson bags, 4 vibrant beige bags, 2 wavy turquoise bags. +shiny lavender bags contain 4 dim purple bags. +vibrant silver bags contain 1 dotted crimson bag, 2 dotted maroon bags. +posh yellow bags contain 4 bright salmon bags, 4 shiny lavender bags, 5 mirrored aqua bags. +faded bronze bags contain 2 posh brown bags, 3 clear lime bags, 4 dotted red bags, 2 striped white bags. +posh maroon bags contain 5 striped salmon bags, 1 light black bag. +pale aqua bags contain 2 shiny orange bags, 1 shiny silver bag, 2 dim violet bags. +plaid chartreuse bags contain 2 muted black bags, 4 muted magenta bags, 1 mirrored bronze bag, 1 posh beige bag. +dotted orange bags contain 2 drab indigo bags. +plaid gold bags contain 3 drab beige bags. +shiny silver bags contain 2 dull teal bags, 5 drab gray bags, 4 bright blue bags, 2 dotted cyan bags. +mirrored crimson bags contain 2 shiny gold bags, 5 plaid black bags, 3 drab beige bags, 1 pale beige bag. +pale gold bags contain 1 striped tomato bag, 5 striped white bags, 2 mirrored bronze bags, 5 dim orange bags. +vibrant crimson bags contain 5 faded white bags, 2 wavy coral bags. +dim yellow bags contain 1 vibrant coral bag, 5 faded red bags, 4 mirrored magenta bags, 4 posh indigo bags. +dull teal bags contain 1 plaid fuchsia bag, 3 striped blue bags. +striped red bags contain 4 dull lime bags. +muted chartreuse bags contain 5 bright crimson bags. +dim lavender bags contain 2 posh maroon bags. +wavy crimson bags contain 1 dim magenta bag, 4 dim crimson bags, 1 dull lavender bag, 3 muted fuchsia bags. +dull green bags contain 5 dull olive bags, 1 clear blue bag, 5 shiny salmon bags. +wavy red bags contain 1 dull chartreuse bag, 3 dim black bags. +pale blue bags contain 4 light olive bags, 3 vibrant chartreuse bags. +dull fuchsia bags contain 2 posh chartreuse bags. +dotted violet bags contain 1 shiny olive bag, 3 bright blue bags, 5 posh beige bags, 4 vibrant black bags. +drab white bags contain 1 plaid gold bag, 5 clear olive bags. +drab blue bags contain 3 muted bronze bags, 5 shiny gold bags, 4 dim olive bags. +plaid salmon bags contain 5 pale gold bags. +pale coral bags contain 3 plaid orange bags, 3 plaid fuchsia bags, 5 drab teal bags. +vibrant maroon bags contain 3 dim lime bags, 2 pale beige bags, 5 mirrored green bags. +mirrored magenta bags contain 2 striped blue bags. +faded blue bags contain 3 vibrant bronze bags, 2 clear maroon bags, 1 faded white bag, 3 dark cyan bags. +drab olive bags contain 5 wavy teal bags, 3 mirrored black bags, 5 dark gray bags, 5 dull lime bags. +posh white bags contain 1 plaid purple bag, 4 dark turquoise bags, 3 clear salmon bags, 1 dim orange bag. +dull red bags contain 4 vibrant plum bags, 3 plaid black bags, 4 dull orange bags. +striped tan bags contain no other bags. +posh blue bags contain 3 mirrored magenta bags, 1 dark plum bag, 4 wavy turquoise bags, 1 shiny coral bag. +drab salmon bags contain 2 bright aqua bags, 4 posh gold bags, 5 plaid blue bags. +striped green bags contain 5 dim black bags. +wavy salmon bags contain 5 pale purple bags. +vibrant cyan bags contain 1 dark gray bag, 1 vibrant beige bag, 5 drab violet bags, 5 dull coral bags. +wavy lavender bags contain 1 light magenta bag, 2 striped cyan bags. +faded maroon bags contain 5 light gray bags. +vibrant yellow bags contain 2 bright beige bags, 5 dim brown bags, 2 posh silver bags, 2 pale cyan bags. +dotted tomato bags contain 3 mirrored magenta bags, 3 wavy chartreuse bags, 2 wavy maroon bags. +striped lavender bags contain 4 shiny coral bags, 2 dim white bags, 3 faded red bags. +faded red bags contain 2 mirrored fuchsia bags, 1 light cyan bag, 2 vibrant lime bags, 1 mirrored green bag. +clear black bags contain 3 drab purple bags, 2 bright yellow bags, 2 wavy brown bags. +faded indigo bags contain 1 dim lime bag, 1 clear brown bag. +shiny tan bags contain 1 dull brown bag, 2 striped tomato bags. +drab teal bags contain 1 dotted turquoise bag, 4 posh fuchsia bags. +wavy magenta bags contain 1 dim yellow bag, 3 drab indigo bags. +mirrored turquoise bags contain no other bags. +faded lime bags contain 4 drab cyan bags, 1 clear orange bag, 5 vibrant salmon bags, 5 faded crimson bags. +vibrant coral bags contain 5 pale gray bags, 2 clear salmon bags. +muted turquoise bags contain 1 clear brown bag. +plaid aqua bags contain 3 dull coral bags. +pale indigo bags contain 1 striped brown bag, 2 bright cyan bags, 5 plaid silver bags. +faded tomato bags contain 1 pale red bag, 2 dotted tan bags. +mirrored white bags contain 4 drab fuchsia bags, 3 plaid orange bags, 4 dotted lavender bags. +shiny aqua bags contain 1 wavy silver bag, 4 drab green bags, 1 bright tomato bag. +pale cyan bags contain 1 pale gold bag, 5 dark turquoise bags. +mirrored salmon bags contain 5 light crimson bags, 5 muted bronze bags, 2 vibrant beige bags, 1 striped lavender bag. +dark gold bags contain 1 shiny olive bag. +muted blue bags contain 2 vibrant maroon bags, 5 wavy chartreuse bags. +bright fuchsia bags contain 1 posh white bag. +light blue bags contain 5 muted beige bags, 1 dark crimson bag, 5 mirrored brown bags, 1 posh orange bag. +clear salmon bags contain 1 faded brown bag, 5 dotted beige bags, 4 faded gray bags, 4 dark orange bags. +plaid red bags contain 3 drab silver bags, 2 dim green bags. +faded plum bags contain 2 posh orange bags, 5 dotted lime bags. +bright coral bags contain 3 plaid plum bags, 1 dark green bag, 2 striped crimson bags, 5 vibrant coral bags. +shiny crimson bags contain 5 bright teal bags, 4 muted magenta bags, 4 vibrant maroon bags, 3 faded cyan bags. +dim magenta bags contain 1 muted olive bag, 1 bright blue bag, 4 muted white bags, 5 posh gray bags. +pale brown bags contain 4 dotted cyan bags, 5 bright coral bags. +striped olive bags contain 2 bright brown bags, 4 pale gray bags, 5 dotted teal bags, 3 pale white bags. +posh gray bags contain 1 dark chartreuse bag. +dotted brown bags contain 3 plaid gold bags, 5 dim bronze bags. +dim lime bags contain no other bags. +clear crimson bags contain 2 posh orange bags, 2 plaid plum bags, 1 dark orange bag. +shiny turquoise bags contain 1 faded indigo bag, 3 light red bags. +striped plum bags contain 1 muted white bag. +muted crimson bags contain 1 bright teal bag. +plaid blue bags contain 3 dotted beige bags, 5 vibrant lime bags, 1 vibrant tan bag, 2 striped blue bags. +light teal bags contain 2 dotted cyan bags. +faded salmon bags contain 5 mirrored crimson bags. +shiny blue bags contain 4 posh gold bags, 3 light cyan bags, 1 clear teal bag. +plaid brown bags contain 2 dull lavender bags. +muted bronze bags contain 3 faded purple bags. +posh fuchsia bags contain 5 striped coral bags. +clear orange bags contain 1 bright blue bag, 5 posh gold bags, 5 striped crimson bags, 1 dark teal bag. +plaid plum bags contain 5 faded brown bags. +clear gray bags contain 4 mirrored fuchsia bags, 2 dim cyan bags, 3 pale gold bags, 1 dim violet bag. +bright lavender bags contain 1 mirrored purple bag, 4 wavy magenta bags, 2 dull black bags, 3 light silver bags. +pale purple bags contain 3 striped tan bags, 1 dull olive bag. +pale bronze bags contain 2 plaid aqua bags, 2 pale fuchsia bags, 4 bright lime bags. +clear blue bags contain 3 plaid beige bags. +drab silver bags contain 3 dim violet bags, 1 muted yellow bag, 1 pale beige bag. +dark silver bags contain 4 dark fuchsia bags, 4 bright green bags, 5 dim beige bags, 1 light tomato bag. +mirrored gray bags contain 2 striped black bags. +posh black bags contain 3 dull indigo bags, 3 striped beige bags, 3 dim blue bags, 2 wavy lime bags. +clear teal bags contain 2 dark orange bags, 4 pale beige bags, 5 clear beige bags, 4 dark teal bags. +pale white bags contain 2 drab gray bags, 1 muted olive bag. +muted fuchsia bags contain 2 clear brown bags, 4 mirrored green bags, 2 striped tan bags. +bright cyan bags contain 1 dotted plum bag. +light tomato bags contain 2 dim violet bags, 1 pale green bag, 4 dim orange bags, 1 dotted tomato bag. +pale turquoise bags contain 2 plaid black bags, 2 clear brown bags. +dim orange bags contain 1 plaid plum bag, 2 clear indigo bags, 1 dotted blue bag, 1 drab beige bag. +posh red bags contain 5 faded brown bags, 4 clear gray bags, 5 bright teal bags. +bright teal bags contain 4 clear beige bags. +posh lavender bags contain 1 drab beige bag, 5 dim salmon bags, 3 light crimson bags. +drab green bags contain 1 striped brown bag, 1 dull blue bag, 1 plaid coral bag. +clear coral bags contain 1 faded crimson bag, 4 light silver bags, 1 posh violet bag. +dark tan bags contain 5 faded brown bags. +vibrant aqua bags contain 1 light cyan bag, 5 bright brown bags. +dark blue bags contain 1 dark silver bag. +drab lime bags contain 3 faded white bags, 5 clear tomato bags, 1 dark turquoise bag. +faded lavender bags contain 1 bright violet bag, 4 posh gold bags. +dark orange bags contain 2 striped tan bags. +plaid orange bags contain 4 dark beige bags, 5 dull lavender bags, 4 striped white bags. +vibrant chartreuse bags contain 1 faded indigo bag, 4 clear magenta bags, 2 shiny blue bags, 2 dull teal bags. +dim white bags contain 3 faded white bags, 2 clear teal bags. +dim cyan bags contain 4 clear olive bags, 4 pale gray bags, 5 plaid bronze bags. +dotted chartreuse bags contain 1 bright magenta bag, 5 shiny maroon bags. +dull aqua bags contain 2 drab beige bags. +clear violet bags contain 3 pale teal bags, 3 posh tomato bags, 1 light silver bag, 2 faded coral bags. +pale lavender bags contain 1 drab beige bag, 2 dark teal bags. +clear tomato bags contain 5 muted beige bags, 1 plaid gold bag, 3 vibrant coral bags, 3 shiny silver bags. +clear cyan bags contain 4 faded lime bags, 2 drab tomato bags. +striped salmon bags contain 3 dim silver bags. +wavy silver bags contain 2 drab blue bags, 4 shiny green bags, 3 muted yellow bags. +dull indigo bags contain 5 mirrored plum bags. +faded coral bags contain 2 muted olive bags, 4 dark salmon bags. +muted olive bags contain 5 faded red bags, 1 dim lime bag, 1 striped white bag, 4 dark teal bags. +dotted plum bags contain 5 plaid blue bags. +striped cyan bags contain 4 mirrored plum bags, 2 wavy beige bags. +dotted olive bags contain 3 mirrored gold bags, 4 bright lavender bags, 2 dim turquoise bags. +plaid green bags contain 5 dark chartreuse bags, 5 mirrored bronze bags, 5 dark beige bags. +clear chartreuse bags contain 5 posh olive bags, 3 plaid violet bags, 3 mirrored fuchsia bags, 2 light orange bags. +wavy indigo bags contain 2 shiny teal bags, 3 clear olive bags. +shiny fuchsia bags contain 5 striped chartreuse bags, 1 light chartreuse bag. +shiny coral bags contain 4 dotted plum bags, 4 dull orange bags, 3 posh olive bags, 2 dark salmon bags. +bright black bags contain 5 drab gray bags, 1 vibrant black bag, 3 vibrant salmon bags, 3 dim silver bags. +bright salmon bags contain 1 shiny plum bag, 4 bright brown bags, 5 pale gray bags, 3 mirrored maroon bags. +faded yellow bags contain 1 light blue bag, 2 striped white bags, 3 dim lime bags, 4 wavy cyan bags. +plaid fuchsia bags contain 1 striped blue bag. +plaid lime bags contain 3 clear bronze bags, 4 dull orange bags, 1 pale aqua bag. +clear turquoise bags contain 1 posh aqua bag, 5 plaid black bags, 4 vibrant brown bags. +dull lime bags contain 3 mirrored crimson bags, 1 dotted crimson bag, 2 light lime bags, 2 light gray bags. +dull gray bags contain 5 bright lavender bags, 3 muted olive bags. +dotted turquoise bags contain 2 dim olive bags, 1 striped blue bag, 4 clear indigo bags. +vibrant purple bags contain 4 light olive bags, 4 mirrored salmon bags, 4 muted red bags. +dark cyan bags contain 2 dim lime bags, 5 light olive bags, 4 muted red bags, 3 drab indigo bags. +vibrant turquoise bags contain 4 light indigo bags. +bright bronze bags contain 2 pale green bags, 5 faded gray bags. +clear maroon bags contain 3 faded coral bags. +faded purple bags contain 5 plaid plum bags, 3 striped blue bags, 2 vibrant tan bags, 3 dark orange bags. +light indigo bags contain 2 wavy bronze bags, 5 bright lime bags, 4 drab lime bags, 2 dotted chartreuse bags. +dotted bronze bags contain 5 faded brown bags, 4 drab silver bags, 3 drab chartreuse bags. +mirrored lavender bags contain 3 dim salmon bags. +clear gold bags contain 1 dull plum bag. +vibrant beige bags contain 5 drab crimson bags. +dull yellow bags contain 5 mirrored green bags, 4 plaid bronze bags, 5 plaid blue bags, 4 dull orange bags. +dotted black bags contain 2 dull fuchsia bags, 2 light fuchsia bags, 3 mirrored lavender bags, 1 muted coral bag. +dotted maroon bags contain 3 plaid coral bags, 5 dotted cyan bags. +dim tomato bags contain 4 pale tomato bags, 3 striped beige bags. +wavy violet bags contain 4 mirrored crimson bags, 4 plaid bronze bags, 4 faded turquoise bags, 4 drab chartreuse bags. +shiny bronze bags contain 3 muted chartreuse bags, 3 drab gold bags. +faded fuchsia bags contain 1 bright blue bag, 1 dim purple bag, 1 dim magenta bag. +plaid turquoise bags contain 2 shiny olive bags, 5 dull orange bags, 2 dark fuchsia bags, 3 clear purple bags. +mirrored teal bags contain 4 drab cyan bags, 2 striped green bags. +clear purple bags contain 3 dull teal bags, 2 vibrant tan bags, 5 vibrant maroon bags. +dotted blue bags contain 2 muted white bags, 2 dark green bags, 2 faded purple bags, 2 plaid blue bags. +light violet bags contain 5 dark salmon bags, 5 striped orange bags. +light beige bags contain 2 muted chartreuse bags, 4 striped brown bags, 3 wavy maroon bags. +wavy purple bags contain 4 dark violet bags, 3 drab fuchsia bags, 4 dull lavender bags, 3 drab lime bags. +light silver bags contain 4 posh brown bags, 3 vibrant crimson bags. +wavy white bags contain 5 mirrored fuchsia bags, 2 dotted turquoise bags, 5 striped tomato bags. +striped purple bags contain 4 dull chartreuse bags. +wavy teal bags contain 1 light chartreuse bag, 3 dark green bags. +vibrant indigo bags contain 2 dim coral bags. +pale red bags contain 3 drab cyan bags, 1 muted tan bag. +dark aqua bags contain 2 faded brown bags, 1 shiny gold bag, 3 light cyan bags, 2 light green bags. +dotted tan bags contain 2 drab beige bags, 2 faded gray bags. +faded aqua bags contain 5 faded brown bags. +drab turquoise bags contain 5 drab teal bags. +dark turquoise bags contain 2 dim teal bags, 1 dim coral bag, 1 clear beige bag. +wavy maroon bags contain 1 dim violet bag, 4 clear bronze bags. +dark gray bags contain 2 bright blue bags. +mirrored coral bags contain 1 clear lime bag, 1 posh gray bag. +dim red bags contain 3 plaid aqua bags, 4 plaid salmon bags, 3 pale gray bags, 4 wavy indigo bags. +dull maroon bags contain 3 light silver bags, 1 dim lime bag, 2 striped silver bags. +vibrant salmon bags contain 1 dark gray bag, 2 dotted cyan bags, 2 drab gray bags, 3 muted tan bags. +vibrant lime bags contain no other bags. +wavy blue bags contain 5 bright maroon bags, 2 dull plum bags, 4 pale magenta bags. +dim purple bags contain 3 dull indigo bags. +muted indigo bags contain 5 posh orange bags, 4 dim yellow bags. +posh gold bags contain 2 clear beige bags, 3 vibrant lime bags. +plaid purple bags contain 4 faded brown bags, 3 shiny blue bags, 1 faded white bag. +clear lime bags contain 5 posh aqua bags, 2 posh fuchsia bags, 1 clear teal bag, 4 faded cyan bags. +bright brown bags contain 5 plaid bronze bags, 4 faded indigo bags. +striped maroon bags contain 1 faded turquoise bag, 3 drab cyan bags, 5 dark gray bags, 2 pale black bags. +faded violet bags contain 4 drab crimson bags. +muted brown bags contain 2 bright tomato bags, 3 dim gold bags, 5 dull blue bags. +posh magenta bags contain 2 dark fuchsia bags. +vibrant green bags contain 3 dark fuchsia bags. +shiny tomato bags contain 2 light turquoise bags, 5 drab green bags, 1 posh gold bag. +faded olive bags contain 1 shiny purple bag, 4 wavy tan bags, 4 wavy violet bags, 1 muted fuchsia bag. +mirrored fuchsia bags contain 1 clear brown bag. +faded magenta bags contain 3 striped white bags, 3 posh tomato bags, 3 striped lime bags. +dim crimson bags contain 5 mirrored brown bags, 1 faded black bag, 1 dark orange bag. +dark green bags contain 2 dotted beige bags, 5 plaid blue bags. +dotted purple bags contain 4 shiny black bags, 1 muted violet bag, 1 drab green bag, 3 faded yellow bags. +posh turquoise bags contain 3 shiny plum bags. +muted gray bags contain 4 dull gray bags, 4 posh teal bags, 5 plaid gray bags. +shiny teal bags contain 2 pale beige bags. +shiny olive bags contain 1 striped tan bag, 3 mirrored turquoise bags. +dull white bags contain 2 pale orange bags, 1 dim magenta bag, 4 drab maroon bags. +drab aqua bags contain 1 wavy red bag. +dotted teal bags contain 3 shiny green bags, 3 drab beige bags, 1 drab crimson bag. +light cyan bags contain 2 mirrored green bags, 5 dotted beige bags, 5 faded white bags, 3 mirrored fuchsia bags. +dim maroon bags contain 1 drab fuchsia bag, 1 mirrored salmon bag. +mirrored maroon bags contain 4 muted white bags, 2 striped tan bags, 2 dark teal bags. +dark brown bags contain 1 striped bronze bag, 5 striped plum bags, 3 muted bronze bags, 2 striped lime bags. +plaid gray bags contain 1 clear brown bag, 5 shiny orange bags, 4 posh bronze bags, 5 light cyan bags. +dim gold bags contain 4 striped tomato bags, 5 striped fuchsia bags, 4 striped white bags, 1 clear brown bag. +drab tan bags contain 5 plaid fuchsia bags, 1 dim teal bag, 4 plaid gold bags. +bright aqua bags contain 4 faded indigo bags, 3 shiny blue bags, 4 posh aqua bags, 5 wavy tan bags. +pale lime bags contain 4 muted blue bags, 5 wavy purple bags. +plaid maroon bags contain 2 dim black bags, 1 drab indigo bag. +wavy gray bags contain 4 drab orange bags. +drab gold bags contain 1 dark gray bag, 4 pale gold bags. +plaid teal bags contain 2 dim teal bags, 1 vibrant lavender bag. +dark salmon bags contain 4 plaid black bags, 2 dim lime bags, 4 pale orange bags, 3 pale beige bags. +plaid lavender bags contain 3 faded red bags, 2 plaid aqua bags. +light fuchsia bags contain 3 dim violet bags. +faded chartreuse bags contain 2 mirrored gold bags, 5 drab gold bags, 3 mirrored salmon bags. +wavy beige bags contain 2 dotted salmon bags, 4 muted white bags. +striped tomato bags contain 4 drab cyan bags. +dotted white bags contain 4 bright green bags, 1 light brown bag. +muted yellow bags contain 3 dim violet bags, 1 posh aqua bag, 2 muted teal bags. +light chartreuse bags contain 4 posh aqua bags, 2 dim coral bags. +muted maroon bags contain 1 mirrored cyan bag, 4 dim olive bags. +pale yellow bags contain 3 bright olive bags. +dull bronze bags contain 2 plaid maroon bags, 2 vibrant bronze bags. +shiny gold bags contain 5 clear brown bags, 5 plaid fuchsia bags, 4 bright teal bags, 1 striped white bag. +posh crimson bags contain 4 vibrant plum bags. +clear silver bags contain 5 dim beige bags, 1 dark olive bag. +striped violet bags contain 5 posh orange bags, 1 vibrant crimson bag. +muted green bags contain 1 bright crimson bag. +shiny gray bags contain 4 striped maroon bags, 5 muted plum bags, 2 light chartreuse bags. +wavy turquoise bags contain 1 pale gold bag. +clear olive bags contain 4 plaid fuchsia bags. +drab indigo bags contain 1 clear purple bag, 4 light silver bags, 2 mirrored cyan bags, 2 clear lime bags. +dim salmon bags contain 1 pale aqua bag, 5 posh fuchsia bags, 4 plaid coral bags, 1 pale orange bag. +light black bags contain 3 muted chartreuse bags. +plaid indigo bags contain 3 plaid fuchsia bags, 2 muted tomato bags, 3 muted bronze bags, 1 drab white bag. +light crimson bags contain 2 striped chartreuse bags, 4 bright teal bags, 3 striped fuchsia bags. +bright purple bags contain 2 shiny violet bags. +dark bronze bags contain 3 striped violet bags, 4 clear beige bags. +dark white bags contain 5 faded white bags, 5 striped fuchsia bags, 2 vibrant lime bags, 5 striped tan bags. +mirrored orange bags contain 4 wavy aqua bags. +mirrored cyan bags contain 5 bright bronze bags. +dull blue bags contain 2 bright brown bags, 2 dim plum bags. +posh indigo bags contain 1 posh lime bag. +vibrant brown bags contain 1 bright indigo bag, 2 striped purple bags, 5 mirrored lime bags, 2 plaid plum bags. +wavy coral bags contain no other bags. +posh cyan bags contain 1 plaid plum bag, 2 plaid gold bags, 3 shiny plum bags. +vibrant tan bags contain 5 mirrored turquoise bags, 3 faded gray bags, 5 posh brown bags, 3 clear brown bags. +mirrored black bags contain 5 striped fuchsia bags, 1 striped tan bag, 3 pale green bags. +bright olive bags contain 1 bright orange bag, 4 drab gold bags, 3 dim cyan bags, 2 drab plum bags. +striped blue bags contain 3 dark white bags, 1 clear beige bag, 3 dim olive bags. +dim turquoise bags contain 4 muted turquoise bags, 1 dotted tomato bag, 4 muted brown bags. +posh green bags contain 4 dim gray bags, 4 clear brown bags. +dull magenta bags contain 3 bright plum bags. +dark red bags contain 2 muted magenta bags, 2 dark beige bags, 2 shiny black bags. +pale black bags contain 2 striped bronze bags. +dotted red bags contain 2 striped blue bags, 3 dim violet bags, 3 faded maroon bags. +dark chartreuse bags contain 5 striped orange bags, 5 dark white bags. +clear lavender bags contain 2 faded crimson bags, 5 clear purple bags, 3 vibrant tan bags. +vibrant white bags contain 1 drab crimson bag, 5 dim violet bags. +drab lavender bags contain 3 clear yellow bags, 5 shiny tan bags. +wavy cyan bags contain 5 shiny violet bags. +faded black bags contain 2 posh aqua bags, 5 bright teal bags, 1 posh orange bag, 4 vibrant coral bags. +mirrored tomato bags contain 3 muted cyan bags, 3 drab brown bags, 1 striped orange bag. +faded orange bags contain 3 plaid fuchsia bags, 5 mirrored crimson bags, 2 pale aqua bags, 2 dull lavender bags. +muted salmon bags contain 1 wavy tan bag, 2 muted chartreuse bags, 2 posh green bags, 5 shiny magenta bags. +pale plum bags contain 4 dull teal bags, 1 striped violet bag, 2 wavy crimson bags, 2 posh violet bags. +shiny magenta bags contain 3 muted yellow bags, 5 light beige bags, 1 dull white bag, 4 striped lavender bags. +plaid black bags contain 4 mirrored green bags. +clear plum bags contain 5 posh violet bags. +bright silver bags contain 2 dull yellow bags, 3 striped red bags, 3 dotted olive bags, 5 bright salmon bags. +muted gold bags contain 1 dull olive bag. +vibrant tomato bags contain 4 shiny blue bags, 1 bright indigo bag. +dim black bags contain 1 plaid gold bag, 2 muted white bags. +plaid white bags contain 2 muted cyan bags, 1 mirrored magenta bag, 3 striped red bags, 2 striped violet bags. +drab maroon bags contain 1 dotted cyan bag, 3 shiny orange bags. +shiny purple bags contain 3 posh purple bags. +shiny violet bags contain 3 dark teal bags, 3 shiny olive bags, 4 dull cyan bags, 1 dim plum bag. +dull chartreuse bags contain 2 bright tan bags, 2 wavy fuchsia bags, 4 bright teal bags, 1 posh violet bag. +striped fuchsia bags contain 5 dotted beige bags. +muted lime bags contain 1 vibrant tan bag. +dotted coral bags contain 5 mirrored magenta bags, 4 wavy blue bags. +bright turquoise bags contain 5 pale indigo bags. +bright maroon bags contain 4 plaid salmon bags, 3 wavy coral bags, 4 dull orange bags, 1 pale green bag. +dim green bags contain 4 posh olive bags, 4 dim white bags, 3 clear orange bags. +mirrored bronze bags contain 4 mirrored fuchsia bags. +shiny maroon bags contain 1 wavy maroon bag, 1 drab gray bag, 1 posh white bag. +wavy olive bags contain 1 muted purple bag, 1 shiny brown bag, 5 faded tomato bags. +dotted crimson bags contain 2 shiny blue bags, 4 dotted blue bags, 5 vibrant crimson bags. +mirrored olive bags contain 3 muted bronze bags, 1 drab tomato bag, 3 drab violet bags. +light aqua bags contain 3 faded cyan bags, 4 shiny white bags. +clear fuchsia bags contain 3 bright blue bags. +light green bags contain 2 dim brown bags, 4 drab green bags. +bright magenta bags contain 1 mirrored turquoise bag, 2 dark fuchsia bags, 5 shiny plum bags. +pale fuchsia bags contain 4 wavy purple bags, 2 striped salmon bags, 4 pale black bags, 3 dotted teal bags. +posh tan bags contain 3 plaid purple bags. +dull tomato bags contain 2 clear salmon bags, 2 striped yellow bags, 5 pale indigo bags. +bright white bags contain 1 drab white bag, 4 dim violet bags. +bright gray bags contain 5 muted yellow bags, 5 vibrant crimson bags. +dull silver bags contain 2 muted purple bags. +dotted gray bags contain 2 mirrored magenta bags, 1 dark lavender bag, 1 clear blue bag, 4 faded magenta bags. +wavy gold bags contain 3 mirrored green bags, 5 pale aqua bags. +shiny plum bags contain 5 plaid blue bags, 2 muted white bags, 5 pale gray bags, 2 faded indigo bags. +posh plum bags contain 4 wavy magenta bags, 3 mirrored plum bags. +clear bronze bags contain 4 bright aqua bags, 4 dim white bags, 4 plaid blue bags, 5 plaid black bags. +vibrant teal bags contain 2 light violet bags, 4 clear orange bags, 1 shiny plum bag, 1 light cyan bag. +clear red bags contain 2 drab tan bags. +striped coral bags contain 1 shiny olive bag, 1 dark teal bag, 3 dark white bags. +striped aqua bags contain 4 wavy teal bags, 2 dull chartreuse bags, 3 mirrored cyan bags, 5 plaid gray bags. +drab purple bags contain 1 faded fuchsia bag, 5 dull chartreuse bags, 1 light white bag, 5 posh gold bags. +mirrored brown bags contain 5 bright aqua bags, 5 shiny blue bags, 5 dotted blue bags, 1 posh fuchsia bag. +dim gray bags contain 4 vibrant chartreuse bags, 5 clear beige bags, 1 shiny orange bag, 5 light chartreuse bags. +mirrored purple bags contain 3 shiny gold bags, 4 plaid aqua bags, 4 wavy gold bags. +drab black bags contain 4 faded aqua bags. +pale tomato bags contain 3 vibrant gold bags, 2 dotted cyan bags, 3 wavy brown bags, 5 bright violet bags. +muted plum bags contain 5 dull white bags, 5 drab chartreuse bags, 4 clear gray bags. +bright lime bags contain 1 light chartreuse bag. +light yellow bags contain 1 vibrant teal bag, 1 dull teal bag. +dark fuchsia bags contain 3 dim plum bags, 5 faded purple bags. +dim blue bags contain 5 striped coral bags, 3 drab fuchsia bags, 5 drab salmon bags. +posh orange bags contain 2 pale gray bags, 4 plaid bronze bags, 5 vibrant tan bags. +striped beige bags contain 3 mirrored crimson bags, 3 muted fuchsia bags. +dim fuchsia bags contain 5 clear white bags. +dull orange bags contain 2 striped crimson bags, 2 dark white bags, 1 dark turquoise bag, 3 shiny olive bags. +drab fuchsia bags contain 3 dark crimson bags, 5 clear magenta bags, 5 faded brown bags. +dim tan bags contain 3 dull indigo bags, 3 clear magenta bags. +clear green bags contain 3 bright blue bags, 4 clear teal bags, 2 pale indigo bags. +shiny black bags contain 1 mirrored brown bag. +pale maroon bags contain 2 faded lime bags, 2 wavy red bags, 1 dark orange bag. +faded crimson bags contain 1 posh aqua bag, 5 bright brown bags, 4 dull teal bags, 4 striped orange bags. +muted tan bags contain 2 pale gold bags, 3 striped magenta bags, 5 plaid gold bags, 5 striped fuchsia bags. +light turquoise bags contain 2 dull plum bags. +dull lavender bags contain 3 dark green bags, 3 light brown bags, 2 posh fuchsia bags, 5 posh bronze bags. +pale olive bags contain 5 striped blue bags, 1 striped coral bag, 2 muted white bags. +dark crimson bags contain 1 bright red bag. +vibrant gray bags contain 1 clear coral bag, 4 posh aqua bags, 5 clear brown bags, 5 dull chartreuse bags. +plaid tan bags contain 2 bright coral bags, 3 wavy salmon bags. +bright crimson bags contain 4 clear indigo bags, 3 dim plum bags, 4 posh brown bags. +dotted magenta bags contain 5 bright lime bags, 2 dotted coral bags. +posh aqua bags contain 5 vibrant lime bags, 5 plaid fuchsia bags. +striped turquoise bags contain 5 pale lavender bags. +pale chartreuse bags contain 4 mirrored tan bags, 5 mirrored black bags. +pale tan bags contain 4 plaid beige bags, 3 light tomato bags, 1 dark tan bag, 4 faded lime bags. +wavy plum bags contain 5 dark crimson bags, 4 dim black bags. +posh brown bags contain 3 dark teal bags, 5 striped white bags. +mirrored tan bags contain 3 clear maroon bags, 4 mirrored green bags, 1 dotted red bag, 1 wavy aqua bag. +dotted fuchsia bags contain 3 clear lime bags, 2 dim plum bags, 2 bright salmon bags, 5 faded violet bags. +drab cyan bags contain 4 striped coral bags, 5 faded gray bags, 2 posh orange bags. +light red bags contain 5 faded black bags. +plaid yellow bags contain 3 striped green bags, 4 striped olive bags, 1 mirrored lavender bag. +muted black bags contain 2 muted turquoise bags, 3 wavy bronze bags, 5 wavy teal bags. +plaid silver bags contain 2 drab maroon bags, 2 wavy maroon bags, 5 dark tan bags. +dark coral bags contain 1 posh bronze bag, 5 bright coral bags. +bright violet bags contain 3 posh brown bags, 4 pale orange bags, 2 muted olive bags, 2 posh orange bags. +pale silver bags contain 3 pale fuchsia bags, 4 bright cyan bags. +dim plum bags contain 1 faded brown bag. +mirrored red bags contain 3 dull magenta bags, 2 light gold bags. +posh beige bags contain 5 plaid turquoise bags, 3 clear bronze bags, 5 plaid silver bags. +faded silver bags contain 4 muted violet bags, 3 muted tomato bags, 1 bright yellow bag. +dim coral bags contain 1 faded brown bag, 4 drab cyan bags, 1 shiny olive bag. +drab beige bags contain 5 mirrored fuchsia bags, 1 faded brown bag. +dark purple bags contain 1 striped tan bag, 2 light maroon bags. +drab magenta bags contain 4 dim silver bags, 4 mirrored silver bags, 5 muted tomato bags. +muted orange bags contain 5 dim olive bags, 5 pale brown bags, 2 mirrored black bags, 3 posh green bags. +dotted aqua bags contain 2 faded turquoise bags, 4 light yellow bags, 4 dotted lavender bags. +pale salmon bags contain 4 light cyan bags, 4 bright plum bags. +bright red bags contain 3 bright coral bags, 4 clear brown bags, 1 bright teal bag. +striped lime bags contain 5 bright yellow bags, 1 drab maroon bag, 5 muted silver bags. +clear magenta bags contain 5 light teal bags, 5 dotted cyan bags, 1 pale orange bag. +dull beige bags contain 1 posh cyan bag, 5 dark orange bags, 3 pale cyan bags, 5 drab salmon bags. +striped chartreuse bags contain 4 wavy maroon bags. +pale gray bags contain 1 plaid black bag. +dull black bags contain 3 dull brown bags. +dotted green bags contain 3 shiny maroon bags. +faded turquoise bags contain 2 dark violet bags. +wavy green bags contain 5 light gray bags, 5 vibrant lime bags. +light maroon bags contain 2 dotted teal bags, 3 striped fuchsia bags. +striped indigo bags contain 2 dim crimson bags. +shiny green bags contain 5 mirrored cyan bags, 5 faded red bags, 1 light silver bag, 4 mirrored black bags. +clear indigo bags contain 2 faded gray bags, 2 mirrored green bags. +vibrant magenta bags contain 4 muted silver bags, 3 bright crimson bags. +mirrored violet bags contain 1 dull blue bag. +clear yellow bags contain 1 plaid purple bag, 2 vibrant crimson bags, 3 faded white bags, 4 plaid gold bags. +light white bags contain 4 clear magenta bags, 4 drab green bags, 2 clear chartreuse bags. +striped brown bags contain 4 drab gold bags, 4 plaid red bags, 2 dim coral bags, 4 dim teal bags. +pale crimson bags contain 4 dim green bags, 2 striped crimson bags, 1 striped coral bag, 3 dark salmon bags. +dull olive bags contain 1 striped yellow bag, 2 bright aqua bags. +dark olive bags contain 2 faded indigo bags, 4 dim orange bags, 5 shiny silver bags, 5 dotted turquoise bags. +drab chartreuse bags contain 1 shiny olive bag, 1 posh tomato bag, 1 dark turquoise bag. +pale green bags contain 3 pale gray bags, 1 dim violet bag, 3 striped crimson bags, 3 faded cyan bags. +light gray bags contain 2 pale white bags, 1 dark beige bag, 1 clear purple bag. +plaid olive bags contain 5 drab aqua bags, 1 plaid bronze bag, 4 clear brown bags. +mirrored indigo bags contain 3 striped bronze bags, 3 faded green bags, 2 dotted green bags, 3 dull olive bags. +wavy brown bags contain 4 pale maroon bags. +shiny lime bags contain 2 posh gold bags, 5 posh black bags. +mirrored silver bags contain 4 pale cyan bags, 1 bright bronze bag, 1 mirrored blue bag. +shiny red bags contain 2 wavy purple bags, 5 drab yellow bags. +light coral bags contain 2 pale gold bags. +posh olive bags contain 2 bright aqua bags. +striped black bags contain 3 bright blue bags, 1 light salmon bag, 1 mirrored salmon bag. +dotted lime bags contain 5 muted indigo bags, 2 striped coral bags, 1 shiny orange bag, 4 dim black bags. +wavy fuchsia bags contain 4 clear magenta bags. +light plum bags contain 3 shiny maroon bags. +shiny brown bags contain 1 faded brown bag, 5 light teal bags. +clear tan bags contain 3 dark teal bags, 2 bright plum bags. +pale violet bags contain 1 clear turquoise bag, 4 dark tan bags, 3 muted green bags, 3 posh magenta bags. +plaid coral bags contain 2 faded red bags, 1 faded indigo bag, 4 striped blue bags, 5 vibrant maroon bags. +drab red bags contain 3 mirrored white bags, 5 drab tomato bags, 3 vibrant chartreuse bags, 2 faded crimson bags. +wavy chartreuse bags contain 1 bright brown bag, 2 vibrant aqua bags, 2 drab teal bags. +dull turquoise bags contain 1 dotted chartreuse bag, 1 wavy lime bag, 1 faded gold bag. +wavy tomato bags contain 4 bright orange bags, 4 shiny fuchsia bags, 1 bright gray bag, 1 posh violet bag. +mirrored lime bags contain 1 vibrant salmon bag, 5 dull white bags, 5 dotted lavender bags, 1 dull yellow bag. +muted white bags contain 4 muted olive bags, 3 mirrored green bags, 2 striped coral bags. +muted red bags contain 3 pale indigo bags, 2 dim violet bags, 2 bright red bags. +dotted lavender bags contain 1 clear indigo bag, 5 muted cyan bags, 5 plaid gray bags, 2 plaid aqua bags. +light lavender bags contain 3 drab tomato bags, 1 wavy tan bag, 1 muted magenta bag, 1 striped magenta bag. +faded gray bags contain 4 faded cyan bags. +dark plum bags contain 5 dim violet bags, 1 light teal bag, 3 faded brown bags, 1 plaid gold bag. +vibrant bronze bags contain 1 drab gray bag, 2 faded gray bags. +clear white bags contain 2 dark fuchsia bags, 2 dark gray bags. +pale beige bags contain 1 mirrored fuchsia bag. +bright chartreuse bags contain 3 clear crimson bags. +drab gray bags contain 2 faded gray bags, 4 posh orange bags, 3 dull teal bags, 4 shiny plum bags. +wavy black bags contain 1 pale maroon bag. +dark beige bags contain 1 faded gray bag. +dark violet bags contain 1 muted tan bag, 5 faded brown bags, 3 plaid black bags. +dim beige bags contain 1 dotted turquoise bag, 5 dim teal bags, 3 mirrored crimson bags. +posh silver bags contain 3 striped orange bags, 4 posh teal bags. +muted cyan bags contain 2 drab salmon bags, 1 pale olive bag, 2 dark plum bags. +dark indigo bags contain 2 dim magenta bags, 3 bright orange bags, 4 clear white bags. +dull violet bags contain 2 pale bronze bags, 2 mirrored blue bags. +pale teal bags contain 5 striped maroon bags, 3 pale gray bags. +bright green bags contain 4 drab green bags, 3 drab indigo bags, 5 dull blue bags. +posh violet bags contain 5 wavy white bags. +clear brown bags contain no other bags. \ No newline at end of file diff --git a/day7/program.js b/day7/program.js new file mode 100644 index 0000000..ac959f0 --- /dev/null +++ b/day7/program.js @@ -0,0 +1,75 @@ +const fs = require('fs'); + +const data = fs.readFileSync('./input.txt', 'utf-8'); +const rules = data.split("\n"); + +const allBags = extractRules(rules); +let matches = 0; + +for (color in allBags) { + if(willContainColor(allBags[color], 'shiny gold', {})) { + matches++; + } +}; + +console.log('bags that eventually contain a shiny gold bag', matches); + +const nestedBags = howManyNestedBags('shiny gold'); +console.log(`We got ${nestedBags} bags nested in shiny gold`); + +function extractRules(rules) { + let bagtypes = {}; + rules.forEach(rule => { + const parts = rule.split(' contain '); + parts[1] = parts[1].replace('.',''); + parts[0] = parts[0].replace(' bags', ''); + + const nestedBags = parts[1].split(', '); + bagtypes[parts[0]] = {}; + nestedBags.forEach(bag => { + let count = bag.substr(0,bag.indexOf(' ')); + if (count === 'no') count = 0; + count = parseInt(count); + const bagType = bag.substr(bag.indexOf(' ')+1); + let subBagType = bagType.replace(' bags', '').replace(' bag', ''); + bagtypes[parts[0]][subBagType] = count; + + }); + }); + + return bagtypes; +} + +function willContainColor(bags, color, matched) { + for (subColor in bags) { + if (color === subColor) { + return true; + } + + if (!matched.hasOwnProperty(subColor) && bags.hasOwnProperty(subColor)) { + matched[subColor] = true; + if (willContainColor(allBags[subColor], color, matched)) { + return true; + } + } + + } +} + +function howManyNestedBags(color) { + let bagCount = 0; + + for (subColor in allBags[color]) { + if (subColor !== 'other') { + bagCount += allBags[color][subColor]; + const subColorCount = allBags[color][subColor]; + let subCount = howManyNestedBags(subColor); + if (subCount > 0) { + + subCount = subCount * subColorCount; + bagCount += subCount; + } + } + } + return bagCount; +} \ No newline at end of file diff --git a/day8/input.txt b/day8/input.txt new file mode 100644 index 0000000..d521153 --- /dev/null +++ b/day8/input.txt @@ -0,0 +1,611 @@ +acc +22 +acc +42 +nop +456 +jmp +5 +acc +31 +acc +49 +acc +10 +jmp +519 +nop +390 +jmp +418 +nop +29 +acc -4 +jmp +156 +jmp +85 +acc +5 +acc +26 +jmp +497 +acc -6 +acc -18 +acc +20 +acc +4 +jmp -8 +jmp +372 +jmp +371 +jmp -1 +jmp +1 +nop +378 +acc +18 +jmp +388 +jmp +1 +acc +29 +acc +37 +jmp +1 +jmp +425 +acc +19 +acc +13 +jmp +477 +acc +7 +jmp +469 +nop +495 +nop +141 +acc +22 +jmp +517 +jmp +125 +nop +30 +acc +37 +acc +23 +nop +238 +jmp +110 +jmp +411 +acc +2 +acc -19 +acc -19 +jmp +296 +acc +0 +acc +14 +acc +20 +jmp +75 +nop +88 +acc -16 +acc +40 +acc +27 +jmp +131 +acc +33 +nop +252 +acc +5 +acc +0 +jmp +101 +nop +219 +acc +50 +acc +40 +jmp +49 +nop +74 +jmp +327 +acc +47 +jmp +206 +acc -15 +jmp +449 +acc -17 +acc -13 +acc +46 +jmp +417 +jmp +160 +acc -7 +acc -11 +acc +16 +acc +14 +jmp -37 +acc -12 +acc +15 +acc -14 +nop +110 +jmp +1 +acc -4 +nop +287 +nop -82 +jmp +30 +jmp +490 +acc +34 +jmp +305 +nop +90 +jmp +1 +nop -4 +nop -95 +jmp -46 +acc +26 +acc +13 +acc +47 +jmp +350 +acc +11 +jmp -102 +acc -2 +jmp +489 +acc +28 +acc +24 +nop +486 +jmp +485 +nop +170 +jmp +66 +jmp +411 +acc +30 +acc +48 +acc +48 +jmp -6 +acc +11 +jmp -51 +jmp +1 +jmp -10 +nop +411 +acc -17 +acc +32 +jmp +9 +jmp +398 +nop +82 +jmp +6 +acc +45 +acc +34 +jmp -44 +acc -13 +jmp -122 +acc +25 +nop +286 +acc +5 +jmp +144 +acc +0 +jmp -122 +acc -11 +acc -6 +jmp -123 +acc +16 +acc +1 +jmp -58 +nop +242 +acc -11 +jmp +257 +nop +231 +acc +46 +jmp +301 +acc -6 +acc +20 +acc -7 +jmp +365 +acc +32 +acc +0 +jmp -66 +jmp +110 +acc -18 +jmp +118 +acc +33 +nop -125 +acc +49 +acc +36 +jmp +188 +acc +9 +acc -11 +jmp +100 +acc +35 +jmp +55 +acc +38 +acc -1 +jmp +312 +jmp +157 +acc +17 +jmp +177 +nop -126 +acc +30 +acc -3 +jmp +211 +acc -3 +jmp -164 +jmp -112 +acc +50 +jmp +268 +nop +290 +acc -8 +acc +35 +jmp -44 +acc -6 +acc +11 +nop +327 +jmp +155 +acc +10 +acc +35 +nop +233 +jmp +330 +acc +31 +acc +8 +jmp +124 +acc -5 +jmp +300 +nop +171 +nop +4 +acc +19 +acc +41 +jmp -156 +nop +179 +acc +12 +jmp +160 +jmp -92 +acc -11 +acc -10 +jmp +95 +nop +94 +acc -8 +jmp -199 +acc +16 +acc +30 +nop +73 +acc +36 +jmp -53 +jmp +1 +jmp -6 +nop +369 +acc +29 +acc +47 +jmp +32 +acc +35 +jmp -61 +acc +41 +jmp +352 +acc -1 +jmp +75 +acc -10 +acc +28 +acc -15 +jmp -187 +acc +6 +jmp +1 +nop +112 +jmp +273 +nop +186 +acc +11 +acc +40 +jmp +128 +acc +17 +acc +23 +acc -8 +nop +277 +jmp +42 +acc +11 +nop -237 +acc +36 +acc +32 +jmp +287 +acc +16 +acc -19 +jmp +115 +acc -6 +acc +16 +nop -2 +acc +23 +jmp -160 +acc -10 +acc -10 +jmp +26 +acc -7 +jmp -95 +nop -160 +acc -2 +acc +44 +jmp -236 +jmp -198 +jmp +1 +acc +1 +jmp -9 +jmp -95 +jmp +273 +acc -19 +jmp -46 +acc +12 +acc +2 +jmp -145 +acc -14 +acc +3 +acc +3 +jmp +250 +acc +4 +acc +40 +jmp +1 +jmp +17 +acc +6 +acc +47 +jmp -77 +nop -192 +acc +11 +jmp +296 +acc -14 +jmp +64 +acc +35 +jmp +134 +acc -8 +nop +228 +acc +24 +acc +15 +jmp -64 +jmp -241 +acc +19 +acc +22 +acc +49 +nop -193 +jmp +219 +acc -1 +acc -11 +nop +211 +acc +0 +jmp -106 +nop +101 +jmp -222 +acc +20 +acc +45 +jmp +70 +acc +19 +acc +21 +jmp -23 +acc +8 +nop +92 +acc +47 +jmp -144 +acc +0 +acc -1 +jmp -81 +acc +23 +jmp -274 +acc +14 +acc +26 +acc +9 +jmp +79 +acc +22 +jmp -331 +acc -10 +jmp -311 +acc +16 +acc +30 +acc -8 +jmp +176 +acc -19 +acc +43 +jmp -222 +nop -116 +jmp +18 +acc +26 +acc +23 +acc +6 +jmp -162 +acc +34 +jmp +95 +acc +27 +acc +40 +acc +9 +jmp -77 +jmp +137 +acc -13 +acc +21 +acc +17 +acc -5 +jmp +91 +jmp -95 +acc +18 +acc -1 +jmp +70 +jmp -355 +nop -166 +acc -19 +acc +16 +jmp -146 +jmp -135 +jmp +57 +acc +45 +jmp -62 +acc -14 +jmp -382 +nop -172 +acc +45 +jmp -77 +acc +13 +jmp +65 +acc -4 +jmp +112 +jmp +107 +jmp +26 +jmp -326 +acc +25 +jmp +1 +jmp +179 +acc +33 +acc +2 +jmp -222 +nop +36 +acc +25 +nop -244 +jmp -376 +jmp -203 +acc +26 +nop +109 +acc +38 +jmp +135 +acc +7 +acc +40 +acc -18 +jmp -113 +nop -294 +acc +0 +acc +40 +nop -265 +jmp +81 +jmp -99 +jmp +32 +acc -17 +acc +25 +acc -12 +acc +26 +jmp -125 +acc -3 +acc -7 +acc +25 +jmp -410 +acc +47 +acc +36 +jmp +35 +acc +2 +acc +18 +acc -3 +jmp -38 +acc +29 +acc +49 +jmp -299 +acc -4 +nop -422 +jmp +50 +acc +11 +acc +2 +acc +49 +jmp -233 +acc +12 +acc +43 +acc -19 +acc +11 +jmp -264 +jmp +124 +jmp -361 +acc +35 +jmp -118 +acc +23 +acc -16 +acc -14 +jmp -22 +jmp -135 +jmp -309 +acc +6 +jmp -44 +acc -12 +acc +0 +jmp -23 +acc +29 +acc -8 +acc +18 +acc +35 +jmp -111 +acc +22 +acc +23 +acc +0 +acc -8 +jmp -55 +acc +14 +jmp +1 +acc +44 +acc +17 +jmp -272 +acc +39 +nop +37 +acc -19 +jmp -323 +acc +24 +acc +28 +acc +29 +acc +37 +jmp +110 +jmp -386 +nop -352 +acc +23 +acc +38 +jmp -369 +acc -5 +acc -14 +jmp +83 +jmp +17 +jmp -151 +jmp -118 +jmp -104 +jmp -341 +acc +32 +acc +43 +jmp -52 +acc -4 +acc +42 +acc +5 +jmp -116 +acc +13 +jmp +1 +nop -361 +acc +41 +jmp -386 +jmp -241 +nop -449 +acc +46 +jmp -176 +acc +6 +jmp +60 +jmp +1 +jmp -3 +jmp -62 +acc -14 +acc +17 +jmp -340 +acc +31 +acc -13 +acc +7 +jmp -54 +jmp -80 +acc +14 +acc +49 +acc +34 +jmp +24 +acc +11 +jmp -158 +acc -13 +jmp -261 +acc +33 +nop -171 +jmp -106 +acc +0 +acc +9 +acc +16 +acc +34 +jmp +18 +acc -2 +acc +47 +acc +39 +jmp -232 +acc +23 +nop -229 +acc +30 +acc +32 +jmp -147 +acc -8 +jmp -460 +jmp -498 +nop -218 +acc +31 +acc +44 +acc +30 +jmp -105 +acc +8 +acc -19 +acc +45 +nop -49 +jmp -140 +nop -43 +acc +42 +jmp +1 +acc -14 +jmp -42 +jmp -389 +acc +39 +acc +26 +acc +38 +jmp -77 +acc +48 +jmp -83 +acc +5 +jmp -81 +nop -242 +acc +35 +acc +0 +acc +19 +jmp -430 +acc +11 +nop -226 +acc +13 +acc +23 +jmp -575 +acc +44 +acc +50 +nop -303 +jmp -112 +jmp -305 +acc +23 +acc -11 +nop -376 +acc +50 +jmp +1 \ No newline at end of file diff --git a/day8/program.js b/day8/program.js new file mode 100644 index 0000000..4715098 --- /dev/null +++ b/day8/program.js @@ -0,0 +1,63 @@ +const fs = require('fs'); + +const data = fs.readFileSync('./input.txt', 'utf-8'); +const readData = data.split("\n"); + +let onlyChangeTheseLines = execute(readData, true); + +readData.forEach((l, i) => { + const copy = JSON.parse(JSON.stringify(readData)); + if (onlyChangeTheseLines.indexOf(i) === -1) return; + if (l.indexOf('nop') > -1) { + copy[i] = l.replace('nop','jmp'); + } else if (l.indexOf('jmp') > -1) { + copy[i] = l.replace('jmp','nop'); + } + + execute(copy); +}); + + +function execute(instructions, outputDeadEnd) { + const lines = []; + let acc = 0; + let line = 0; + let executedLines = []; + + instructions.forEach(i => { + lines.push(splitInstruction(i)); + }); + + return run(); + + function splitInstruction(instruction) { + const parts = instruction.split(' '); + const type = parts[0]; + const amount = parts[1].indexOf('+') > -1 ? parseInt(parts[1].substr(1)) : parseInt(parts[1]); + return {type: type, amount: amount}; + } + + function run() { + if (executedLines.indexOf(line) > -1) { + if (outputDeadEnd) { + console.log('Part 1', acc); + } + return executedLines; + } + + const instrcution = lines[line]; + executedLines.push(line); + + if (instrcution.type === 'acc') { + acc += instrcution.amount; + line++; + } else if (instrcution.type === 'nop') { + line++; + } else if (instrcution.type === 'jmp') { + line += instrcution.amount; + } + + if (instructions[line]) return run(); + console.log('Part 2: ', acc); + } +} \ No newline at end of file diff --git a/day9/input.txt b/day9/input.txt new file mode 100644 index 0000000..a178437 --- /dev/null +++ b/day9/input.txt @@ -0,0 +1,1000 @@ +37 +7 +16 +34 +48 +24 +5 +40 +30 +35 +2 +45 +19 +33 +36 +49 +32 +1 +44 +21 +25 +3 +11 +38 +15 +4 +6 +7 +8 +16 +9 +10 +5 +12 +13 +17 +14 +35 +18 +19 +20 +23 +36 +53 +22 +21 +41 +28 +11 +24 +15 +25 +26 +27 +29 +64 +50 +31 +30 +34 +32 +44 +33 +47 +74 +35 +66 +37 +36 +38 +45 +39 +40 +41 +42 +57 +51 +55 +68 +70 +71 +72 +61 +88 +65 +75 +140 +77 +73 +82 +110 +81 +74 +116 +86 +80 +112 +83 +92 +128 +141 +106 +120 +146 +126 +147 +133 +134 +138 +139 +156 +209 +162 +160 +154 +155 +233 +216 +163 +313 +298 +273 +189 +198 +226 +253 +232 +265 +259 +260 +316 +267 +272 +277 +449 +428 +314 +309 +471 +318 +379 +430 +458 +387 +683 +475 +415 +421 +486 +525 +544 +575 +532 +519 +632 +539 +590 +739 +586 +623 +627 +688 +696 +697 +804 +1072 +1119 +940 +808 +896 +836 +990 +907 +1107 +1436 +1114 +1129 +1051 +1058 +1754 +1385 +1644 +1459 +1250 +2686 +1324 +2442 +1504 +1501 +1612 +1704 +1915 +1715 +1732 +1826 +1897 +2048 +2431 +2109 +3004 +2165 +2825 +2301 +3039 +2862 +3145 +2574 +2709 +2751 +3447 +4043 +3005 +4198 +3113 +3612 +4910 +3629 +3541 +4306 +4157 +4466 +4349 +4274 +5113 +5027 +5446 +6186 +7889 +8522 +5436 +5854 +5283 +5864 +6292 +6118 +6546 +6617 +6742 +6654 +7241 +7170 +7698 +8431 +11231 +8506 +8623 +9301 +9387 +10140 +10310 +12518 +11137 +10719 +11147 +11290 +11401 +11575 +12156 +12410 +12664 +16757 +13271 +13396 +19611 +14411 +14868 +17129 +16937 +29793 +17807 +17924 +18688 +27532 +23665 +21029 +21866 +23954 +22009 +22976 +30217 +34022 +25986 +27807 +29601 +30400 +26667 +27682 +28264 +40602 +29279 +31805 +34066 +41472 +45606 +41589 +47696 +48711 +55214 +43038 +57543 +69154 +45963 +77223 +66588 +68866 +55265 +115299 +58207 +54349 +95816 +68284 +62330 +115750 +61084 +100312 +90012 +116995 +100820 +84627 +139841 +94674 +89001 +97387 +98303 +190490 +178080 +109614 +112556 +113472 +115433 +116349 +225364 +116679 +122633 +194241 +123414 +145711 +158471 +150085 +173628 +268085 +179301 +198099 +182014 +183675 +186388 +391499 +207001 +207917 +222170 +223086 +229235 +323350 +228905 +530351 +233028 +239312 +262390 +304647 +308556 +389397 +295796 +344859 +415293 +352929 +380113 +430087 +405100 +365689 +370063 +393389 +545520 +431003 +530726 +445256 +456114 +462263 +533552 +524701 +472340 +846296 +535108 +674245 +763452 +604352 +640655 +758059 +697788 +718618 +733042 +1129053 +759078 +838645 +876259 +824392 +918090 +887117 +893266 +907519 +901370 +1591316 +934603 +1469711 +1359500 +1742482 +1139460 +1175763 +1245007 +1302140 +1362411 +1338443 +1571687 +1416406 +1963852 +1557434 +1583470 +1597723 +1663037 +1769525 +2032726 +1780383 +1827869 +3212193 +1808889 +2351009 +2908044 +2538174 +2384467 +3385303 +3352070 +2315223 +2420770 +2547147 +2640583 +2778817 +3886910 +2973840 +2999876 +4336251 +3140904 +3181193 +5009062 +4606686 +4229659 +5601963 +3589272 +3636758 +4124112 +4159898 +4666232 +4699690 +4735993 +4805237 +6183905 +4862370 +4955806 +4967917 +5187730 +5419400 +7370563 +5973716 +6589148 +7226030 +6322097 +10580402 +6817951 +7713384 +11509827 +7749170 +7760870 +7796656 +8824488 +8860105 +8895891 +10281770 +12554407 +15536208 +9667607 +16645061 +13548127 +9923723 +13692660 +10607130 +22222014 +12295813 +14531335 +12911245 +20092469 +19476293 +14567121 +15678056 +15462554 +15510040 +18356300 +30972594 +19141875 +34623804 +17755996 +18563498 +19591330 +25386277 +20274737 +20530853 +27240787 +22902943 +22219536 +30198460 +30667241 +25207058 +26827148 +27442580 +43742577 +32323117 +30029675 +34158451 +33218550 +33266036 +33866340 +36112296 +37347326 +36319494 +52721949 +44977607 +38154828 +39866067 +40805590 +42494273 +43433796 +68014567 +45122479 +55485572 +58425608 +52034206 +52649638 +76652724 +57472255 +128686930 +95216222 +73666820 +66484586 +67084890 +69378332 +91338595 +72431790 +137710495 +74474322 +78020895 +127917362 +84988546 +84239386 +83299863 +85928069 +111607065 +132899930 +135078332 +186342970 +104683844 +109506461 +110121893 +123956841 +124557145 +161700808 +256917030 +186081387 +146906112 +136463222 +141810122 +150452685 +158713708 +207374252 +157774185 +167539249 +168288409 +193421756 +169227932 +269381250 +197535134 +229240989 +214190305 +244584793 +214805737 +219628354 +177777905 +246585115 +286915907 +261020367 +278273344 +311038054 +335827658 +283369334 +292262807 +360961005 +396780238 +437669659 +325313434 +365074383 +448869343 +361710165 +347005837 +608295280 +392583642 +422362698 +391968210 +397406259 +424363020 +456051249 +503091339 +461147239 +893720908 +561642678 +589311398 +570536151 +675337544 +619196992 +575632141 +639268644 +707966842 +708716002 +672319271 +687023599 +821769279 +754293807 +738974047 +739589479 +1483032306 +1031683390 +789374469 +1036779380 +1233961949 +880414269 +1133466510 +964238578 +1022789917 +1809594090 +2272406775 +1164943539 +1209804795 +1214900785 +1194829133 +1247951412 +1461693740 +1359342870 +1791073187 +1411908750 +1651262177 +1478563526 +1493883286 +1821057859 +1776368859 +1753613047 +1954318008 +2156256427 +1844652847 +1903204186 +3010605047 +1987028495 +2129182117 +2187733456 +3196833290 +3284956473 +2359772672 +2404633928 +2409729918 +2442780545 +2607294282 +2771251620 +2837906396 +3920255304 +2905792036 +3747857033 +3323216373 +3247496333 +4630514001 +4802553217 +3598265894 +4510498468 +4307838114 +3831681342 +4174761951 +4116210612 +7346122927 +4316915573 +4597463374 +5652130261 +4847414473 +4764406600 +6236315270 +5050074827 +5214032165 +7618666093 +6369517514 +8918763829 +6153288369 +6229008409 +6570712706 +6921482267 +7422258284 +7714476506 +7906104008 +7915181467 +8148596915 +11663038500 +8679095815 +8290972563 +8433126185 +8914378947 +9081322173 +11168176080 +9611821073 +13362629080 +9814481427 +10264106992 +11203363196 +12382296778 +14284698981 +12522805883 +12724001075 +16834819698 +23726169079 +13492194973 +17995701120 +15136734790 +15620580514 +15821285475 +22196778205 +16439569478 +16724098748 +23306676400 +17514448358 +17347505132 +18728860374 +18693143246 +19426302500 +19875928065 +21467470188 +21017844623 +32651183148 +24905102661 +28002877292 +31949108383 +31860833538 +40450267827 +29313480448 +28628929763 +38018063680 +33616281634 +34238547106 +31441865989 +59143411073 +33163668226 +36040648378 +34071603880 +48956314347 +36243308732 +60070795752 +49020721915 +55083751822 +39302230565 +40893772688 +70744096554 +45922947284 +52907979953 +54218583109 +59951985675 +63385084328 +57942410211 +62477148674 +93101815502 +61792597989 +65680413095 +64605534215 +93919014663 +67235272106 +69204316604 +69406976958 +70112252258 +70314912612 +75545539297 +110813319904 +88322952480 +80196003253 +150800101154 +118824117324 +110098089292 +98830927237 +100141530393 +112160993320 +114170568784 +129027870095 +157729929438 +199136272384 +124269746663 +186062344652 +127473011084 +130285947310 +133809850819 +136439588710 +183374885388 +138611293562 +139519229216 +250332549120 +194366572037 +204465749916 +316348291962 +168518955733 +210481950563 +314563839208 +232640778056 +238752823955 +198972457630 +212302523713 +250610157494 +438833585871 +251742757747 +266992240300 +266084304646 +705825826171 +257758958394 +270249439529 +264095798129 +272421144381 +404848522600 +441133843782 +278130522778 +308038184949 +362885527770 +367491413363 +379000906296 +380821479446 +502352915241 +409454408193 +411274981343 +431613235686 +437725281585 +478386828359 +484723668094 +633575718009 +509501716141 +703809586231 +523843263040 +852408825125 +521854756523 +528008397923 +534345237658 +766448713370 +653242623827 +778766394706 +586168707727 +641016050548 +688859664395 +730376941133 +869844328604 +889661809702 +790275887639 +820729389536 +841067643879 +842888217029 +955456498726 +1110011970767 +1070892375821 +1573265158162 +1227184758275 +1031356472664 +1056199994181 +1045698019563 +1252231697656 +1162870807071 +1169024448471 +1264722178791 +1479135552034 +1239411331554 +1275028372122 +1427236351606 +1510860379152 +2589147522801 +2054998066430 +2180904346588 +1611005277175 +1631343531518 +1776185888262 +1683955860908 +1798344715755 +2077054492227 +2087556466845 +2116590395384 +3761010353135 +2101898013744 +2194227279735 +2208568826634 +2402282138625 +3878083902006 +2331895255542 +4408949747769 +3458949458526 +2514439703676 +2666647683160 +2702264723728 +2938096730758 +3121865656327 +3460141749170 +3242348808693 +4325159222018 +5090292990044 +3315299392426 +3482300576663 +5330434482961 +3992571995490 +4631030099060 +6603177027504 +4218488409128 +4296125293479 +6148948259823 +4402796106369 +6364214465020 +5884582715288 +4846334959218 +4998542938702 +5181087386836 +6017564116154 +5216704427404 +9033826205429 +5640361454486 +8698921399848 +6582007405497 +6557648201119 +9936627949262 +7718095498795 +9199882107714 +7307871387916 +9961464582021 +8838906954708 +10215247366106 +9477365058278 +8514613702607 +20151875315368 +9142460252697 +9401339045071 +9583883493205 +15142551968857 +19249073571535 +11234268543558 +10179630325538 +10397791814240 +15983346450568 +26198593816674 +12198009655605 +12948232842402 +15781889513211 +15724467658194 +13865519589035 +15025966886711 +17679560080816 +15822485090523 +16146778342624 +25939715024300 +30924441482068 +24924349765908 +17657073955304 +18098497195812 +18543799297768 +28913828624374 +18985222538276 +19763513818743 +20577422139778 +31707814108762 +21413898869096 +34325688810979 +27922477313799 +25146242498007 +38256982220594 +32409318886803 +31545079669851 +28891486475746 +53838178390282 +29688004679558 +30848451977234 +39957698166864 +50472467153603 +33803852297928 +68570964349415 +57805315100120 +37083719734088 +35755571151116 +36642296493580 +63239517435353 +38748736357019 +66735007697782 +44909756316750 +79219213969216 +46560141367103 +49336376182895 +57555561384810 +64647057626862 +78706434523883 +115861510462796 +62097323566361 +114974785120332 +78227862658641 +60536456656792 +66771724413646 \ No newline at end of file diff --git a/day9/program.js b/day9/program.js new file mode 100644 index 0000000..3df59f8 --- /dev/null +++ b/day9/program.js @@ -0,0 +1,70 @@ +const fs = require('fs'); + +const data = fs.readFileSync('./input.txt', 'utf-8'); +const itemsToCheck = 25; + +loopData(data.split("\n")); + +function loopData(rows) { + let last25 = []; + + rows.forEach((row, i) => { + if (last25.length === itemsToCheck+1) last25.splice(0,1); + if (last25.length === itemsToCheck) { + if (!hasSum(parseInt(row), last25)) { + console.log(i, 'part 1 FAIL', row); + + findSum(rows, parseInt(row)); + } + } + last25.push(parseInt(row)); + }); +} + +function hasSum(num, nums) { + for (let i = 0; i < nums.length; i++) { + const n1 = nums[i]; + for (let j = 0; j < nums.length; j++) { + const n2 = nums[j]; + const sum = parseInt(n1+n2); + if (num === sum) { + return true; + } + } + } + return false; +} + +function findSum(nums, sumToFind) { + let uses = []; + let found = false; + + nums.forEach(n => { + if (found) return; + if (sumOfArray(uses) > sumToFind && uses.length > 1) uses = stripToBelow(sumToFind, uses); + + if (sumOfArray(uses) === sumToFind) { + found = true; + uses.sort((a,b) => { return a > b ? 1 : -1}); + console.log('part 2 gotcha!', uses[0] + uses[uses.length - 1] , uses); + } + uses.push(parseInt(n)); + }); +} + +function stripToBelow(sumToFind, items) { + + items.splice(0, 1); + if (sumOfArray(items) > sumToFind && items.length > 1) { + return stripToBelow(sumToFind, items); + } + return items; +} + +function sumOfArray(items) { + let sum = 0; + items.forEach(i => { + sum += i; + }) + return sum; +} \ No newline at end of file