Re: Enigma 1362 - Eight-fifths



Mark Brader said:

> I couldn't see anything intelligent
> to be done except the same enumeration of possibilities that Richard
> came up with. If that *is* the only way to reach the answer, then
> I'm instead inclined to complain that the puzzle isn't interesting.

I'm inclined to agree. I am guessing that whoever decides on which puzzle to
use had had a bit of a night out and a splitting headache, and just pulled
one at random out of a hatful of emergency stand-by puzzles.

> But if Richard used C, then I bet my program was shorter and easier
> to write:
>
> sub canon { return join("", sort split(//, $_[0])); }
> for ($i = 1; canon(5*$i) ne canon(8*$i); ++$i) { }
> print 5*$i, " mi = ", 8*$i, " km\n";

I don't know about "easier to write" - I encountered no difficulties in the
C version. I will agree, however, that yours is shorter. It is in the
nature of low-level languages that sometimes they lack high-level features
(such as 'split'). I tried briefly to hack up a shorter C version by
bending the rules a bit, but I couldn't quite manage it.

I note with some satisfaction, however, that your program took about six
times as long as mine to run. And 17 milliseconds saved is well worth the
extra few seconds it took to type the extra characters in my source file.

;-)

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
.



Relevant Pages

  • Re: Longest word in Chinese
    ... >>> characters and meaning Montserrat. ... Richard> And how could it be shorter than the transliteration of ... That's still shorter than: ... Krungthepmahanakornamornratanakosinmahintarayutthayamahadilokphopnopparatrajathaniburiromudomrajaniwesmahasatharnamornphimarnavatarnsathitsakkattiyavisanukamprasit ...
    (sci.lang)
  • Re: Help from fellow Fortran Users
    ... > I think the only cases he actually spoke of were for shorter actual ... > arguments than dummies, Richard. ...
    (comp.lang.fortran)
  • Re: Longest word in Chinese
    ... Richard> And how could it be shorter than the transliteration of ... That's still shorter than: ... Krungthepmahanakornamornratanakosinmahintarayutthayamahadilokphopnoppar ...
    (sci.lang)
  • Re: Enigma 1362 - Eight-fifths
    ... >> After I'd eliminated all the three-digit solutions, ... >> program which gave me the answer in about three milliseconds. ... > to be done except the same enumeration of possibilities that Richard ... > I'm instead inclined to complain that the puzzle isn't interesting. ...
    (rec.puzzles)
  • Re: Enigma 1362 - Eight-fifths
    ... > to be done except the same enumeration of possibilities that Richard ... > I'm instead inclined to complain that the puzzle isn't interesting. ... Back when ZX 81s and ZX Spectra were the only affordable computers, ... If a religion is defined to be a system of ideas that contains unprovable ...
    (rec.puzzles)