Skip to content

Instantly share code, notes, and snippets.

@fosterdill
Last active August 29, 2015 14:16
Show Gist options
  • Save fosterdill/dba8253229342b44a5ec to your computer and use it in GitHub Desktop.
Save fosterdill/dba8253229342b44a5ec to your computer and use it in GitHub Desktop.
Cats in hats
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