Created
December 7, 2015 00:36
-
-
Save jmdeldin/8bff73b25c25164e50c3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| $grid = Array.new(10, "X").map { |r| Array.new(10, "X") } | |
| def $grid.print | |
| puts map(&:join) | |
| end | |
| def $grid.draw(row, col, size: 2) | |
| bounds = $grid.length | |
| fail "out of bounds #{row}+#{size} > #{bounds}" if row+size > bounds | |
| shape = ' ' | |
| size.times do |i| | |
| $grid[row][col + i] = shape | |
| $grid[row + i][col] = shape | |
| $grid[row + i][col + i] = shape | |
| end | |
| end | |
| $grid.draw(5, 5) | |
| $grid.print |
Author
jmdeldin
commented
Dec 7, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment