Advent of Ruby
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
arb
command. - It uses Git instead of a database to track the user's progress and current state.
Installation
gem install advent_of_ruby
Usage
In a directory where you want to store your solutions, run the command arb
and follow the prompts.
Demo
Other solutions
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.
Commands
Shortcuts:
- Any command can be abbreviated with its first letter, e.g.
arb b
forarb bootstrap
. - Just
arb
is short forarb run
. -
arb help
shows a summary of each command.
arb bootstrap [YEAR] [DAY]
- Downloads the input and instructions files for the given day.
- Creates a solution file and a spec file for the given day.
- Creates two files (one for each puzzle part) with other people's solutions from /r/adventofcode and these repos:
- 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_command
inconfig.yml
.
arb run [YEAR] [DAY]
- 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 changeit
toxit
on 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.
arb commit
- Commits new or modified solutions to Git.
arb progress
- Shows progress (total and by year) based on the number of your solutions committed in Git.
Prior art
- AoC-rb—this gem was originally based on it
- AocRb
- aoc-cli
- aocli
- advent_of_code_cli
- advent_of_code_generator
- advent-rb