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.
 * Inputs consist of strings of ones. Where multiple inputs are called for, they are separated by single blank cells.
 * The output format is up to you.
 * 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.

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

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 sum.

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.

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\).

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