Advent of Code 2023 day 5
12/05/2024, 5:00 AMCharles Flynn
12/05/2024, 2:13 PM47 -> [53, 13, 61, 29]
97 -> [13, 61, 47, 29, 53, 75]
etc
To then get the number order my algorithm is as follows:
• Identify the key which doesn't appear in any of the lists. One value has to be the smallest and therefore won't appear in any list as bigger than something else.
• Append to my ordered list
• Remove that entry from the map
• If on the last map entry add that last value to the end as its the biggest
• Repeat if map not empty
This works for the sample, but on the real input it falls over on the very first step. I can't see a problem with my parsing so wondering if i've misunderstood the data a bit. Any pointers welcome 🙂Jonathan Kolberg
12/05/2024, 5:37 PMCharles Flynn
12/05/2024, 5:42 PMJonathan Kolberg
12/05/2024, 5:43 PMCharles Flynn
12/05/2024, 5:44 PMCharles Flynn
12/05/2024, 5:46 PMCharles Flynn
12/05/2024, 6:36 PMKeys: [29, 47, 53, 61, 75, 97]
Vals: [13, 29, 47, 53, 61, 75]
Keys is values that appears on the left side of a pipe. Vals on the right.
In the sample data 13 doesn't appear as a key which means nothing is larger than it so it's the highest by order. Conversely 97 doesn't appear on the right side so it isn't bigger than anything, so it's the smallest by order.
(The ordering of the output here is just to aid in viewing the data)
For my real data I get the following identical lists:
Keys: [15, 16, 18, 19, 21, 23, 26, 27, 28, 29, 31, 34, 35, 39, 43, 45, 47, 48, 49, 51, 53, 56, 57, 59, 62, 63, 64, 65, 66, 67, 68, 69, 73, 75, 76, 78, 79, 81, 82, 83, 84, 85, 86, 87, 88, 89, 92, 94, 95]
Vals: [15, 16, 18, 19, 21, 23, 26, 27, 28, 29, 31, 34, 35, 39, 43, 45, 47, 48, 49, 51, 53, 56, 57, 59, 62, 63, 64, 65, 66, 67, 68, 69, 73, 75, 76, 78, 79, 81, 82, 83, 84, 85, 86, 87, 88, 89, 92, 94, 95]
Which either implies I'm doing something wrong or the orderings are circular somehow in a way that the sample data isn't.Charles Flynn
12/05/2024, 6:43 PM[97, 75, 47, 61, 53, 29, 13]
Which I believe to be correct. I'm assuming this is possible for the real input but now I'm questioning whether it is or not.