Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions algorithms/automata/dfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ def DFA(transitions, start, final, string):
num = len(string)
num_final = len(final)
cur = start
for i in range (num):
if transitions[cur][string[i]] == None:

for i in range(num):

if transitions[cur][string[i]] is None:
return False
else:
cur = transitions[cur][string[i]]

for i in range (num_final):
for i in range(num_final):
if cur == final[i]:
return True
return False

8 changes: 4 additions & 4 deletions algorithms/graph/tarjan.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""
from algorithms.graph.graph import DirectedGraph


class Tarjan(object):
def __init__(self, dict_graph):
self.graph = DirectedGraph(dict_graph)
Expand All @@ -18,7 +19,7 @@ def __init__(self, dict_graph):

self.sccs = []
for v in self.graph.nodes:
if v.index == None:
if v.index is None:
self.strongconnect(v, self.sccs)

def strongconnect(self, v, sccs):
Expand All @@ -31,7 +32,7 @@ def strongconnect(self, v, sccs):

# Consider successors of v
for w in self.graph.adjmt[v]:
if w.index == None:
if w.index is None:
# Successor w has not yet been visited; recurse on it
self.strongconnect(w, sccs)
v.lowlink = min(v.lowlink, w.lowlink)
Expand All @@ -41,7 +42,7 @@ def strongconnect(self, v, sccs):
# Note: The next line may look odd - but is correct.
# It says w.index not w.lowlink; that is deliberate and from the original paper
v.lowlink = min(v.lowlink, w.index)

# If v is a root node, pop the stack and generate an SCC
if v.lowlink == v.index:
# start a new strongly connected component
Expand All @@ -54,4 +55,3 @@ def strongconnect(self, v, sccs):
break
scc.sort()
sccs.append(scc)

3 changes: 1 addition & 2 deletions algorithms/strings/multiply_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"""


def multiply(num1:"str", num2:"str")->"str":
carry = 1
def multiply(num1: "str", num2: "str") -> "str":
interm = []
zero = ord('0')
i_pos = 1
Expand Down