Skip to main content

This package refers to the topic of automata theory, which includes DFA, NDFA, Mealy machines, Moore machines and Finite state machine.

Project description

AutomaPy

The package contains a set of tools and algorithms for theoretical computer science, which could include automata theory as well as other topics.

Examples of How To Use (AutomaPy)

Create a program that implements a machine that accepts strings ending with '101'.

from AutomaPy import DFA



dfa = DFA()



dfa.addState("A" , {"0": "A", "1":"B"}, initial_state = True)

dfa.addState("B" , {"0": "C", "1":"B"})

dfa.addState("C" , {"0": "A", "1":"D"})

dfa.addState("D" , {"0": "C", "1":"B"}, final_state=True)



print(dfa.endingWithOneZeroOne("101"))

print(dfa.endingWithOneZeroOne("01101"))

print(dfa.endingWithOneZeroOne("011011"))

Design a Program for creating machine that accepts three consecutive one.

from AutomaPy import DFA



dfa = DFA()



dfa.addState("A" , {"0": "A", "1":"B"}, initial_state = True)

dfa.addState("B" , {"0": "A", "1":"C"})

dfa.addState("C" , {"0": "A", "1":"D"})

dfa.addState("D" , {"0": "F", "1":"E"}, final_state=True)

dfa.addState("E" , {"0": "E", "1":"E"})

dfa.addState("F", {"0": "F", "1":"G"}, final_state=True)

dfa.addState("G", {"0": "F", "1":"H"}, final_state=True)

dfa.addState("H", {"0": "F", "1":"D"}, final_state=True)



print(dfa.threeConsecutiveOne("010111"))

print(dfa.threeConsecutiveOne("01011"))

print(dfa.threeConsecutiveOne("010101"))

Write a program for tokenization of given input.

from AutomaPy import DFA



dfa = DFA()



print(dfa.tokenize("This is an example of tokenization."))

Design a program for accepting decimal number divisible by 2.

from AutomaPy import DFA



dfa = DFA()



dfa.addState("A", {"0": "A", "1": "B"}, initial_state=True, final_state=True)

dfa.addState("B", {"0": "A", "1": "B"})



print(dfa.decimalNumberDivisibleByTwo("10")) # Decimal number of "10" is 2

print(dfa.decimalNumberDivisibleByTwo("110")) # Decimal number of "10" is 6

print(dfa.decimalNumberDivisibleByTwo("101")) # Decimal number of "10" is 5

Design a program for creating a machine which accepts string having equal no. of 1’s and 0’s.

from AutomaPy import DFA



dfa = DFA()



dfa.addState("A", {"0": "B", "1": "B"}, initial_state=True, final_state=True)

dfa.addState("B", {"0": "A", "1": "A"}, final_state=True)



print(dfa.equalNumberOfOneZero("10"))

print(dfa.equalNumberOfOneZero("101100"))

print(dfa.equalNumberOfOneZero("1011"))

Design a program for creating a machine which count number of 1's and 0's in a given string.

from AutomaPy import DFA



dfa.addState("A", {"0": "A", "1": "A"}, initial_state=True)



print(dfa.countNumberOfOneZero("0101"))

print(dfa.countNumberOfOneZero("01"))

print(dfa.countNumberOfOneZero("011111"))

print(dfa.countNumberOfOneZero("00000"))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

AutomaPy-1.0.9.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

AutomaPy-1.0.9-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file AutomaPy-1.0.9.tar.gz.

File metadata

  • Download URL: AutomaPy-1.0.9.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for AutomaPy-1.0.9.tar.gz
Algorithm Hash digest
SHA256 4a3202d9c84d6ea9727453b33e6c5b0cacb3a21986f04a314ab142bbd5f345b2
MD5 9d7c0e7a10ee2b4e8ad9a91e7947a61a
BLAKE2b-256 16885039c57c012436d5e2f3b12ede45c258678b1cd85b95cb7c28ffa38e70fd

See more details on using hashes here.

File details

Details for the file AutomaPy-1.0.9-py3-none-any.whl.

File metadata

  • Download URL: AutomaPy-1.0.9-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for AutomaPy-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 639a2a1e3853c0a11a38e50996c3c3212de090b12df5863d0730d80d7fd5130e
MD5 78f0311694ade28614c254e63a315a83
BLAKE2b-256 f858ad33d12f224241ad788886d9ee3636d2ba6adb9a2b49301c0b00e1a7eca6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page