Skip to content

Instantly share code, notes, and snippets.

@agoodkind
Created June 19, 2018 18:35
Show Gist options
  • Save agoodkind/aa5dfa43dbc8032245d7ee91c9081e9b to your computer and use it in GitHub Desktop.
Save agoodkind/aa5dfa43dbc8032245d7ee91c9081e9b to your computer and use it in GitHub Desktop.
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