-
Notifications
You must be signed in to change notification settings - Fork 543
Easier solution #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Easier solution #14
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# At the start all cats are hatless. | ||
cats = [False]*100 | ||
|
||
# We do a loop over each step size from 1 to 100 | ||
for step in range(1,101): | ||
|
||
# We only look at cat indices that are a multiple of our step size | ||
for i in range(1, 100//step + 1): | ||
|
||
# We change the hat status for each cat we loop over | ||
cats[i*step-1] = not cats[i*step-1] | ||
|
||
|
||
# Print the list of cats that have a hat | ||
for i in range(100): | ||
if cats[i]: | ||
print(f"Cat {i+1} has a hat!") | ||
|
Uh oh!
There was an error while loading. Please reload this page.