develooper Front page | perl.golf | Postings from January 2007

Re: New Golf

Thread Previous | Thread Next
From:
perl-golf
Date:
January 7, 2007 04:56
Subject:
Re: New Golf
Message ID:
enqqle$v8$1@post.home.lunix
In article <20070105044300.67149.qmail@web56410.mail.re3.yahoo.com>,
	Andrew Savige <ajsavige@yahoo.com.au> writes:
> You might call this "golfing the post mortem" ... speaking of which,
> I bet Ton is still searching for that elusive 98. :-)
>
Nah, I'm not. I'm reasonably confident that the magic formula is
optimal for a one shot number to roman (though I did find a
previously unknown formula that's only one stroke longer) ,
and that the way to use that to solve the problem is also shortest.
(I also realized in the mean time that my range optimizer program
is incomplete, but I don't think it matters for this problem)

The thing I most seriously looked into is that in building the lookup
table i use the magic formula to for number to roman without using the
rest of the table. That seems a waste of a lot of already available
information.

e.g. if you count forward, you can imagine converting number ddddD
by doing:   ($lookup{ddddD} = $lookup{dddd} . magic(D)) =~ y///
where the y/// shifts by one (probably using a for instead of =~ ).

Or maybe not even go through numbers:
  $lookup{$num++} = ripple_carry($accu .= "I")

The s/.//eg loop to convert by digit however is so efficient that I
found nothing to beat it. I'm not very convinced it can't be beaten
though.
--
Help bring about world peace. Kill a fanatic today!

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About