Skip to content

Instantly share code, notes, and snippets.

@bgmarx
Created May 2, 2014 03:48
Show Gist options
  • Save bgmarx/683402bf9a9a751b545d to your computer and use it in GitHub Desktop.
Save bgmarx/683402bf9a9a751b545d to your computer and use it in GitHub Desktop.
make a chessboard
def chess_board(size = 8)
i = 0
j = 0
while i < (size * size)
if i % (size) == 0
puts ""
j % 2 == 0 ? print("# " * (size / 2)) : print(" #" * (size / 2))
j += 1
end
i += 1
end
end
puts chess_board(8)
# # # #
# # # #
# # # #
# # # #
# # # #
# # # #
# # # #
# # # #
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment