Created
June 19, 2018 18:35
-
-
Save agoodkind/aa5dfa43dbc8032245d7ee91c9081e9b to your computer and use it in GitHub Desktop.
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
class Solution: | |
# @param A : integer | |
# @param B : integer | |
# @return a list of integers | |
def stepnum(self, A, B): | |
adjacents = [] | |
for i in range(A,B+1): | |
if self.isAdjacent(str(i)): | |
adjacents.append(i) | |
return adjacents | |
def isAdjacent(self, strNum): | |
for letter in range(0,len(strNum)-1): | |
first = int(strNum[letter]) | |
second = int(strNum[letter+1]) | |
if abs(first - second) is not 1: | |
return False | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment