Skip to content

emollett/AdventOfCode2022

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Advent of Code - Ruby

This repository serves as a template for the Advent of Code challenge, using Ruby as the language for solving the daily problems. This application includes:

  • A CLI interface for executing the challenge code directly
  • An RSpec collection for refactoring

Structure

For each challenge day, there is an entry file located at dayX/main.rb, with three methods:

  1. An initialize, which takes in the puzzle input as an argument
  2. part1, which returns the result for Part 1
  3. part2, which returns the result for Part 2

When you receive your problem input, you can paste it into dayX/input.txt, and it will be automatically read in with the CLI input and RSpec tests.

In the root folder is a main.rb, which can be executed via CLI, and serves as an entry for all of the daily challenge classes.

There is also a spec/ folder with RSpec tests for each day. There is a dayX_spec.rb for each day, which contains a test block for each part.

Setup

  1. Run gem install bundler if you do not have Bundler installed
  2. Run bundle install to setup Rubocop and RSpec

Using the CLI

  1. Run ruby main.rb from your CLI
  2. When prompted, enter the day for which you want to output your solution.

Using RSpec Tests

  1. After solving a problem, paste your solution into the appropriate test block as :expected
  2. Run the test via CLI using rspec spec/dayX_spec.rb, or from within RubyMine

Using RuboCop

You can run rubocop to analyze your code quality. You can also autofix some minor infractions with rubocop -a.

License

Advent of Code - Ruby is released under the MIT License.

About

My solutions for the 2022 advent of code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages