Created
May 18, 2012 17:03
-
-
Save mrklein/2726430 to your computer and use it in GitHub Desktop.
Project Euler #112
This file contains 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
#!/usr/bin/python | |
n = 1 | |
b = 0 | |
def is_bouncy(n): | |
if len(str(n)) <= 2: | |
return False | |
l = map(int, str(n)) | |
inc = all(x <= y for x, y in zip(l, l[1:])) | |
dec = all(x >= y for x, y in zip(l, l[1:])) | |
return (not inc) and (not dec) | |
while True: | |
if is_bouncy(n): | |
b += 1 | |
if b*100 == 99*n: | |
print n | |
break | |
n += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment