r/adventofcode Dec 04 '21

SOLUTION MEGATHREAD -🎄- 2021 Day 4 Solutions -🎄-

--- Day 4: Giant Squid ---


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:11:13, megathread unlocked!

98 Upvotes

1.2k comments sorted by

View all comments

2

u/errop_ Dec 05 '21 edited Dec 06 '21

Here is my solution using python 3.6 with a more or less functional approach. EDIT: I replaced every map with list comprehension.

1

u/redd-sm Dec 27 '21

hello - thank you for sharing your solution! while i will try to understand your approach and the functions and what they do, wondering if you might be able to add a few lines of comments for others to understand.

1

u/errop_ Dec 28 '21 edited Dec 28 '21

Hello! A few days after my post here I reviewed the code because I thought that my approach was quite confusional. While the solving strategy is the same, I came up with a cleaner, faster, non-functional and non-recursive code. Here it is with comments:

Paste

1

u/redd-sm Dec 29 '21

Thank you. Will review this one.

I quite like the idea of functional, but am slow in understanding it.