Skip to content
This repository has been archived by the owner on Apr 24, 2019. It is now read-only.

Commit

Permalink
Loop through rows to find winning player
Browse files Browse the repository at this point in the history
  • Loading branch information
edgenard committed Apr 2, 2018
1 parent 91764b5 commit 1dd3398
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions tic-tac-toe/tic_tac_toe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1dd3398

Please sign in to comment.