TEST_RB = <<~'TEST' if ARGV[0] == "2" require_relative "impl_2" RESULT = example_result_2 else require_relative "impl" RESULT = %example_result_1% end INPUT = <<~IN %example_input% IN def test_example parsed = parse(INPUT) result = calculate(parsed) if result == RESULT puts "Test successful. Now run with real input" puts "ruby %day_name%/run.rb #{ARGV[0]}" else puts "Test failed" puts "expected \"#{RESULT}\" got \"#{result}\"" end end test_example TEST RUN_RB = <<~'RUN' if ARGV[0] == "2" require_relative "impl_2" else require_relative "impl" end def print(result) if result.is_a? Array result.map! {|l| "#{l}\n" } end puts result end def run puts "running your implementation" input = File.new("%day_name%/data").read data = parse(input) result = calculate(data) print(result) end run RUN IMPL_RB = <<~'IMPL' #prepare the input which is a string containing new lines def parse(input) data = [] input.each_line do |line| data << line end data end # result should a single string or integer def calculate(data) result = "" data.each do |d| result = d end result end IMPL