Skip to content

Instantly share code, notes, and snippets.

@evmorov
Created September 3, 2016 21:17
Show Gist options
  • Save evmorov/3be70174184f2c2469e0de5199b3ec7c to your computer and use it in GitHub Desktop.
Save evmorov/3be70174184f2c2469e0de5199b3ec7c to your computer and use it in GitHub Desktop.
require 'rspec'
require_relative 'mine_solver'
describe MineSolver do
describe '#safe' do
it do
board = '
1????
1????
111??
1??
1211 1??
???21 1??
????211??
?????????
?????????'
expected = [
[0, 5],
[1, 6],
[1, 7],
[2, 7],
[3, 7],
[5, 1],
[5, 7],
[6, 2],
[6, 7]
]
expect(subject.safe(board)).to match_array(expected)
end
it do
board = '
1?
1??
111'
expected = [[0, 1], [1, 2]]
expect(subject.safe(board)).to match_array(expected)
end
it do
board = '
1211
???21
????21
??????'
expected = [[1, 1], [2, 2]]
expect(subject.safe(board)).to match_array(expected)
end
it do
board = '
1211
???1'
expected = [[1, 1]]
expect(subject.safe(board)).to match_array(expected)
end
it do
board = '
1?
1?
1?'
expected = [[0, 1], [2, 1]]
expect(subject.safe(board)).to match_array(expected)
end
it do
board = '
111
??1
??'
expected = [[1, 0], [2, 1], [2, 2]]
expect(subject.safe(board)).to match_array(expected)
end
it do
board = '
1 1
1??
1??
1?
? '
expected = [[1, 2], [2, 1], [3, 1]]
expect(subject.safe(board)).to match_array(expected)
end
it do
board = '
1
??2
?
?1'
expected = [[1, 0], [3, 2]]
expect(subject.safe(board)).to match_array(expected)
end
it do
board = '
1?
?
2?'
expected = [[0, 1]]
expect(subject.safe(board)).to match_array(expected)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment