Skip to content

Latest commit

 

History

History
57 lines (51 loc) · 5.71 KB

README.md

File metadata and controls

57 lines (51 loc) · 5.71 KB

This repository contains solutions to various puzzles of the Advent of Code 2021. Puzzles are solved with various idioms and libraries from the Scala ecosystem.

Ammonite is used to run the code. It is available from many package managers (e.g. brew install ammonite-repl). When running a puzzle solution (e.g. amm day02.sc) dependencies will be downloaded automatically.

Custom runner is used to run the solution code with example and real inputs. Runner registers all of the assertions in the solution and prints out results table at the end:

┌───┬─────────────────────────────┬─────────────────────────────┬─────────────────────────────┐
│   │ Assertion                   │ Example value (expected)    │ Real value (expected)       │
├───┼─────────────────────────────┼─────────────────────────────┼─────────────────────────────┤
│ ✓ │ final position              │ 150 (150)                   │ 1383564 (1383564)           │
├───┼─────────────────────────────┼─────────────────────────────┼─────────────────────────────┤
│ ✓ │ hoz with aim                │ 15 (15)                     │ 1911 (1911)                 │
├───┼─────────────────────────────┼─────────────────────────────┼─────────────────────────────┤
│ ✓ │ depth with aim              │ 60 (60)                     │ 778813 (778813)             │
├───┼─────────────────────────────┼─────────────────────────────┼─────────────────────────────┤
│ ✓ │ position with aim           │ 900 (900)                   │ 1488311643 (1488311643)     │
└───┴─────────────────────────────┴─────────────────────────────┴─────────────────────────────┘

List of solutions and Scala idioms/libraries used:

Puzzle Idioms and libraries
Day 1 Ammonite Ops, Collections Sliding Window
Day 2 Match on interpolator
Day 3 Parsing text to integers
Day 4 Mutable vars
Day 5 zip
Day 6 Map.updatedWith
Day 7 Sum of consecutive numbers
Day 8 Set intersection
Day 9 foldLeft
Day 10 Extractor objects
Day 11 Unfold
Day 12
Day 13
Day 14