Think i’m misunderstanding a rule from today… :thr...
# advent-of-code
c
Think i’m misunderstanding a rule from today… 🧵
Copy code
- Compare [2,3,4] vs 4
    - Mixed types; convert right to [4] and retry comparison
    - Compare [2,3,4] vs [4]
      - Compare 2 vs 4
        - Left side is smaller, so inputs are in the right order
But [2, 3, 4] runs out of elements first.
Copy code
If the left list runs out of items first, the inputs are in the right order.
I get that at this point i’ve converted the literal 4 to a list. But it’s worded in such a way we are now supposed to compare them as a list.
e
in dictionary order, does "bcd" or "d" come first?
doesn't matter that [2,3,4] is shorter than [4] if the beginning of it has smaller values
c
But the list comparison rule explicitly states that you compare value by value and if the right list is shorter it fails
e
you compare value by value, and the very first index is less. so you never get to the second rule about which one is shorter
c
Ohhhhhhhhhhhhhhhhhhhh
So
Copy code
== Pair 1 ==
- Compare [1,1,3,1,1] vs [1,1,5,1,1]
  - Compare 1 vs 1
  - Compare 1 vs 1
  - Compare 3 vs 5
    - Left side is smaller, so inputs are in the right order
If left was [1, 1, 3, 1, 5] it would still pass because 3 caused it to?
e
yes
d
The "some list runs out of indexes" comparison is only done if everything up the last index of the shortest list is equal
e
btw, this is called lexicographic order, alphabetical order, or dictionary order. does "car" come before "card"? yes, because it's shorter. does "card" come before "bar"? no, even though it's longer, because of its letters