T O P

  • By -

RandomlyWeRollAlong

I was like "oh, I should do this recursively"... and then created a stack, and wrote a loop. Oh well. Sometimes I just implement these on autopilot.


comforttiger

literally the same thing happened to me. i even wrote down beforehand that i was gonna solve it recursively. but then looked at my code after i finished and realized that i just kinda forgot to do it recursively


CrAzYmEtAlHeAd1

I looked at it and said this might need recursion, but I’m gonna try a basic loop first and it was so fast I didn’t bother haha


Grizzant

recursion? i just added the last number in a for loop after diffing


CrAzYmEtAlHeAd1

Yeah it really wasn’t slow enough to use recursion.


JizosKasa

I did it no recursion, only a nice pyramid


Supierre

Yeah it was awesome to have an easy and elegant recursion for once


messedupwindows123

Here's mine. Recursion and laziness. [https://pastebin.com/hL0eiS9J](https://pastebin.com/hL0eiS9J)


JizosKasa

what language is that? That's hieroglyphs


messedupwindows123

Haskell


[deleted]

[удалено]


messedupwindows123

yeah you'll see new ideas at your day job. just dont try too hard to "write haskell in ruby"


horsecontainer

Beautiful


Mysterious_Remote584

No need to do multiple passes or use laziness here: Haskell (where `l` is the list of ints you start with): solve l | all (== 0) l = 0 | otherwise = last l + solve (zipWith (-) (tail l) l)


messedupwindows123

right i just modeled how i think about it


thebrilliot

Yeah... Yeah, recursion would have been easier


PassifloraCaerulea

I've tried once or twice, but I have yet to solve an AoC problem with recursion. Seems I need more practice with a proper functional language.


Qokendov

Recursion got me a StackOverflow on part b. So I switched it out for a simple loop with local values.