Skip to content

Instantly share code, notes, and snippets.

@svetlyak40wt
Created February 12, 2018 11:28
Show Gist options
  • Save svetlyak40wt/f877e425081b6db365d78f028780d84f to your computer and use it in GitHub Desktop.
Save svetlyak40wt/f877e425081b6db365d78f028780d84f to your computer and use it in GitHub Desktop.
Pretty numbificator
def is_pretty_num(n):
if len(n) > 4:
i = n[0]
for l in n[1:]:
if l != i:
i = 0
break
if i != 0:
return 1
i = int(n[0])
for l in n[1:]:
if int(l) == i + 1:
i += 1
else:
i = 0
break
if i != 0:
return 1
i = int(n[-1])
for l in n[::-1][1:]:
if int(l) == i + 1:
i += 1
else:
i = 0
break
if i != 0:
return 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment