project-euler/112_bouncy_numbers.py

19 lines
268 B
Python

#!/usr/bin/env python3
# Brute force
def main(x):
i = 100
bc = 0
while 100*bc // i != x:
i += 1
bc += is_bouncy(i)
return i
def is_bouncy(n):
n = list(str(n))
s = sorted(n)
return n != s and n[::-1] != s
print(main(99))