Is Java worth learning in 2021?
-๐- 2022 Day 7 Solutions -๐-
-๐- 2022 Day 5 Solutions -๐-
Python. Part 1, Part 2
Time to break out the regular expressions (for input parsing). This is also where I learned that if you're reading line by line with fileinput, you can't stop and resume processing in a second loop. It's all gotta be done in a single for loop. So, I turned what would've been two simple loops into one loop with a state variable, which calls one of two different functions depending on which state we're in.
Crate stacks are stored as lists. So, it's a list slicing day.
In part 1 I initially had the wrong answer because I thought we were grabbing all the crates at once and preserving that list. Turns out I had to reverse the list first. And then for part 2, don't reverse it. (My initial solution for part 1 would've been right for part 2.) So once again, part 2 is simpler than part 1.
Also learned that you can't have a variable named "from" in Python.
More on reddit.com