Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Hospelian Arabic to Roman Transform (HART) shortened

4 views
Skip to first unread message

Andrew Savige

unread,
Dec 25, 2012, 2:04:21 AM12/25/12
to go...@perl.org
Continuing the thread from Jan 2007 after more than five years,
the famous "Hospelian Arabic to Roman Transform" aka HART, as
played by Ton in the Fonality Christmas golf challenge, has been
shortened by one stroke by primo. Test program showing Ton's two
original HART magic formulae and primo's improvement follows:

use strict;
use Roman;

sub ton1 { my $t = shift; my $s;
($s.=4x$_%1859^7)=~y/IVCXL91-80/XLMCDXVIII/d
for $t=~/./g; return $s }

sub ton2 { my $t = shift; my $s;
($s.=5x$_*8%29628)=~y/IVCXL426(-:/XLMCDIVX/d
for $t=~/./g; return $s }

sub pmo1 { my $t = shift; my $s;
($s.="32e$_"%72726)=~y/CLXVI60-9/MDCLXVIX/d
for $t=~/./g; return $s }

sub pmo2 { my $t = shift; my $s;
($s.="57e$_"%474976)=~y/CLXVI0-9/MDCLXIXV/d
for $t=~/./g; return $s }

for my $i (1..3999) {
    my $r  = uc roman($i);
    my $t1 = ton1($i);
    my $t2 = ton2($i);
    my $p1 = pmo1($i);
    my $p2 = pmo2($i);
    print "$i: $r\n";
    $r eq $t1 or die "t1: expected '$r' got '$t1'\n";
    $r eq $t2 or die "t2: expected '$r' got '$t2'\n";
    $r eq $p1 or die "p1: expected '$r' got '$p1'\n";
    $r eq $p2 or die "p2: expected '$r' got '$p2'\n";
}
print "all tests successful\n";

For more details: http://perlmonks.org/?node_id=1009126

/-\

Yanick Champoux

unread,
Jan 2, 2013, 4:25:59 PM1/2/13
to Andrew Savige, go...@perl.org
On 12-12-25 02:04 AM, Andrew Savige wrote:
> Continuing the thread from Jan 2007 after more than five years,
> the famous "Hospelian Arabic to Roman Transform" aka HART, as
> played by Ton in the Fonality Christmas golf challenge, has been
> shortened by one stroke by primo.

Holy schmolee. I now have this mental image of primo looking at his
monitor, dust gathering in the deep frown above his staring eyes, as the
five years trickle by, until the moment he went 'ah AH!', and shaved
that byte off the prior solution...

Well done,
`/anick
0 new messages