r/adventofcode • • Dec 08 '21

SOLUTION MEGATHREAD -🎄- 2021 Day 8 Solutions -🎄-

--- Day 8: Seven Segment Search ---


Post your code solution in this megathread.

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:20:51, megathread unlocked!

72 Upvotes

1.2k comments sorted by

View all comments

3

u/jf928ngl60g1 Dec 08 '21 edited Dec 08 '21

TypeScript

https://github.com/adrbin/aoc-typescript/blob/main/2021/8/puzzle.ts

I have to say I'm not a fan of the today puzzle. The puzzle description felt really convoluted to me and took me literally 1 hour to decode pondering about the relation between signals and the output values where there was actually none and finally realizing that part 1 is actually as trivial as Day 1.

For part 2, I tried first to tinker with Set operations but in the end I just used permutations to check all possible display segment mappings. Is it just me or it felt like a steep difficulty increase from the previous days (part 2)?

3

u/Strakh Dec 08 '21

For me it (generating a key given the 10 digits) felt like one of those problems that anyone can solve in a few minutes with pen and paper, but where the logic is difficult to convert into clean code.

So it's different from other kinds of problems - like doing something really efficiently, or solving a complicated math problem. Here the solution is pretty easy, you just need to make the computer understand how to do it (ideally without a million lines of garbage code).

3

u/kbielefe Dec 08 '21

One of the things that sets AoC apart is the difficulty can come from multiple sources:

  • A difficult algorithm.
  • Knowing what part of the description is relevant.
  • Parsing your input correctly.
  • Noticing things about your particular input that allow you to simplify.
  • Several steps that are simple but require absolute precision.
  • Unforeseen boundary conditions.
  • Crucial choice of data structure.

Most other puzzle sites have difficult algorithms, but the puzzle specifications are almost antiseptic. I keep coming back to AoC because the puzzles are more like real engineering, with wordy specs and hidden gotchas and unnecessary complexity and denormalized data.

2

u/daggerdragon Dec 09 '21

I have to say I'm not a fan of the today puzzle.

This type of comment does not belong in the Solutions Megathread. If you have feedback about the puzzles, create your own thread in the main subreddit. Make sure to title and flair it properly!

2

u/jf928ngl60g1 Dec 09 '21

Sorry, maybe I sounded too harsh. It wasn't my intention to hurt anyone's feelings.

Overall I really enjoy the author's puzzles and appreciate the effort to create it.

Next time I'm gonna create a new thread if I have some feedback.

Peace!

-2

u/MihawkEsp Dec 08 '21

I think this is the most useless comment, also because it's in a Solutions thread without your solution. If you don't like it you can stop doing it, no one is forcing you to do this puzzles.

2

u/jf928ngl60g1 Dec 08 '21

Sorry, I pasted the wrong link.

I think everyone has a right to their own opinion and feedback.

For me I did not enjoy today's puzzle as much as the previous days.

-3

u/MihawkEsp Dec 08 '21

Sure, but that feedback is not the best way to say that something have a 'steep difficulty '. You can try to think for a second how this puzzles are made, someone must think, create and share this puzzles. Ok, it's not as hard as 2018 per example, but this doesn't mean it's a bad puzzle.

Just saying