Class: AdventOfCode::Commands::Solve

Inherits:
Command
  • Object
show all
Defined in:
lib/advent_of_code_cli/commands/solve.rb

Instance Method Summary collapse

Methods inherited from Command

#initialize

Constructor Details

This class inherits a constructor from AdventOfCode::Commands::Command

Instance Method Details

#executeObject

Raises:



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/advent_of_code_cli/commands/solve.rb', line 6

def execute
  raise MissingInputError unless File.exist?(input_file_name)
  raise MissingSolutionError unless File.exist?(solution_file_name)

  say "Reading input..."
  input = File.readlines(input_file_name, chomp: true)

  say "Loading solution..."
  load(solution_file_name)

  module_name = "Day#{day_string}"

  say "\nRunning part one..."
  solution(module_name, "one", input)

  say "\nRunning part two..."
  solution(module_name, "two", input)

  say "\nDone!", :green
end