r/adventofcode • • Dec 10 '20

SOLUTION MEGATHREAD -🎄- 2020 Day 10 Solutions -🎄-

Advent of Code 2020: Gettin' Crafty With It

  • 12 days remaining until the submission deadline on December 22 at 23:59 EST
  • Full details and rules are in the Submissions Megathread

--- Day 10: Adapter Array ---


Post your solution in this megathread. Include what language(s) your solution uses! If you need a refresher, the full posting rules are detailed in the wiki under How Do The Daily Megathreads Work?.

Reminder: Top-level posts in Solution Megathreads are for code solutions only. If you have questions, please post your own thread and make sure to flair it with Help.


This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.

EDIT: Global leaderboard gold cap reached at 00:08:42, megathread unlocked!

69 Upvotes

1.1k comments sorted by

View all comments

2

u/gamepopper Dec 10 '20 edited Dec 12 '20

C++

Unless someone can point out what I'm doing wrong for the second part, I think I'm gonna have to count myself out for today.

Originally tried a recursive approach, but it took forever on the example with 31 numbers, so no chance with the puzzle input. After looking around I noticed a memoization approach, so I thought I'd use that, but with the exception of the first example set, all the results were lower. I'm not sure what was wrong.

I was originally going to throw in the towel until I had one more look and discovered that I needed to include both 0 and the largest number to the list for it to calculate correctly.

https://pastebin.com/KMJbTM9N

2

u/raevnos Dec 10 '20

1

u/gamepopper Dec 11 '20

Thanks, although I have already provided my solution that works.

1

u/daggerdragon Dec 10 '20 edited Dec 12 '20

Top-level posts in Solution Megathreads are for code solutions only.

This is a top-level post, so please edit your post and share your code/repo/solution or, if you haven't finished the puzzle yet, you can always create your own thread and make sure to flair it with Help.

Nope, all good!

2

u/gamepopper Dec 11 '20

Have people actually read my comment? I've provided my solution to both parts, I only explained how I was stuck on the second part, but I figured out what I did wrong.

2

u/daggerdragon Dec 11 '20

Ah, that part wasn't clear at first glance (first skim, rather). It sounded like you were frustrated with code that didn't work:

I'm not sure what's wrong.

That statement is in present tense, hence my copypasta. If your currently-posted code does work properly and you know why it didn't work, that's great, I retract the copypasta. However, if you still don't know what's wrong, I would still encourage you to post a Help thread with that code and get an actual answer on that.

2

u/gamepopper Dec 12 '20

Ah, I see how that can be confusing, I've updated it to be clearer that it was in the past tense.

1

u/daggerdragon Dec 12 '20

Copypasta has been retracted :)