Module: AocRb::PuzzleSource
Instance Method Summary collapse
Instance Method Details
#create_puzzle(year, day, input) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/aoc_rb/puzzle_source.rb', line 8 def create_puzzle(year, day, input) padded_day = Puzzle.padded(day) begin Module.const_get("Year#{year}").const_get("Day#{padded_day}").new(input) rescue NameError puts "There is no solution for this puzzle" end end |
#run_part(part_name) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/aoc_rb/puzzle_source.rb', line 17 def run_part(part_name) solution = nil t = Benchmark.realtime do solution = yield if !solution.nil? puts "Result for #{part_name}:" puts solution else puts "no result for #{part_name}" end end puts "(obtained in #{t} seconds)" unless solution.nil? solution end |