Can this program be shortened? Measuring program-length?
r.e.s.
r_e_s_01 at ZZZyahoo.com
Thu Jul 10 15:57:51 EDT 2008
Can the following program be shortened? ...
def h(n,m):
E=n,
while (E!=())*m>0:n=h(n+1,m-1);E=E[:-1]+(E[-1]>0)*(E[-1]-1,)*n
return n
h(9,9)
Note: Although it halts eventually in principle, this program can't be
expected to terminate on any machine in the universe, as it computes a
number larger than Graham's number -- assuming Python is extended (if
necessary?) to access unbounded storage.
Besides using one-letter names and no unneeded whitespace, can something
more be done to shorten it? ("Obfuscating" the code would be okay.)
Also, I'm not really sure how best to measure a program's length, but
this one is now 98 bytes long (or 102 bytes, depending on how newlines
are handled). Is there a better measure of program-length?
Thanks for any feedback.
More information about the Python-list
mailing list