Permalink
Browse files

Loop through rows to find winning player

  • Loading branch information...
edgenard committed Apr 2, 2018
1 parent 91764b5 commit 1dd33986b50f4938ee18862d5396b582e0c440b9
Showing with 2 additions and 6 deletions.
  1. +2 −6 tic-tac-toe/tic_tac_toe.rb
@@ -26,12 +26,8 @@ def winning_move?(square, player)
end

def winner
square = 0
return winning_player(square) if winning_player(square)
square = 3
return winning_player(square) if winning_player(square)
square = 6
return winning_player(square) if winning_player(square)
rows = [0, 3, 6]
rows.each { |row| return winning_player(row) if winning_player(row) }
return '-'
end

0 comments on commit 1dd3398

Please sign in to comment.