aboutsummaryrefslogtreecommitdiff
path: root/challenge-179
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2022-08-22 15:41:21 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2022-08-22 15:41:21 +0100
commit62519b42ee44971ea14b6df5a768665fd6c6bd36 (patch)
tree859596c06cd9be75e789757c06eb41d5cb870791 /challenge-179
parent3302b7131a13da61a8bb4392a16b28b590c0c745 (diff)
downloadperlweeklychallenge-club-62519b42ee44971ea14b6df5a768665fd6c6bd36.tar.gz
perlweeklychallenge-club-62519b42ee44971ea14b6df5a768665fd6c6bd36.tar.bz2
perlweeklychallenge-club-62519b42ee44971ea14b6df5a768665fd6c6bd36.zip
- Added solution by Dario Mazzeo.
Diffstat (limited to 'challenge-179')
-rwxr-xr-xchallenge-179/dario-mazzeo/perl/ch-1.pl52
1 files changed, 52 insertions, 0 deletions
diff --git a/challenge-179/dario-mazzeo/perl/ch-1.pl b/challenge-179/dario-mazzeo/perl/ch-1.pl
new file mode 100755
index 0000000000..6a09035b3b
--- /dev/null
+++ b/challenge-179/dario-mazzeo/perl/ch-1.pl
@@ -0,0 +1,52 @@
+# THE WEEKLY CHALLENGE - 179
+# Task 1: Ordinal Number Spelling
+# Autore: Dario Mazzeo
+
+my $n=$ARGV[0];
+print NumeroInTesto($n);
+exit;
+
+
+sub NumeroInTesto{
+ my $n=$_[0];
+
+ if (length($n)==1){
+ if ($n==0){return "";}
+ elsif ($n==1){return "uno";}
+ elsif ($n==2){return "due";}
+ elsif ($n==3){return "tre";}
+ elsif ($n==4){return "quattro";}
+ elsif ($n==5){return "cinque";}
+ elsif ($n==6){return "sei";}
+ elsif ($n==7){return "sette";}
+ elsif ($n==8){return "otto";}
+ elsif ($n==9){return "nove";}
+ }
+ elsif (length($n)==2){
+ if ($n==10){return "dieci";}
+ elsif ($n==11){return "undici";}
+ elsif ($n==12){return "dodici";}
+ elsif ($n==13){return "tredici";}
+ elsif ($n==14){return "quattordici";}
+ elsif ($n==15){return "quindici";}
+ elsif ($n==16){return "sedici";}
+ elsif ($n==17){return "diciassette";}
+ elsif ($n==18){return "diciotto";}
+ elsif ($n==19){return "diciannove";}
+
+ my $n1=substr($n,0,1);
+ my $str="";
+ if ($n1==2){$str="venti";}
+ elsif ($n1==3){$str="trenta";}
+ elsif ($n1==4){$str="quaranta";}
+ elsif ($n1==5){$str="cinquanta";}
+ elsif ($n1==6){$str="sessanta";}
+ elsif ($n1==7){$str="settanta";}
+ elsif ($n1==8){$str="ottanta";}
+ elsif ($n1==9){$str="novanta";}
+
+ my $str=$str.(NumeroInTesto(substr($n,1,1)));
+ $str=~s/[ia]([uo])/$1/;
+ return $str;
+ }
+} \ No newline at end of file