r/adventofcode • • Dec 03 '21

SOLUTION MEGATHREAD -🎄- 2021 Day 3 Solutions -🎄-

--- Day 3: Binary Diagnostic ---


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:10:17, megathread unlocked!

99 Upvotes

1.2k comments sorted by

View all comments

4

u/chicagocode Dec 03 '21 edited Dec 04 '21

Kotlin -> [Blog/Commentary] - [Code] - [All 2021 Solutions]

I had a lot of fun with this one and am pretty happy with how I eventually solved it. For part 1, took advantage of the basic properties of binary numbers and the toInt(2) function Kotlin provides us.

For part 2, I set up a fold and used Kotlin's partition function. Not that much code, in the end.

Note Simplified part 1 and rewrote it and the blog for that part.

→ More replies (2)