User:Vel!/Turing golf

Your challenge in each of these problems is to construct a Turing machine that computes things.

Rules:
 * Use only standard Turing machines except where otherwise noted.
 * Your score is \(\text{states} + (\text{colors} + 2)^2 - 16\). Like golf, you are trying to minimize your score for each challenge.
 * Input and output formats are up to you. Usually the input consists of one or more strings of ones separated by single blanks.
 * You are absolutely free to break these rules and try to do these using other restricted programming environments. Lambda calculus, Brainf***, anything you want. You have to come up with your own scoring system, however.
 * Please add your own challenges to this page! They are ordered roughly by perceived difficulty.

The par, indicated in each header, is the score that I guessed is average. If you score above par, you get a bogey, and if you score below par, you get a birdie.

Maybe someday I'll offer prizes. (Which, of course, will be math books.)

Addition (par 2)
Given two inputs \(n\) and \(m\), compute \(n + m\).

Deedlit's answer
Assuming \(n\) and \(m\) are strings of ones separated by a space, we can use:

0 _ 1 r 1 0 1 1 r 0 1 _ _ l 2 1 1 1 r 1 2 1 _ l halt 2 _ _ l halt

It just fills in the blank and eliminates the rightmost 1. Deedlit11 (talk) 00:17, April 4, 2013 (UTC)

FB100Z's answer
0 1 _ r 1 1 1 * r * 1 _ 1 * halt

This one's even simpler, removing the leftmost 1 then filling the blank. FB100Z &bull; talk &bull; contribs 03:21, April 4, 2013 (UTC)

Comparison (par 6)
Given two inputs \(n\) and \(m\), determine whether \(n < m\), \(n = m\), or \(n > m\).

Aarex's answer
0 1 * l 0 0 _ * r 1 1 1 _ r 2 1 _ < * halt 2 1 * r 2 2 _ * r 3 3 1 * r 3 3 _ * l 4 4 1 _ l 5 4 _ > * halt 5 1 * l 5 5 _ * l 0

Aarex (talk) 00:38, April 4, 2013 (UTC)

FB100Z's answer
0 1 * r * 0 _ * r r2 r2 1 * r * r2 _ * l r3 r3 1 _ l l1 r3 _ * * halt

l1 1 * l * l1 _ * l l2 l2 1 * l * l2 _ * l l3 l3 1 _ r 0 l3 _ * * halt

I'm not sure if this counts.

FB100Z &bull; talk &bull; contribs 03:26, April 4, 2013 (UTC)

Duplication (par 6)
Given \(n\), output two copies of \(n\).

Ikosarakt's answer
0 _ _ l halt 0 1 _ r 1 1 1 * r 1 1 _ * r 2 2 _ 1 r 3 2 1 * r 2 3 _ 1 l 4 4 _ * l 5 4 1 * l 4 5 _ * r 0 5 1 * l 5

Ikosarakt1 (talk ^ contribs) 07:41, April 4, 2013 (UTC)

Polynomial
Given a sequence \(a_0, a_1, a_2, \ldots, a_n\) and an input \(x\), compute \(\sum_{i = 0}^n a_nx^n\); i.e. the polynomial with coefficients \(a_i\) and input \(x\).


 * Is that Exponential factorial? $Jiawhein$\(a\)\(l\)\(t\) 12:32, April 4, 2013 (UTC)

Factorial
Compute \(n!\) given \(n\).

Graham's number
Compute Graham's number. The score limit is 1000 &mdash; no TMs with \(g_{64}\) states!

PRNG
Construct any pseudo-random number generator. Open problem, no scores here.

Divisor sum
Compute the sum of the divisors of \(n\).

Pi
Compute digits of pi in any base of your choice.


 * 5 trillion.$Jiawhein$\(a\)\(l\)\(t\) 12:33, April 4, 2013 (UTC)

Partition function
Ignoring order, there are five distinct sums that add to 4:


 * 4
 * 3 + 1
 * 2 + 2
 * 2 + 1 + 1
 * 1 + 1 + 1 + 1

Compute the number of ways you can add positive integers to get \(n\).

String subsequence
Determine whether the one sequence of strings is a subsequence of other (arbitrary number of types of symbols).

n(k) function
Compute n(k) for given n.

Goodstein function
Compute G(n) for given n.

TREE function
Compute TREE(n) for given n.

SCG function
Compute SCG(n) for given n.