in reply to Risque Romantic Rosetta Roman Race
Grumble... grumble... I hate doing speed optimization...
Golf is at least more logical, with speed opts strange things make a difference.
{ my @rtoa; @rtoa[unpack 'c*', 'MDCLXVImdclxvi'] = (qw(1000 500 100 50 10 5 1)) + x 2; sub roman_to_dec { my $n = 0; $n += $_ - $n % $_ * 2 for @rtoa[ unpack 'c*', shift ]; $n; } }
Faster than the reduce version, and faster than the uc(shift) version...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Risque Romantic Rosetta Roman Race - MCE Array ForLoop
by marioroy (Prior) on May 13, 2023 at 17:40 UTC |