Created
May 12, 2017 22:53
-
-
Save ethagnawl/07c8a15eac9bc8372f174425fc331cda to your computer and use it in GitHub Desktop.
SO solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
board = [[1, 2, 3], | |
[4, 5, 6], | |
[7, 8, 9]] | |
while (input = gets.chomp.to_i) != "exit" | |
board = board.map.with_index do |row, i| | |
row.map.with_index do |column, ii| | |
if column == input | |
"x" | |
else | |
row.length * i + ii + 1 | |
end | |
end | |
end | |
board.each do |outer_row| | |
outer_row.each { |inner_row| print "| #{inner_row} |" } | |
print "\n" | |
end | |
puts "Type quit for exiting game, or a number" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment