Re: Enigma 1362 - Eight-fifths
- From: Richard Heathfield <invalid@xxxxxxxxxxxxxxx>
- Date: Sun, 20 Nov 2005 21:02:36 +0000 (UTC)
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)
.
- Follow-Ups:
- Re: Enigma 1362 - Eight-fifths
- From: Mark Brader
- Re: Enigma 1362 - Eight-fifths
- From: Mark Brader
- Re: Enigma 1362 - Eight-fifths
- References:
- Enigma 1362 - Eight-fifths
- From: petergregorychapman
- Re: Enigma 1362 - Eight-fifths
- From: petergregorychapman
- Re: Enigma 1362 - Eight-fifths
- From: pappu pager
- Re: Enigma 1362 - Eight-fifths
- From: Richard Heathfield
- Re: Enigma 1362 - Eight-fifths
- From: Mark Brader
- Enigma 1362 - Eight-fifths
- Prev by Date: Re: Qwyzzle: Level 49
- Next by Date: Re: Help!
- Previous by thread: Re: Enigma 1362 - Eight-fifths
- Next by thread: Re: Enigma 1362 - Eight-fifths
- Index(es):
Relevant Pages
|