Skip to content

Instantly share code, notes, and snippets.

@arriqaaq
Created December 19, 2021 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arriqaaq/497b51b1f5fe95417046a22da8f8381f to your computer and use it in GitHub Desktop.
Save arriqaaq/497b51b1f5fe95417046a22da8f8381f to your computer and use it in GitHub Desktop.
Turing
// Input: a binary number n
// Ouput: accepts if n mod 3 == 0
// Example: accepts 110 (=6)
//
// ------- States -----------|
// q0 - mod3 == 0 |
// q1 - mod3 == 1 |
// q2 - mod3 == 2 |
// qaccept - accepting state |
//---------------------------|
name: Binary numbers divisible by 3
init: q0
accept: qAccept
q0,0
q0,0,>
q0,1
q1,1,>
q1,0
q2,0,>
q1,1
q0,1,>
q2,0
q1,0,>
q2,1
q2,1,>
q0,_
qAccept,_,-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment