module AocRb::PuzzleSource
Public Instance Methods
create_puzzle(year, day)
click to toggle source
# File lib/aoc_rb/puzzle_source.rb, line 8 def create_puzzle(year, day) padded_day = Puzzle.padded(day) begin Module.const_get("Year#{year}").const_get("Day#{padded_day}").new rescue NameError puts "There is no solution for this puzzle" end end
run_part(part_name) { || ... }
click to toggle source
# 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