32 lines
820 B
Ruby
32 lines
820 B
Ruby
require_relative 'lib'
|
|
require 'test/unit'
|
|
|
|
class TestLib < Test::Unit::TestCase
|
|
def test_count_reachable_positions
|
|
input = [
|
|
[8, 9, 0, 1, 0, 1, 2, 3],
|
|
[7, 8, 1, 2, 1, 8, 7, 4],
|
|
[8, 7, 4, 3, 0, 9, 6, 5],
|
|
[9, 6, 5, 4, 9, 8, 7, 4],
|
|
[4, 5, 6, 7, 8, 9, 0, 3],
|
|
[3, 2, 0, 1, 9, 0, 1, 2],
|
|
[0, 1, 3, 2, 9, 8, 0, 1],
|
|
[1, 0, 4, 5, 6, 7, 3, 2]
|
|
]
|
|
assert_equal(36, count_reachable_positions(input))
|
|
end
|
|
|
|
def test_count_hiking_trails
|
|
input = [
|
|
[8, 9, 0, 1, 0, 1, 2, 3],
|
|
[7, 8, 1, 2, 1, 8, 7, 4],
|
|
[8, 7, 4, 3, 0, 9, 6, 5],
|
|
[9, 6, 5, 4, 9, 8, 7, 4],
|
|
[4, 5, 6, 7, 8, 9, 0, 3],
|
|
[3, 2, 0, 1, 9, 0, 1, 2],
|
|
[0, 1, 3, 2, 9, 8, 0, 1],
|
|
[1, 0, 4, 5, 6, 7, 3, 2]
|
|
]
|
|
assert_equal(81, count_hiking_trails(input))
|
|
end
|
|
end
|