aoc2023/day_5/test.rb

60 lines
760 B
Ruby

if ARGV[0] == "2"
require_relative "impl_2"
RESULT = 46
else
require_relative "impl"
RESULT = 35
end
INPUT = <<~IN
seeds: 79 14 55 13
seed-to-soil map:
50 98 2
52 50 48
soil-to-fertilizer map:
0 15 37
37 52 2
39 0 15
fertilizer-to-water map:
49 53 8
0 11 42
42 0 7
57 7 4
water-to-light map:
88 18 7
18 25 70
light-to-temperature map:
45 77 23
81 45 19
68 64 13
temperature-to-humidity map:
0 69 1
1 0 69
humidity-to-location map:
60 56 37
56 93 4
IN
def test_example
parsed = parse(INPUT)
result = calculate(parsed)
if result == RESULT
puts "Test successful. Now run with real input"
puts "ruby day_5/run.rb #{ARGV[0]}"
else
puts "Test failed"
puts "expected \"#{RESULT}\" got \"#{result}\""
end
end
test_example