parameters: (self, n, k)
return_statement: return "".join(result)
docstring: :type n: int
          :type k: int
          :rtype: str
docstring_summary: :type n: int
          :type k: int
          :rtype: str
docstring_tokens: : type n : int : type k : int : rtype : str
function: def crackSafe(self, n, k):
          """
          :type n: int
          :type k: int
          :rtype: str
          """
          def dfs(k, node, lookup, result):
              for i in xrange(k):  # preorder like traversal relative to initial result to avoid getting stuck, i.e. don't use k-1 until there is no other choice
                  neighbor = node + str(i)
                  if neighbor not in lookup:
                      lookup.add(neighbor)
                      result.append(str(i))
                      dfs(k, neighbor[1:], lookup, result)
                      break
  
          result = [str(k-1)]*(n-1)
          lookup = set()
          dfs(k, "".join(result), lookup, result)
          return "".join(result)
function_tokens: def crackSafe ( self , n , k ) : def dfs ( k , node , lookup , result ) : for i in xrange ( k ) : # preorder like traversal relative to initial result to avoid getting stuck, i.e. don't use k-1 until there is no other choice neighbor = node + str ( i ) if neighbor not in lookup : lookup . add ( neighbor ) result . append ( str ( i ) ) dfs ( k , neighbor [ 1 : ] , lookup , result ) break result = [ str ( k - 1 ) ] * ( n - 1 ) lookup = set ( ) dfs ( k , "" . join ( result ) , lookup , result ) return "" . join ( result )