Skip to main content

Automata Practical Exam - DFA and Turing Machine

Project description

Automata Practical Exam – Section 5

Student Info

  • Section Number: 5
  • Tasks Solved:
    1. DFA that accepts binary strings containing the substring 101
    2. Turing Machine that recognizes binary numbers divisible by 3

Project Structure

automata_practical_exam_<4549>/
│
├── automata/                    #  Python package root
│   ├── __init__.py              # makes this a package
│   ├── dfa.py                   # DFA implementation
│   └── turing_machine.py        # Turing Machine implementation
│
├── tests/                       #  Unit tests
│   ├── test_dfa.py
│   └── test_turing_machine.py
│
├── README.md                    #  this file
└── setup.py                     #  package metadata


-------------------------------------------------
>>>Installation
# from project root
pip install -e .
Installs the package in “editable” mode so you can modify code and see changes immediately.

>>>Usage
1. Import and run the DFA
from automata.dfa import DFA

dfa = DFA()
print(dfa.accepts("010101"))   # True
print(dfa.accepts("0100"))     # False


------------------------------------------------

2. Import and run the Turing Machine
from automata.turing_machine import TuringMachine

tm = TuringMachine("110")      # binary 6
print(tm.run())                # True (6 divisible by 3)

tm2 = TuringMachine("101")     # binary 5
print(tm2.run())               # False (5 not divisible by 3)


------------------------------------------------
 >>>>>Running Tests
 pip install pytest
pytest tests/


Or run individual test files:
python -m pytest tests/test_dfa.py
python -m pytest tests/test_turing_machine.py

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

automata_practical_mohamedaz-0.1.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

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

automata_practical_mohamedaz-0.1-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file automata_practical_mohamedaz-0.1.tar.gz.

File metadata

File hashes

Hashes for automata_practical_mohamedaz-0.1.tar.gz
Algorithm Hash digest
SHA256 92e1350b14335e99d2b4bbf32999472875223a53d23620db95ddac38b982eb03
MD5 3712788a9aea21b9d0f601e6298f7ba4
BLAKE2b-256 289727fc34a83decc3758d90d609403da4e83f559ee3b9a4d0edb6f2595c7050

See more details on using hashes here.

File details

Details for the file automata_practical_mohamedaz-0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for automata_practical_mohamedaz-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6329732e4651c2010df4ee41123b78f97f207303de52c2a59c09647cf9088cb0
MD5 e4a228a59bb3bf944a14221680f815cb
BLAKE2b-256 5ddb21b55e0e05ca3e603823eb97592b8e79016be0a0f658fdf60749e316b6bf

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