Maybe hash operations are slow, so let's do away with them :)
#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11152065 use warnings; { my @r2d; @r2d[qw(1 12 2 13 3 34 4 35 5 56 6 57 7)] = qw(1 4 5 9 10 40 50 90 100 400 500 900 1000); use List::Util qw( sum ); sub roman_to_dec3 { sum @r2d[ shift =~ tr/ivxlcdmIVXLCDM/1-71-7/r =~ /5?[67]|3?[45]|1?[2 +3]|1/g ] } } my @testdata = ( qw( XLII LXIX mi cd xcix mdclxvi cdxliv i ii iii iv v vi vii viii ix x xi xii xiii xiv xv) ); for my $r (@testdata) { print "$r: ", roman_to_dec3($r), "\n"; }
In reply to Re: Risque Romantic Rosetta Roman Race
by tybalt89
in thread Risque Romantic Rosetta Roman Race
by eyepopslikeamosquito
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |