Last active
August 29, 2015 14:16
-
-
Save fosterdill/dba8253229342b44a5ec to your computer and use it in GitHub Desktop.
Cats in hats
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
def cats_in_hats n | |
cats = Array.new(n) | |
(0...n).each do |i| | |
(1..n).each do |j| | |
cats[i] = !cats[i] if i % j == 0 | |
end | |
end | |
cats | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment