Skip to content

Instantly share code, notes, and snippets.

@jshawl
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jshawl/83369752467d9d57afa6 to your computer and use it in GitHub Desktop.
Save jshawl/83369752467d9d57afa6 to your computer and use it in GitHub Desktop.
grid = [
[0,0,0],
[0,0,0],
[0,0,0]
]
ships = [
[ [0,0],[0,1] ],
[ [1,2],[2,2] ]
]
grid.each_with_index do |row, index|
puts " "
row.each_with_index do |space, col|
marker = ' * '
ships.each do |ship|
ship.each do |coord|
if coord == [col, index]
marker = " S "
end
end
end
print "#{marker}"
end
puts " "
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment