Most of these quotes are from The Quotations Page.
FortyTwo
This is a project that stemmed from a favourite website of mine, h2g2 -- the Hitchhiker's Guide to the Galaxy.
Users of h2g2 have taken to finding ways that their user numbers can be manipulated to make 42 -- that being the answer to Life, the Universe and Everything.
Someone asked whether a program could be found to sort out the problem of making 42... and various people stepped forward to take up the challenge. Here are two of my attempts...
The first, GFortyTwo, is goal-based. This means it splits the digits into two halves recursively, and 'asks' for a useful number from each half. This approach is quite different from just enumerating all the possibilities; it also seems to be reasonably fast. You can try it online in applet form here.
An interesting case is that GFortyTwo operates increasingly quickly when you give it longer sequences of digits, whereas a brute-force approach would soon become too slow.
My second attempt, MFortyTwo, uses what is effectively a brute-force approach: it supports arithmetic operations on 'MultiNumber' objects, which can represent multiple possible numbers and how each could be obtained. This approach removes some of the repetition of the obvious brute-force method. However, it cannot currently concatenate digits...
Source: fortytwo.tgz
Package: org.davidmorgan.experimental
Main: org.davidmorgan.experimental.GFortyTwo
Main: org.davidmorgan.experimental.MFortyTwo
Command Line Parameters: a sequence of digits separated by spaces
Copyright (C) 2002-2007 David Morgan -- last modified 18/11/2006 -- 1632 hits -- best viewed with any browser -- valid xhtml -- valid css

