https://github.com/spencerwi/adventofcode2018
Advent of code solutions for 2018
https://github.com/spencerwi/adventofcode2018
advent-of-code advent-of-code-2018 crystal crystal-lang
Last synced: 6 months ago
JSON representation
Advent of code solutions for 2018
- Host: GitHub
- URL: https://github.com/spencerwi/adventofcode2018
- Owner: spencerwi
- License: mit
- Created: 2018-12-01T12:55:57.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-17T12:59:13.000Z (about 7 years ago)
- Last Synced: 2025-02-21T15:49:31.513Z (about 1 year ago)
- Topics: advent-of-code, advent-of-code-2018, crystal, crystal-lang
- Language: Crystal
- Size: 374 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Advent of Code solutions for 2018
## Requirements
[Crystal-lang](https://crystal-lang.org), at least 0.27.0
## Running tests
Most (but not all) solutions have tests, in a `spec/` subdirectory in the day's
directory. To run the test, cd into the day's dir and run `crystal spec`.
## What's the deal with that weird `unless PROGRAM_NAME` thing?
Normally, you write your "library" logic in one Crystal file and your executable
"wrapper" in another file, and your specs import the library file and test it.
However, that's a lot of overhead for these problems, but I like the idea of
being able to TDD my way to solutions given the sample input/outputs, so each of
my solutions checks to see if the file is being imported as part of running
specs (by looking at the current executable name and matching against a special
name Crystal uses for the `crystal spec` command) and if so, doesn't execute the
"main"/"executable" logic.