A self-referential challenge
Bennett Todd
bet at dukeac.UUCP
Tue Mar 28 08:59:21 AEST 1989
[
Asks for suggestions on how to make
CRC-computer * >CRC-output
contain correct CRC values for all files -- including
"CRC-output"
]
That's easy, just iterate looking for the fixed point, like so:
touch .CRC-output
finis=0
while test $finis -eq 0
do
CRC-computer * >CRC-output
diff CRC-output >/dev/null && finis=1
cp CRC-output .CRC-output
done
rm .CRC-output
But please, not on my machine:-). Seriously, without an in-depth analysis of
how CRCs behave (which is way, way beyond my abilities) there is no reason
to believe that a fixed point exists; it might fall into a cycle instead
(given any finite number of bits in the CRC, it has to do one or the other).
Unless some mathematician steps forward and waves her magic wand, I expect the
best answer will be to fall back 10 and punt:
CRC-computer * | egrep -v CRC-output >CRC-output
I really liked the question, though.
-Bennett
bet at orion.mc.duke.edu
More information about the Comp.lang.c
mailing list