.-----. .------------------.
.--'~ ~ ~| .-' * \ / '-. 1 **
.--'~ ,* ~ | | >o< \_\_\|_/__/ | 2 **
.---': ~ '(~), ~| | >@>O< o-_/.()__------| 3 **
|@..#'. ~ " ' ~ | |>O>o<@< \____ .'| 4 **
| | | .. | 5
| | | .' '. | 6
| | | | | | 7
| .--. | | | | | 8
'---' | | | | | | 9
| | | | | | 10
| | | | | | 11
| | | | | | 12
| | | | | | 13
| | | | | | 14
| | | | | | 15
| | | | | | 16
| | | | | | 17
| | | | | | 18
| | | | | | 19
| | | '. .' | 20
.------' '------. | '' | 21
| | | | 22
| | | | 23
| | | | 24
| | '-. .-' 25
'----------------------' '------------------'
Nushell was placed on my radar in early 2023. My gut reaction was 'I hate powershell'. With some persistance from friends, the idea of Nushell was starting to take root. In the fall, it was time to put pen to paper and satiate my curiousity. Advent of Code 2023 (source) was the testing ground. I learned a lot about Nushell and started using it day-to-day for scripting. The built-in testing framework was sunsetted at some point in 2024. That was a problem so I built nuUnit (source).
This year when Advent of Code 2024 came around, I evaluated several other languages. In a proper familiar language, maybe I could complete all 25 days... It also could be a great chance to learn Clojure or Go... Practicing Lua or Python would be fun... But it was hard to resist battle testing nuUnit and pushing Nushell to it's limits. So I buckled in for another rocky ride exploring what Nushel is capable of.
cargo install nushell # https://github.com/nushell/nushell
cargo install aoc-cli # https://github.com/scarvalhojr/aoc-cli
vim ~/.adventofcode.session # https://github.com/scarvalhojr/aoc-cli?tab=readme-ov-file#session-cookie
nu -c 'use toolkit.nu; toolkit pull puzzle'
Download the puzzle input and description
Usage:
> pull puzzle <day>
Flags:
-h, --help: Display the help message for this command
Parameters:
day <int>
Input/output types:
╭───┬───────┬────────╮
│ # │ input │ output │
├───┼───────┼────────┤
│ 0 │ any │ any │
╰───┴───────┴────────╯
nu -c 'use toolkit.nu; toolkit run puzzle'
Run a puzzle solver
Usage:
> run puzzle <day>
Flags:
-h, --help: Display the help message for this command
Parameters:
day <int>
Input/output types:
╭───┬───────┬────────╮
│ # │ input │ output │
├───┼───────┼────────┤
│ 0 │ any │ any │
╰───┴───────┴────────╯
nu -c 'use toolkit.nu; toolkit submit answer'
Submit an answer to a puzzle
Usage:
> submit answer <day>
Flags:
-h, --help: Display the help message for this command
Parameters:
day <int>
Input/output types:
╭───┬───────┬────────╮
│ # │ input │ output │
├───┼───────┼────────┤
│ 0 │ any │ any │
╰───┴───────┴────────╯
nu -c 'use toolkit.nu; toolkit update readme'
Recalculate the README
Usage:
> update readme
Flags:
-h, --help: Display the help message for this command
Input/output types:
╭───┬───────┬────────╮
│ # │ input │ output │
├───┼───────┼────────┤
│ 0 │ any │ any │
╰───┴───────┴────────╯
- On day 2, when piping into an
if
, could not call a defined function in theelse
clause. The error was something likevariable not defined
but the stacktrace was a couple functions higher than theelse
clause - nuUnit importing tests from a separate file doesn't work
open ~/tilde/path/from/home
doesn't work directly any more,path expand
is necessary first- Opening relative paths (eg:
day-04-ceres-search/input
) is nuUnit tests is painful- Same with importing modules, it is difficult to know what kind of relative path to use (eg: working directory, calling file's directory)
- A package manager of some sort is sorely needed. Being able to easily distribute and reuse code would be really helpful