Advent of Code - Day 4 & 5
I forgot to make a post after Day 4, but I solved it after a few headaches. Day 5 is, as of this posting, half way complete. I got a late start and forced myself to stop at 12:30am to go to sleep since I have work today. I am confident I can complete it after work before starting Day 6. I may try to make tonight a "as fast as I can" finish just to see how I do. Which means starting at 9pm on the dot and going at it. I have no illusions I will remain out of the top 100, but I am hoping to get in the first 2,500 to finish it.
We'll see. If not tonight, I am determined for one of these days to try and do it "competitively.
Advent of Code - Day 3: Mull It Over
- Part 1 - 1 submission
- Part 2 - 4 submissions
Part 1 was very straight forward with regex as the key to solving it. Part 2 took me a bit longer. I had watched a video of another coder solving a previous day's challenge and they dutifully coded and tested the examples in each day's problem. Something I usually skipped over. Today I was determined to hold to them. It served me well on the first part, but the 2nd part contains an element of it which the test data doesn't catch for you and it took me a while to fix it.
I ended up using part of the solution from another poster's code. I had a non-regex concept for how to do it, but they showed me how to integrate it as part of the regex. However, the pitfall caught me still.
The core issue is that the "state" of whether to process the inputs carries over across lines of text from the input. This isn't something the test data covers (though the problem makes plain how it should work.) So even though my testing implementation worked, it fell down on the larger dataset.
I figured it out though.
Advent of Code - Day 2: Red-Nosed Reports
- Part 1 - 2 submissions
- Part 2 - 3 submissions
Took me a little bit longer on this one. First wrong submission for part 1 was because I forgot the rules regarding the difference allowed between numbers in the series. Then I had to do a fair bit of bug fixing before landing on the correct second guess. Part 2 is, I am sure, an inelegant solution where I brute forced the failing lines. I am certain there is a more elegant solution for it. But, in the end, I got both answers.
Advent of Code - Day 1: Historian Hysteria
I opted to use PHP as it is what I know best, and I knew the functions it had would be well suited to this problem suite.
My notes after completing today's challenge:
- Part 1 - 1 correct submission
- Part 2 - 1 incorrect, then 1 correct submission
Nailed the first part on the first run. The second one had two issues which I had to correct after 1 incorrect submission. First, I only skimmed the directions (shame on me) and I assumed that they wanted me to only compare unique numbers in the left column. Second was a bug on my part of not trimming off the new line when reading in from the text file.
Advent of Code - Day 7
Remember when I was waiting for a day where I felt really challenged? Well, I'm a few days behind and Day 7 did it.
I was able to get, I'd say 80% of the way there for getting an answer to Day 7's first challenge. I am confident I would have eventually figured out what was going on with my code and gotten to the solution, but it was taking a while and I realized that I didn't need to keep banging my head against the wall. Rather than blindly bumble into the correct eventual solution, I decided to stop and see how it was done by others. YouTuber 'thibpat,' a French programmer and casual YouTuber, had a video showing how he approached solving it.
Also, I have realized over the course of these days of coding, that I need to better understand Regular Expressions. They are an example where I have a very base level of understanding and rely heavily on googling up a solution when I need them. I would like to just understand them. So I'm going to work on that.
I asked on Mastodon and @shiftingedges recommended recommended Execute Program's free course on it. So I'm going to check that out in the coming weeks.
Advent of Code - Day 4 complete!
Just wrapped up Day 4 of the AoC event. This one began to stretch my mental muscles more as I figured out what was needed.
I only submitted one wrong answer, and that was due to a quirk of Javascript where I realized it was possibly parsing numbers as strings and thus making faulty comparisons. For the second puzzle, it took me a little bit to figure out what was needed, but my second submission was right the first time.
Today is also the first day I am going to seek out other solutions in Javascript and see if there were more optimized ways of writing the code, not that mine was long, but I feel like it was pretty optimized and am curious where I could do it better.
Advent of Code - Day 1
Hammered out the answers to today's Advent of Code.
I decided to work in Javascript as I felt it would be a bigger challenge and more rewarding exercise than to do it in PHP; and honestly I didn't feel like doing it in Python. I might do it in Python after work if I have time.
