module BingoGrader
extend self
def bingo?(board)
bingo_via_row?(board) ||
bingo_via_row?(board.transpose) ||
bingo_via_diag?(board) ||
bingo_via_diag?(board.reverse)
end
private
#solves the horizontal problem. Enemerable madness.
def bingo_via_row?(board)
board.map do |row|
row.all? {|v| v == 0 }
end.any?
end
def bingo_via_diag?(board)
size = board[0].count
(0..size-1).map {|n| board[n][n] }.all? {|v| v == 0 }
end
end
Created
June 9, 2015 04:39
-
-
Save thatrubylove/9020555f33434758c755 to your computer and use it in GitHub Desktop.
test gf markdown
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment