There are lots of CLI tools for doing Advent of Code in Ruby. Why make another?
This one does a few things differently:
- It shows other people's solutions. This was inspired by Exercism's community solutions.
- It's geared toward leisurely solving puzzles across all years. You can use it for the competition in December, but I didn't build it with that in mind.
- It has a magically simple CLI, which mostly involves spamming the
arbcommand. - It uses Git instead of a database to track the user's progress and current state.
gem install advent_of_ruby
In a directory where you want to store your solutions, run the command arb and follow the prompts.
advent-of-ruby-cli-demo.mp4
Here's what it looks like to peruse other people's solutions. Solutions from Reddit and a few GitHub repos are gathered together in a Markdown file, which in this example is viewed in VS Code's Markdown preview.
Shortcuts:
- Any command can be abbreviated with its first letter, e.g.
arb bforarb bootstrap. - Just
arbis short forarb run. arb helpshows a summary of each command.
- Downloads the input and instructions files for the given day.
- Creates a solution file and a spec file for the given day.
- If the current directory contains
.rubocop.ymlor a Gemfile specifyingrubocop, then the new solution and spec files are auto-formatted using RuboCop.
- If the current directory contains
- Creates two files (one for each puzzle part) with other people's solutions from /r/adventofcode and these repos:
- https://github.com/ahorner/advent-of-code
- https://github.com/eregon/adventofcode
- https://github.com/erikw/advent-of-code-solutions
- https://github.com/gchan/advent-of-code-ruby
- https://github.com/ZogStriP/adventofcode
- If both arguments are omitted, it bootstraps the next puzzle, i.e. the puzzle after the one that was last committed to Git.
- If only the day argument is omitted, it bootstraps the next puzzle of the given year.
- Opens all of the new files using
editor_commandinconfig.yml.
- Runs specs for the given day.
- If specs pass, also runs the currently in-progress part (Part One or Part Two) of the given day.
- If you're seeing specs run when you want to run only the real input, or vice versa, add one of the following flags:
--spec(-s) runs only the specs. (To run only Part One or Part Two specs, in the spec file changeittoxiton the other part's example to skip it.)--one(-o) runs only Part One with the real input.--two(-t) runs only Part Two with the real input.
- Optionally submits the answer, via a prompt that appears if specs pass and the answer has not already been submitted.
- If both arguments are omitted, it runs the puzzle that is untracked in Git, if any.
- Commits new or modified solutions to Git.
- Shows progress (total and by year) based on the number of your solutions committed in Git.
- AoC-rb—this gem was originally based on it
- AocRb
- aoc-cli
- aocli
- advent_of_code_cli
- advent_of_code_generator
- advent-rb
