aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdgar-Alexis-Lopez-Martinez <83847738+Edgar-Alexis-Lopez-Martinez@users.noreply.github.com>2022-11-07 21:08:32 -0600
committerGitHub <noreply@github.com>2022-11-07 21:08:32 -0600
commite0031d8bd9aa03515e487a9d1b71035f05fb9bd7 (patch)
tree217a28221daf9ce018aa2c54fecc9b70f1bc325d
parentfa5994f682992c61e749091445cc072e871d9d46 (diff)
downloadjavanol-e0031d8bd9aa03515e487a9d1b71035f05fb9bd7.tar.gz
javanol-e0031d8bd9aa03515e487a9d1b71035f05fb9bd7.tar.bz2
javanol-e0031d8bd9aa03515e487a9d1b71035f05fb9bd7.zip
Create automata_enteros.py
-rw-r--r--automata_enteros.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/automata_enteros.py b/automata_enteros.py
new file mode 100644
index 0000000..cdf5879
--- /dev/null
+++ b/automata_enteros.py
@@ -0,0 +1,61 @@
+class automata_enteros:
+ int stateN = 0
+ int isAccepted(char str[]):
+
+ int len = len(str)
+
+ for i in len:
+ if (stateN == 0):
+ start(str[i])
+ else:
+ if (stateN == 1):
+ state1(str[i])
+ else:
+ if(stateN == 2):
+ state2(str[i])
+ else:
+ if(stateN == 3):
+ state3(str[i])
+ else
+ return 0
+
+ if (stateN == 2 or stateN == 3):
+ return 1
+ else:
+ return 0
+
+ def start(char c):
+
+ if (c == '1' or c == '2' or c == '3' or c == '4' or c == '5' or
+ c == '6' or c == '7' or c == '8' or c == '9'):
+ stateN = 3
+ else:
+ if (c == '0'):
+ stateN = 2
+ else:
+ if(c == '-'):
+ stateN = 1
+ else:
+ stateN = -1
+
+ def state1(char c):
+ if (c == '1' or c == '2' or c == '3' or c == '4' or c == '5' or
+ c == '6' or c == '7' or c == '8' or c == '9'):
+ stateN = 3
+ else:
+ stateN = -1
+
+ def state2(char c):
+ stateN = -1
+
+ def state3(char c):
+ if (isdigit(c)):
+ stateN = 3
+ else:
+ stateN = -1
+
+ bool verified(char* token):
+ if (isAccepted(token)):
+ return true
+ else:
+ return false