I was certain that C would really help me with the bit fiddly puzzles, but yesterday kicked my booty and left me slapping together something ugly b...
For further actions, you may consider blocking this person and/or reporting abuse
I did a basic dynamic programming solution
Didn't really find this one interesting. Apparently it's a known series.
Either way, Ruby it was:
Here's part 1 JS, part 2 is a big performance issue. EDIT: I tried using
new Map()
for a more efficient process but I still ran into the call stack size error. I guess Javascript and heavy processing don't fit together :(You can use a map to store the numbers you've seen. Map lookup is O(1), compared to looking through a list (O(n)). The keys can be the numbers you've seen, the values the list of positions.
Thank you for the suggestion! I'll try it!
Technically simple but designed to catch out the users of, ahem, more academic languages! Rust should offer good performance of course. Optimised build runs both parts in about 5 seconds.
Ruby solution. Same thing for Part 1 and 2.
My Haskell solution for today was quite short, but performance was shit.
It's in Python, and it's not pretty, but I'm busy and it works and keeps me on track, so I'm counting that as a win. Just got to get through this week of finals and then I'll have more time :) Part two takes a while, but not like a "get up and get some coffee" while, so I'll take it.
COBOL as usual
Here is my Haskell solution, please don't ask about performance for that big number :-)
My JavaScript walkthrough:
Video: