Created
May 2, 2014 03:48
-
-
Save bgmarx/683402bf9a9a751b545d to your computer and use it in GitHub Desktop.
make a chessboard
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
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