Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 57c5d0b722
Fetching contributors…

Cannot retrieve contributors at this time

28 lines (19 sloc) 0.764 kb
edges = {(1,'q') : 1}
accepting = [1]
def fsmsim(string,current,edges,accepting):
if string == "":
return current in accepting
letter = string[0]
if(current,letter) in edges:
destination = edges[(current,letter)]
remaining_string = string[1:]
return fsmsim(remaining_string,destination,edges,accepting)
# fall off the FSM
return False
print fsmsim("",1,edges,accepting) # should return True
print fsmsim("q",1,edges,accepting) # should return True
print fsmsim("qqqqqqqqqqqqqq",1,edges,accepting) # should return True
print fsmsim("",1,edges,accepting) # should return True
print fsmsim("qqqqqqAqqqqqq",1,edges,accepting) # should return False
Jump to Line
Something went wrong with that request. Please try again.