Re: Hamming minigolf post mortem

[email protected] (Ronald J Kimball)
Newsgroups perl.golf
Message-ID <[email protected]>
On Sat, Apr 19, 2003 at 08:51:45PM +0300, Juho Snellman wrote:
> On Sat, Apr 19, 2003 at 05:29:23PM +0200, Peter Makholm wrote:
> > Daniel Tuijnman <[email protected]> writes: 
> > > I was quite surprised to see such a clean and elegant algorithm as your
> > > 67 post-mortem reach so high. No Perl trickery at all going on here!
> > 
> > I'm surprised to see that we were only two trying to delete exchange
> > <=> for a simple > in the sorting. By the documentation is isn't
> > guaranteed to work but that doesn't usually stop golfers.
> 
> Attempting != succeeding. The > doesn't work reliably when you're
> interested in any elements except the smallest one. I tried >, found
> out that it didn't work, and moved on. Probably others did too.

sort { $a > $b } @list doesn't even work reliably when you're only
interested in the smallest element.  Consider sorting a list containing two
elements, 1 and 3.  The outcome will depend on which value is used as $a
and which as $b.  3 > 1 will return 1, and the result will be (1, 3).  1 >
3, however, will return 0, and the result could be either (1, 3) or (3, 1)!

Any solution which depends on a specific result from such a construct will
almost certainly fail on other implementations of sort.

Ronald
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.