Ed Murphy wrote:
>Trivially so; if you have M and N farms, then replace X with X-M
>and Y with Y-N.

Not quite.  It's easy (I would say trivial except that people are
getting it wrong) if N = (M+1) % 10.  In that case, replace X with
(X-M), Y with (Y-M), and Z with (Z-M).  That gets you a machine that
will take inputs of M and N digits, and (the bit you've both missed)
still produce outputs of 2 to 9 digits.  You need to modify the "2 +"
as well to get a combination that gives you the full range of digits:

        11 * ((2 + M + 4(X-M) + 2(Y-M) + (Z-M)) % 10)

If M and N are not contiguous, then it's more difficult because the
desired output range is not contiguous.  Using the C-style conditional
operator, and C syntax, how about (given M < N):

        t = 4*(X == M ? 0 : 1) + 2*(Y == M ? 0 : 1) + (Z == M ? 0 : 1);
        d = t + (t < M ? 0 : t < N-1 ? 1 : 2);
        return 11*d;

This raises the question of what operators are permitted in an
"expression".  I mentioned this last time, back in August, but there
was no further discussion.  Trivially, the operation of any valid
expression machine can be explicated in the form of a thousand-entry
lookup table (one entry for each (X,Y,Z) tuple), where each entry has
as its value either an integer in the range [00,99] or a null (for where
the expression has a value outside the valid range, so the machine emits
no digits).  If one were to attempt to construct an expression machine
whose expression was expressed *only* as a thousand-entry lookup table,
would that be permitted?

The lookup table form can be trivially converted to a more conventional
expression, if using a C-style conditional operator:

        ... : X==3&&Y==5&&Z==7 ? 67 : X==3&&Y==5&&Z==8 ? 92 : ...

or, with a bit more effort, using floor() instead:

        ... + floor((X+6)%10/9.0)*floor((Y+4)%10/9.0)*floor((Z+2)%10/9.0)*67
            + floor((X+6)%10/9.0)*floor((Y+4)%10/9.0)*floor((Z+1)%10/9.0)*92
            + ...

If it is accepted that it would always be possible to express a lookup
table as an acceptable form of expression, then it might even be useful
to *require* that the expression be given in lookup-table form: this is
the ultimate guarantee that the proposed expression is computable and
that its meaning cannot be argued about.

-zefram

Reply via email to