# Advent of Code 2021

**URL:** <https://discuss.ocaml.org/t/advent-of-code-2021/8945>\
**Category:** Community\
**Tags:** fun\
**Created:** [December 5, 2021, 3:12am UTC](https://discuss.ocaml.org/t/advent-of-code-2021/8945 "2021-12-05T03:12:24Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![shonfeder](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/shonfeder/32/424_2.png) [@shonfeder](https://discuss.ocaml.org/u/shonfeder)\
**Post date:** [December 5, 2021, 3:12am UTC](https://discuss.ocaml.org/t/advent-of-code-2021/8945/1 "2021-12-05T03:12:24Z")

</div>

For any other OCamlers having a go at [Advent of Code](https://adventofcode.com/) this year, I thought I’d create this thread for discussing/sharing/comparing.

I doubt I’ll see it all the way through myself, but will keep at it until I run out of steam 🙂

If anyone would like to form an ocamlcentric leaderboard, all may feel free to use my private leaderboard, by entering code `221063-e41acad3` at [Leaderboard - Advent of Code 2021](https://adventofcode.com/2021/leaderboard/private) (after logging in). I’d also be happy to join a different leaderboard if there’s already one fit for this purpose 🙂

(Discussion from a few years back is here: [Advent of Code starts today](https://discuss.ocaml.org/t/advent-of-code-starts-today/1223))

---

<div class="post-metadata">

**Author:** ![nated](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nated/32/6354_2.png) [@nated](https://discuss.ocaml.org/u/nated)\
**Post date:** [December 5, 2021, 2:57pm UTC](https://discuss.ocaml.org/t/advent-of-code-2021/8945/2 "2021-12-05T14:57:03Z")

</div>

I’ve already fallen a bit behind, so I’m not sure how long I’ll keep at it either, but I’ll join! [Here are my solutions so far.](https://git.sr.ht/~nated/aoc2021/tree)

For Day 3 I also decided to try to see how close I could get to the top 100, so I did my first solution in the browser console and got it in about 6 minutes, which got me about 1000th place I think, so I gave up on that idea 😅

---

<div class="post-metadata">

**Author:** ![perry](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/perry/32/518_2.png) [@perry](https://discuss.ocaml.org/u/perry)\
**Post date:** [December 5, 2021, 4:57pm UTC](https://discuss.ocaml.org/t/advent-of-code-2021/8945/3 "2021-12-05T16:57:32Z")

</div>

This year I’m using Rust and not OCaml (I know OCaml too well, and I treat AoC as an opportunity to learn new things).

---

<div class="post-metadata">

**Author:** ![shonfeder](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/shonfeder/32/424_2.png) [@shonfeder](https://discuss.ocaml.org/u/shonfeder)\
**Post date:** [December 5, 2021, 5:47pm UTC](https://discuss.ocaml.org/t/advent-of-code-2021/8945/4 "2021-12-05T17:47:31Z")

</div>

I had been referring to your old leaderboard, from your post in 2017, as a motivator, but decided to create this thread after I got booted from it 😜 I hope your Rusting in going swell! 🦀

Last year I tried to do the solutions in Lambda Prolog, with the aim of learning new things. I did learn a lot, but I also found that I am generally so slow at solving the puzzles that the added challenge of a new (research-grade) language made it impossible for me to keep up. The main thing I aim to learn this year is how to dispatch the puzzles more quickly! So my ambition is to solve the puzzles in little enough time that I can sustain engagement throughout the whole calendar. We’ll see how that goes 🐪

---

<div class="post-metadata">

**Author:** ![shonfeder](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/shonfeder/32/424_2.png) [@shonfeder](https://discuss.ocaml.org/u/shonfeder)\
**Post date:** [December 5, 2021, 6:19pm UTC](https://discuss.ocaml.org/t/advent-of-code-2021/8945/5 "2021-12-05T18:19:44Z")

</div>

Congrats on making it into the top 1000th! 🎉 Even if my bedtime weren’t well before midnight EST, I still don’t think I’d have a prayer of solving a puzzle quickly enough for that 🙂 I’ve enjoyed looking over your solutions, thank you for sharing!

My solutions are going into [GitHub - shonfeder/aoc2021: AOC 2021 in OCaml 🐫](https://github.com/shonfeder/aoc2021) . I’m currently trying to focus on improving my ability to _focus_ and avoid getting lost down rabbit holes or caught up in trivial mistakes that slowdown my time to solution. To that end, I’ve started keeping [some notes](https://github.com/shonfeder/aoc2021/blob/trunk/notes.org) to reflect on the mistakes I’m making.

---

<div class="post-metadata">

**Author:** ![perry](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/perry/32/518_2.png) [@perry](https://discuss.ocaml.org/u/perry)\
**Post date:** [December 5, 2021, 7:53pm UTC](https://discuss.ocaml.org/t/advent-of-code-2021/8945/6 "2021-12-05T19:53:54Z")

</div>

There are people doing speed runs who finished both parts of day 1 in under 90 seconds. I think one’s best policy, unless one is determined to set up specifically to do speed runs, is to accept that one is not going to be high on the leaderboard. 🙂

---

<div class="post-metadata">

**Author:** ![perry](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/perry/32/518_2.png) [@perry](https://discuss.ocaml.org/u/perry)\
**Post date:** [December 5, 2021, 7:54pm UTC](https://discuss.ocaml.org/t/advent-of-code-2021/8945/7 "2021-12-05T19:54:36Z")

</div>

I was cleaning it out to have a new set of people using it this year. I didn’t realize anyone from 2017 was still using it. 🙂

---

<div class="post-metadata">

**Author:** ![cdaringe](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/cdaringe/32/2419_2.png) [@cdaringe](https://discuss.ocaml.org/u/cdaringe)\
**Post date:** [December 11, 2021, 7:26am UTC](https://discuss.ocaml.org/t/advent-of-code-2021/8945/8 "2021-12-11T07:26:15Z")

</div>

I don’t work in OCaml day to day (booooo), so every time [I punch in a nice pure `|>` pipeline](https://github.com/cdaringe/aoc-2021/blob/main/day5/lib/day5.ml#L64-L68) for a solution, I still get that sweet, sweet FP rush

---

<div class="post-metadata">

**Author:** ![shonfeder](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/shonfeder/32/424_2.png) [@shonfeder](https://discuss.ocaml.org/u/shonfeder)\
**Post date:** [December 11, 2021, 3:11pm UTC](https://discuss.ocaml.org/t/advent-of-code-2021/8945/9 "2021-12-11T15:11:19Z")

</div>

One of the learnings I’m hoping to glean from this year’s puzzles is to improve my ability to analyze, “formalize”, and implement specifications. So I’m spending some time each day refining the puzzle descriptions into more systematic specifications. Today I noticed an inconsistency in the puzzle description 🙂

> The energy level of each octopus is a value between `0` and `9` .  
> …  
> any octopus with an energy level greater than `9` _flashes_

If the first line holds, then no octopus could flash! 💥 🐙💡

---

<div class="post-metadata">

**Author:** ![perry](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/perry/32/518_2.png) [@perry](https://discuss.ocaml.org/u/perry)\
**Post date:** [December 27, 2021, 11:20pm UTC](https://discuss.ocaml.org/t/advent-of-code-2021/8945/10 "2021-12-27T23:20:59Z")

</div>

So it’s over! Looks like two of us finished!

---

<div class="post-metadata">

**Author:** ![dangdennis](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dangdennis/32/2594_2.png) [@dangdennis](https://discuss.ocaml.org/u/dangdennis)\
**Post date:** [December 5, 2022, 6:56am UTC](https://discuss.ocaml.org/t/advent-of-code-2021/8945/11 "2022-12-05T06:56:18Z")

</div>

Anyone else doing AoC 2022?

> **[advent-of-code/2022/ocaml/bin at main · dangdennis/advent-of-code](https://github.com/dangdennis/advent-of-code/tree/main/2022/ocaml/bin)**
>
> main/2022/ocaml/bin

I’m on day 4.

---

<div class="post-metadata">

**Author:** ![dangdennis](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dangdennis/32/2594_2.png) [@dangdennis](https://discuss.ocaml.org/u/dangdennis)\
**Post date:** [December 5, 2022, 4:33pm UTC](https://discuss.ocaml.org/t/advent-of-code-2021/8945/13 "2022-12-05T16:33:28Z")

</div>

I just used Base’s List.chunk func. So helpful.

---

<div class="post-metadata">

**Author:** ![yawaramin](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/yawaramin/32/3384_2.png) [@yawaramin](https://discuss.ocaml.org/u/yawaramin)\
**Post date:** [December 5, 2022, 10:44pm UTC](https://discuss.ocaml.org/t/advent-of-code-2021/8945/14 "2022-12-05T22:44:05Z")

</div>

I’ve done a couple using Eio, the `Eio.Path.with_lines` function has been super useful. Might find some use for its built-in parser combinator too in coming days.

---

<div class="post-metadata">

**Author:** ![dangdennis](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dangdennis/32/2594_2.png) [@dangdennis](https://discuss.ocaml.org/u/dangdennis)\
**Post date:** [December 6, 2022, 4:17am UTC](https://discuss.ocaml.org/t/advent-of-code-2021/8945/15 "2022-12-06T04:17:06Z")

</div>

That’s helpful. I had tried to pretend I was dealing with a large file and use streams, but I gave that up quickly. 😆
