Cyclic Tag System: 1 Line of Turing-Complete Code
blog.barvinograd.com
Cyclic Tag System: 1 Line of Turing-Complete Code
1–10 of 14 posts
Re: Cyclic Tag System: 1 Line of Turing-Complete Code
#2This is very cool. It's amazing how "simple" something can be and still be Turing-complete.
Also slightly shorter:
while word[S:]: pIndex, word = (pIndex + 1) % len(C), word[1:] + C[pIndex] * (word[0] == "1")
Or, even shorter, while word[S:]: pIndex, word = (pIndex + 1) % len(C), word[1:] + C[pIndex] * int(word[0])
And obviously one can just use one letter variable names/remove whitespace.Re: Cyclic Tag System: 1 Line of Turing-Complete Code
#3[deleted]
Re: Cyclic Tag System: 1 Line of Turing-Complete Code
#4At first I thought this was describing Bitwise Cyclic Tag (http://esolangs.org/wiki/Bitwise_Cyclic_Tag), but it's subtly different. And even simpler, as it turns out. I'm impressed.
Re: Cyclic Tag System: 1 Line of Turing-Complete Code
#5"The following line of python code is able to simulate a Universal Turing Machine:"
while len(word) > S : pIndex, word = (pIndex + 1) % len(C), word[1:] + C[pIndex]
if (word[0] == "1") else word[1:]Re: Cyclic Tag System: 1 Line of Turing-Complete Code
#6"The following line of python code is able to simulate a Universal Turing Machine:" while len(word) > S : pIndex, word = (pIndex + 1) % len(C), word[1:] + C[pIndex] if (word[0] == "1") else word[1:]
It's not obvious for a non-Pythonista, but the if .. else .. is meant to be on the previous line. It's a ternary conditional like cond?a:b in C (with the condition in the middle).
Re: Cyclic Tag System: 1 Line of Turing-Complete Code
#7The completeness of CTS was also used in the proof of completeness of the 2-state 3-symbol Turing machine.
Re: Cyclic Tag System: 1 Line of Turing-Complete Code
#8If this interested you, consider checking out the book A New Kind of Science by Wolfram. It describes tag systems, and a hundred other things that are similarly cool and fun to play with.
Re: Cyclic Tag System: 1 Line of Turing-Complete Code
#9Almost a year ago I tried to see how short of a cyclic tag system I could make in Ruby. The result: https://github.com/elitheeli/stupid-machines/blob/master/sho...
Re: Cyclic Tag System: 1 Line of Turing-Complete Code
#10"The following line of python code is able to simulate a Universal Turing Machine:" while len(word) > S : pIndex, word = (pIndex + 1) % len(C), word[1:] + C[pIndex] if (word[0] == "1") else word[1:]
It's not obvious for a non-Pythonista, but the if .. else .. is meant to be on the previous line. It's a ternary conditional like cond?a:b in C (with the condition in the middle).
Yes, they should have broken the line before `word[1:]` so it was clearer.