From 87ab487d59fa85dbe2afa55cc841b02805ae42ca Mon Sep 17 00:00:00 2001 From: Louis Burda Date: Fri, 7 Apr 2023 17:18:18 -0400 Subject: Reorder days into src --- src/02/input | 250 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/02/part1 | 50 ++++++++++++ src/02/part2 | 41 ++++++++++ src/02/solve.py | 40 +++++++++ 4 files changed, 381 insertions(+) create mode 100644 src/02/input create mode 100644 src/02/part1 create mode 100644 src/02/part2 create mode 100644 src/02/solve.py (limited to 'src/02') diff --git a/src/02/input b/src/02/input new file mode 100644 index 0000000..0bb005f --- /dev/null +++ b/src/02/input @@ -0,0 +1,250 @@ +vtnihorkulbfvjcyzmsjgdxplw +vtnihorvujbfejcyzmsqgdlpaw +vtnihoriulbzejcyzmsrgdxpaw +vtsihowkulbfejcyzmszgdxpaw +vtnizorkunbfejcyzmsqgdypaw +vtnihorkdlbfojcyzmsqgdfpaw +vtpioorkulbfejcysmsqgdxpaw +vtnvhorkulbfhjcyzmsqgdipaw +vtrihorkylbaejcyzmsqgdxpaw +vtnigorkulbfejcyzmszgjxpaw +rtnihorkklbfejcyzmslgdxpaw +vtnihorkqlbfejcyzmsqgmppaw +vgnisorkulbfejcyzmsqgdkpaw +atnihorkulbfejcyzmdbgdxpaw +vtnihorkulbfejcezmsqqixpaw +vtnihorkucbfejcxzmsqgdypaw +vtnihorkulxfajcyzmsqgyxpaw +vbnihorkulbfescyzmsqgdxpae +vanshorkulbfejcyzjsqgdxpaw +vtnihoukulbfejcyzmwqgdxpbw +vtndhorkulbfejcyxmgqgdxpaw +ztnihlrkupbfejcyzmsqgdxpaw +vtoihkrkulbfejhyzmsqgdxpaw +vtnihorkalbiejcyzmsqgdxeaw +vtnihorhulcfejcyzqsqgdxpaw +vtnshotkulbfejcyzmsqvdxpaw +vtnihoryulbfejcyzmsqgpspaw +vtnihorkukbfmjcyzmsqgdxpcw +vtnihorkulbfejcybmsqgdupxw +vlnihorkulbfejcyzmsqgdmpac +vtnihorkulbfejcezmfqgdkpaw +vpnihorkulbfejcyzmsqfdxyaw +vtnihorkulbjejcysmcqgdxpaw +vdnihorkulffejcyzisqgdxpaw +vtnihorkulkfsjcyzrsqgdxpaw +vtnihorkulqfegoyzmsqgdxpaw +vtnihorkulbfeyhyzgsqgdxpaw +vnnihorkulbfejcyzmdqgdxpfw +vtnihorkulstejcyzmsqgdxpak +vtnphorkujbfejcczmsqgdxpaw +vtpihorkulbfejcyzmskgdxiaw +vtnihorkulbfejcdzmxqsdxpaw +vtnihorgulbfticyzmsqgdxpaw +veniuorkulbfejcyzmsqgdmpaw +vhnihorkclbfejyyzmsqgdxpaw +vtnihorkulbfejcyzmrqgsrpaw +dtnihorkzlhfejcyzmsqgdxpaw +vtnizorkulbfejcyzhsqgdxdaw +vtnihohkulbfejcybmpqgdxpaw +vtnihbrzulbfejcyzmsqgdppaw +stnihorkulmfejcyzmsqgdxeaw +vtnihorkulbfejmgzwsqgdxpaw +vtnihcrkulbfnjdyzmsqgdxpaw +vxxihorkulbfejcyzmsqddxpaw +vtnhhorkulbfejcyzmsqgdpiaw +vtnihoakulbfvjcyzmmqgdxpaw +vtbbhorkulbfejcyqmsqgdxpaw +vtnihnukulbfejcxzmsqgdxpaw +vteihorgulkfejcyzmsqgdxpaw +vbnihorkulbfejcyzmsqgdxpmt +itnihorkulbuejcyzmsqgdxpxw +vtnfhqrkulbfejcwzmsqgdxpaw +vtnihorkubbfedcyzmsqpdxpaw +rtnihorkulhfejcyzmsqgdxpah +vtnihorzulbfejcyqmsqqdxpaw +vtnihorkulbfeecyzmsqgdcgaw +vtniuorkulbfejpyzmsqxdxpaw +vtnicorkilbfajcyzmsqgdxpaw +vtzihorkulbfejcyzmsqgaxpkw +vtnihomkulbfejcyzmsqgvmpaw +vznihockulbfejcyzmsqgdjpaw +vtqmhorkulhfejcyzmsqgdxpaw +ptnihorkulbfsjcyzbsqgdxpaw +ftnihorkulbfejcepmsqgdxpaw +vtnhhorkulbfejyyzxsqgdxpaw +vtnihorkulbfejcyzmsiwdxpxw +vtnikorkulbfejvyzmnqgdxpaw +vtnihorkulbgejoyzmsqhdxpaw +vtnihorkulbwejqylmsqgdxpaw +vtnihorkdlbfejcyzwsqgdrpaw +vtnihorkulbfojcyzmtugdxpaw +vtnihonkulbtejcyzxsqgdxpaw +vtnihorkulrfevcyzmsqgdxpcw +vtnioorkulbfejcynmsqgdxpad +vtnihorkudffejcyzhsqgdxpaw +vtnihorkelbfejcqzmsqgdxbaw +jtnihokkulbfejcyzmsqgdrpaw +ztnihorrulbfejcyzlsqgdxpaw +vtwiforkulbfejcyzmsqpdxpaw +vtnihopvulbfejcyzmsqgzxpaw +vtnihzrkulafejcyzmsqgdxpaj +vtnixoekulbfejcyzmsqgdxpak +vtnihorkulbfejxyzmsqgdxhlw +vtnihorkulbfwjcyzmmqcdxpaw +vtnihorkulbfejcywmsdgdxzaw +vtnihorkulbfejfyzmsqggxuaw +vtnihnrkurbfejcyzmsqggxpaw +vtuihorkulbkejcyzmsqgdxpww +vtnihoriuljfejcyzssqgdxpaw +vtnihorkulyftjcezmsqgdxpaw +vtnihorkklbfeccyzmsqgdppaw +vtnihorkulbfdpcyzmsqgdxpcw +vtnihqrkulgfejcyzmeqgdxpaw +vtnihorktlbfejdyzmswgdxpaw +vinihzrkulbfeacyzmsqgdxpaw +vtuihorkupbfejcyzmsqgdxplw +vtnihorkulbfcjcyzmlqgdxpsw +vtnihorkllbfejcyzmsqgdxvak +qtnihorkulbfdjcyzusqgdxpaw +vtniherkulbhejcyzmsqgzxpaw +vtnzhorgulbfejcyzmsqgdxpew +vtnihoykulhfjjcyzmsqgdxpaw +vtnihookulyfejcyzmsqgdxqaw +jtnihorkulbfejcyzmssgdxpaq +vtnicorkulwfejcyzmsxgdxpaw +wtnihorkuubfejcyzmsqgdxpam +vtnihorkuggfejcyzmsdgdxpaw +vtnihurkulbfgjcyzmsqrdxpaw +ptnihorkuabfejcyzmsqgqxpaw +vtrihoykulbfejcyzmsqgdxpam +otnihorkulbfejcyzmpqgdxpjw +vtyihorkulbfejdyznsqgdxpaw +vtnihornulbfrjcizmsqgdxpaw +vtnihfrlulbfejcyzmsqgdxpah +atnihorkulbfejcyossqgdxpaw +vtnihorkuljfejcyzysqgdxpow +vtniyorkulbfejcyzmsqgdxbaz +venihorkulbfejctzmqqgdxpaw +vtrihorkulbfejcyjmsqgdxpfw +venitorkulbfexcyzmsqgdxpaw +vtbihorkulbfejcyzmwqgdxpyw +vtnihorkuubfejxyzmsqgdxkaw +vtqihorkulbnejcyzmsqgdxnaw +vteihorkurbfejcyzmsqwdxpaw +vtgjhorkxlbfejcyzmsqgdxpaw +ytniworkulbfejcyzmsqgdxptw +vtnihorkulbfejcyzmsvgixhaw +dtnihorkusbfejcyzmsqidxpaw +vtnihurkulbfejcdzmkqgdxpaw +vtgihorkulbfejcyzhsqgdxpaf +vtniudrkulbfeacyzmsqgdxpaw +vtnihorkulbfejcyemsokdxpaw +vtnihorkulbfejcyjmwqgdxpag +vtnihorpulbfetcpzmsqgdxpaw +ctnzhorkulbfejcyzmfqgdxpaw +vanihorkuhbwejcyzmsqgdxpaw +vtnihonkurbfejcyzvsqgdxpaw +vtnihgrkulbcejcbzmsqgdxpaw +vtnihorkutbfeacyzmsqcdxpaw +vtniaorkuhbfqjcyzmsqgdxpaw +vtnihorkylbfozcyzmsqgdxpaw +vtnihorkulbfejcypmfqgdxpbw +vtrphonkulbfejcyzmsqgdxpaw +vtnihorkulbdejcywmsqydxpaw +vtnikorkulbfejvyzknqgdxpaw +vznihorkulbfejcyzmsqbdxpam +vtmghorkulbfejcyzmsqghxpaw +vtnihorkulbfejcyzmshglxpfw +vtiihorkulbfejcjzmsqgdxoaw +rtnihorkulbfejcuzmsqgdxpow +vtnthoikulbuejcyzmsqgdxpaw +vtniholkulbfcjcyzmsqgdxpvw +vdnihorkulbbejcyzmsqgdxdaw +ntnihorkulbfojcyzmsqgdxzaw +vtniqorkulbfejcyzklqgdxpaw +vtnihorkulhfejcpzmsqgdxprw +vhnihorkulqfejcyzmsqgdapaw +vtnihorkolafejcyzmsqadxpaw +vtnihorkulbpejcyzasqgtxpaw +vtnihgiyulbfejcyzmsqgdxpaw +dtnihorkulbffjcyzmsqgdfpaw +vtnvhorhulbfejcyzmpqgdxpaw +vtniholkulbfebcyzmsqgnxpaw +vunihorkulbbejcyznsqgdxpaw +vtnihorkulbfehcyomsqgaxpaw +vtnihorkllboejcyzmsigdxpaw +vtnihwrkulbfejcywmsqgdxiaw +vtnoherkulbfbjcyzmsqgdxpaw +vtnbhorkulbfejcyzmsqgkxpaa +vtnihorkilbfdjxyzmsqgdxpaw +vtnfhorkuvbfejcyzmsqgixpaw +vtnyhorkulbpejcyzmsqgdxjaw +vtnihomkalbfejcyzmqqgdxpaw +vtnihorkulbfejcybmsqgjxvaw +vtnihorkulbfgjcnzmsqbdxpaw +vtnihorkulbfejcyzmpqgsxpap +lmnihorkulbfejcizmsqgdxpaw +vtmahkrkulbfejcyzmsqgdxpaw +vtnihorkulbfujcyrcsqgdxpaw +vtnzhorkulbfejcyzjvqgdxpaw +vtnicorkulbfejmyzmsqgdxvaw +vtnyhojkulbfejcyzmsngdxpaw +vtnuhorkulbfejcyzlsqgdxpmw +vtnihorkulufejcgzmtqgdxpaw +vtnihfrkulbfejnyzmsigdxpaw +vtnzhorkulbdejnyzmsqgdxpaw +vttihorkulbfejcyzmyqgdxwaw +vknihorkulbfejnylmsqgdxpaw +vtnihorkulbfejcfrmsqgdxpaz +vtnchormulbfejcyzmsqgdopaw +vtnihorkulbfebcyzusqgdxpam +jtnihorwulbfejcyzksqgdxpaw +ctnihodkutbfejcyzmsqgdxpaw +vonihorkultfejcyzmsqgixpaw +vtnihorkulbqejcyzmsqgdypcw +vfnihorkulbfbjcyzmsqcdxpaw +utnihorkulbfejcyqmsqgdxraw +vtnihorkjllfejcyzmskgdxpaw +vtnihorkulbfejcyvisqgdapaw +vtnihorkclzfejcyzmsqvdxpaw +vtnihwrkvlffejcyzmsqgdxpaw +vtnihlrkulbfejcrzmsqydxpaw +vtnihorkulbfbjtysmsqgdxpaw +vtnihorkulbfxjcepmsqgdxpaw +ttnihorkulbfejpyzmsqgdxpaz +vtnwhorkolbfejcdzmsqgdxpaw +vtnihorkulbfejcyzdsqgdxppn +vtnwporkulbfercyzmsqgdxpaw +vtnshorxuvbfejcyzmsqgdxpaw +vtnihxrkulbfejcyomsqfdxpaw +vtnwhorkrljfejcyzmsqgdxpaw +vqnihorkulbfejcyzmtqgdxpuw +vtnnhorkulbfhrcyzmsqgdxpaw +vtuihwrkulbfedcyzmsqgdxpaw +vtgbhorkucbfejcyzmsqgdxpaw +vtnitorkulbfejcozmsqgdkpaw +otnihomkulbfejcyzmsqgdxhaw +vtnihgrkulbfrjcyzmsqxdxpaw +vtnihorkulbfujcyzmsqghxpzw +vsnihopkhlbfejcyzmsqgdxpaw +vtniherkulbfejcyzmpzgdxpaw +vtnxhorkulbfejcszmsqgdxcaw +vtnihorkulbfejctzmsxadxpaw +vtnihorkslbmejcyzmsqgnxpaw +vtnwhorgulbfegcyzmsqgdxpaw +vtnihorkulbfsjcyzmsqgdxiau +vtnihorkulbfejcyzmsqldxpbj +vtnghorkulbfmjcyzmsqgdxpaa +vtnihorkulbfetcyzmpqudxpaw +vtnbhorkulbfejcyzmsqgdupyw +ntnihorhulbfejwyzmsqgdxpaw +vjnihorkulbfejcyqosqgdxpaw +vtiihorbulbfejcbzmsqgdxpaw +vtnihorkulbfejxlzmpqgdxpaw +vtnihorkolbfejcyfmsqgdxraw +vtnihqrrulbfedcyzmsqgdxpaw +ctnihorkulbfejcyzmsqgdxpsy +vtnihorkulbfkjcezmspgdxpaw +ztnihorkulbmcjcyzmsqgdxpaw +vinihorkulbfedcyzmsqgdxpau diff --git a/src/02/part1 b/src/02/part1 new file mode 100644 index 0000000..43358f4 --- /dev/null +++ b/src/02/part1 @@ -0,0 +1,50 @@ +--- Day 2: Inventory Management System --- + +You stop falling through time, catch your breath, and check the screen on the device. "Destination +reached. Current Year: 1518. Current Location: North Pole Utility Closet 83N10." You made it! Now, +to find those anomalies. + +Outside the utility closet, you hear footsteps and a voice. "...I'm not sure either. But now that so +many people have chimneys, maybe he could sneak in that way?" Another voice responds, "Actually, +we've been working on a new kind of suit that would let him fit through tight spaces like that. But, +I heard that a few days ago, they lost the prototype fabric, the design plans, everything! Nobody on +the team can even seem to remember important details of the project!" + +"Wouldn't they have had enough fabric to fill several boxes in the warehouse? They'd be stored +together, so the box IDs should be similar. Too bad it would take forever to search the warehouse +for two similar box IDs..." They walk too far away to hear any more. + +Late at night, you sneak to the warehouse - who knows what kinds of paradoxes you could cause if you +were discovered - and use your fancy wrist device to quickly scan every box and produce a list of +the likely candidates (your puzzle input). + +To make sure you didn't miss any, you scan the likely candidate boxes again, counting the number +that have an ID containing exactly two of any letter and then separately counting those with +exactly three of any letter. You can multiply those two counts together to get a rudimentary +checksum and compare it to what your device predicts. + +For example, if you see the following box IDs: + + + - abcdef contains no letters that appear exactly two or three times. + + - bababc contains two a and three b, so it counts for both. + + - abbcde contains two b, but no letter appears exactly three times. + + - abcccd contains three c, but no letter appears exactly two times. + + - aabcdd contains two a and two d, but it only counts once. + + - abcdee contains two e. + + - ababab contains three a and three b, but it only counts once. + + +Of these box IDs, four of them contain a letter which appears exactly twice, and three of them +contain a letter which appears exactly three times. Multiplying these together produces a checksum +of 4 * 3 = 12. + +What is the checksum for your list of box IDs? + + diff --git a/src/02/part2 b/src/02/part2 new file mode 100644 index 0000000..cf1b625 --- /dev/null +++ b/src/02/part2 @@ -0,0 +1,41 @@ +--- Part Two --- + +"Good, the new computer seems to be working correctly! Keep it nearby during this mission - you'll +probably use it again. Real Intcode computers support many more features than your new one, but +we'll let you know what they are as you need them." + +"However, your current priority should be to complete your gravity assist around the Moon. For this +mission to succeed, we should settle on some terminology for the parts you've already built." + +Intcode programs are given as a list of integers; these values are used as the initial state for the +computer's memory. When you run an Intcode program, make sure to start by initializing memory to the +program's values. A position in memory is called an address (for example, the first value in memory +is at "address 0"). + +Opcodes (like 1, 2, or 99) mark the beginning of an instruction. The values used immediately after +an opcode, if any, are called the instruction's parameters. For example, in the instruction +1,2,3,4, 1 is the opcode; 2, 3, and 4 are the parameters. The instruction 99 contains only an opcode +and has no parameters. + +The address of the current instruction is called the instruction pointer; it starts at 0. After an +instruction finishes, the instruction pointer increases by the number of values in the +instruction; until you add more instructions to the computer, this is always 4 (1 opcode + 3 +parameters) for the add and multiply instructions. (The halt instruction would increase the +instruction pointer by 1, but it halts the program instead.) + +"With terminology out of the way, we're ready to proceed. To complete the gravity assist, you need +to determine what pair of inputs produces the output 19690720." + +The inputs should still be provided to the program by replacing the values at addresses 1 and 2, +just like before. In this program, the value placed in address 1 is called the noun, and the value +placed in address 2 is called the verb. Each of the two input values will be between 0 and 99, +inclusive. + +Once the program has halted, its output is available at address 0, also just like before. Each time +you try a pair of inputs, make sure you first reset the computer's memory to the values in the +program (your puzzle input) - in other words, don't reuse memory from a previous attempt. + +Find the input noun and verb that cause the program to produce the output 19690720. What is 100 * +noun + verb? (For example, if noun=12 and verb=2, the answer would be 1202.) + + diff --git a/src/02/solve.py b/src/02/solve.py new file mode 100644 index 0000000..6b3594f --- /dev/null +++ b/src/02/solve.py @@ -0,0 +1,40 @@ +import sys +sys.path.append("../common") +import aoc + +data = aoc.data.split("\n") + +def solve1(args): + doubles = 0 + triples = 0 + for s in data: + counts = list((0,) * 26) + for c in s: + counts[ord(c[0])-97] += 1 + if 2 in counts: + doubles += 1 + if 3 in counts: + triples += 1 + return doubles * triples + +def compare(s1, s2): + dif = 0 + same = list() + for i in range(len(s1)): + if s1[i] != s2[i]: + dif += 1 + else: + same.append(s1[i]) + return (dif, same) + +def solve2(args): + for i in range(len(data)): + for j in range(i, len(data)): + if i == j: + continue + res = compare(data[i], data[j]) + if res[0] == 1: + return "".join(res[1]) + + +aoc.run(solve1, solve2, sols=[3952, "vtnikorkulbfejvyznqgdxpaw"]) -- cgit v1.2.3-71-gd317