Created
          February 12, 2018 11:28 
        
      - 
      
- 
        Save svetlyak40wt/f877e425081b6db365d78f028780d84f to your computer and use it in GitHub Desktop. 
    Pretty numbificator
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | 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