• drudoo@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    11 months ago

    I’m not proud but after 3 hours in part 2 I had to look up help. I was trying to do it using recursion and it was not working at all.

    Even after watching a couple of videos and reading code I’m not sure why part 2 works as it does 😭

    I don’t normally code so this is like my yearly training 😂

    • hal9001@lemmy.worldOP
      link
      fedilink
      arrow-up
      1
      ·
      11 months ago

      Recursion probably made things a little trickier for you (but is totally possible). The special piece to notice in part 2 is that you are only forward creating cards and (most importantly) there are no decisions to optimize. Each card alway produces the same result.

      This problem reminded me of the lantern fish problem. The trick with this one was not tracking individual fish, instead you only need the number of each generation you have (and in today’s puzzle we just need to track how many of each card you have)