Skip to content

Instantly share code, notes, and snippets.

@Irene-123
Created July 3, 2020 11:46
Show Gist options
  • Save Irene-123/81f904f5dde9d5fa930387dec0afa59d to your computer and use it in GitHub Desktop.
Save Irene-123/81f904f5dde9d5fa930387dec0afa59d to your computer and use it in GitHub Desktop.
The Shaggy Problem in Python !
```
'''
This is a game where you must count to number from 0 to 1000. However, if the number has a 6 in it, or is divisible by 6, you don't say the number. Instead, you say "Shaggy".
Rules:
You can't hard-code the numbers.
The number only has to satisfy at least 1 of the following requirements
Divisible by 6
Number contains a 6
Some type of separator is mandatory (12345Shaggy7.. doesn't count)
You must count exactly to 1000 from 1.
The numbers must be output, but it doesn't matter how (e.g., stdout, writing to a text file, etc.).
'''
def is_true(i):
i=str(i)
if '6' in i:
return True
return False
def is_digitPresent(n):
for i in range (n):
if i%6==0 or is_true(i):
print("shaggy!")
else :
print(i)
if __name__ == '__main__':
n=int(input())
is_digitPresent(n)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment