Are you testing with 5.6.1? Running test 1 ... Warning: Use of "pop" without parens is ambiguous at strtol.6082 line 2.
#!perl -l
%s=qw(d 100 y 10 t 3 m 6 b 9);%c=map{$_,2+$s++}qw(tw th fo fi si se ei ni);$n=pop." ";while($n=~s/(.+?(m|t|b)\S+(n|d)|.+)\s//){my$a;$_=$1;while(s/((\S\S)(.+?(y|d|n)|\S+))\s//){$a+=($s{$4}||1)*($1=~/z/?0:$c{$2}||1)}$f+=10**$s{$2}*$a}print(join',',grep/./,split/(\d{3})/,$f);
|
Running test 2 ...Unexpected STDOUT: Expected: 1 but got: 0
#!perl -l
%s=qw(d 100 y 10 t 3 m 6 b 9);%c=map{$_,2+$s++}qw(tw th fo fi si se ei ni);$n=pop()." ";while($n=~s/(.+?(m|t|b)\S+(n|d)|.+)\s//){my$a;$_=$1;while(s/((\S\S)(.+?(y|d|n)|\S+))\s//){$a+=($s{$4}||1)*($1=~/z/?0:$c{$2}||1)}$f+=10**$s{$2}*$a}print(join',',grep/./,split/(\d{3})/,$f);
|
#!perl -l
%s=qw(d 2 y 1 t 3 m 6 b 9);map{$$_=2+$s++}qw(tw th fo fi si se ei ni);$_=<>;s/\n/ /;while(s/(.+?(m|t|b)\S+(on|d)|.+)\s//){$n=$1;$p=$2;$f+=10**($s{$p}+$s{$4})*(($1=~/z/?0:$$2||1)+($1=~/ten|([^s]..en|lve)/&&($1?10:9))||0)while$n=~s/((..)(.*?(y|d|n)|\S+))\s//}$_="$_,$1"while$f=~s/(.+?)((...)*)$/$2/;s/ ?,//;print;
|
#!perl -l
%s=qw(d 2 y 1 t 3 m 6 b 9);%c=map{$_,2+$s++}qw(tw th fo fi si se ei ni);$n=<>;$n=~s/\n/ /;while($n=~s/(.+?(m|t|b)\S+(on|d)|.+)\s//){my$a;$_=$1;while(s/((\S\S)(.*?(y|d|n)|\S+))\s//){$a+=($1=~/z/?0:$c{$2}||1)*10**$s{$4};$a+=9 if$1=~/ten/;$a+=10 if$1=~/[^s]..en|lve/}$f+=10**$s{$2}*$a}$m="$m,$1"while$f=~s/(.+?)((...)*)$/$2/;$m=~s/,//;print$m;
|