Created
July 16, 2019 22:31
-
-
Save Cyborg-Model-Z/7c59f9de0bd95ee61e731f0bd6d1a91f to your computer and use it in GitHub Desktop.
Jumping numbers
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
| @camsbury | |
| This exercise wanted you to take an int and determine if it was "jumping" with jumping meaning the subsequent numbers in the string only differ by one | |
| 787 = jumping 1234 = jumping 1235 != jumping 5656543234 = jumping | |
| I put a little skeleton together but I think I should be getting some "no's" and I'm getting all yesses | |
| ``` | |
| def make_str(int): | |
| return str(int) | |
| def split_number(str): | |
| lst = [int(d) for d in str] | |
| return lst | |
| def jumping(lst): | |
| count = len(lst) | |
| while count >=1: | |
| if lst[count-1]-lst[count-2] == 1 or -1: | |
| count -=1 | |
| print ('yes') | |
| else: | |
| print ('no') | |
| def jumping_number(number): | |
| pass | |
| jumping(split_number(make_str(727567654))) | |
| ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment