/mod-3-fsm

Modulo Three FSM

Primary LanguageTypeScript

Modulo Three

This little application gives several options for finding the remainder of division by 3:

  • ModuloThreeFSM: API library implements the ‘mod-three’ procedure. Available methods:
    1. getters and setters for states, alphabet, initial state, final state and transitions object
    2. parseInput(): method that returns the remainder of division by 3 of the input binary string
    3. nextState(): a method that returns the next state of the FSM depending on the passed state and the incoming value
  • easy: converts a string to a number and returns the remainder after division by 3
  • standart: implement a state transition algorithm to implement the‘mod-three’ procedure
  • advanced: hardcoded version of finite automaton (FA) is a 5-tuple

To run it localy

  1. Clone GitHub repo Modulo Three
  2. cd mod-3-fsm
  3. npm install
  4. ts-node ./src/run.ts 10011 or any other valid binary string

To run tests

  1. Clone GitHub repo Modulo Three
  2. cd mod-3-fsm
  3. npm install
  4. npm run test:all

Result of the last command

Screenshot 2023-05-22 at 23 42 29

Test each version separately

You can also run tests separately for each option:

  • ModuloThreeFSM: npm run test:api
  • easy: npm run test:easy
  • standart: npm run test:std
  • advanced: npm run test:adv