From 7c08fa9dc330262195c30cd158c14ebdfb59c174 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Thu, 16 Jun 2022 19:04:09 +0100 Subject: - Added solution by Dario Mazzeo. --- challenge-169/dario-mazzeo/README | 1 + challenge-169/dario-mazzeo/perl/ch-1.pl | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 challenge-169/dario-mazzeo/README create mode 100755 challenge-169/dario-mazzeo/perl/ch-1.pl (limited to 'challenge-169') diff --git a/challenge-169/dario-mazzeo/README b/challenge-169/dario-mazzeo/README new file mode 100644 index 0000000000..9ed3e21a7f --- /dev/null +++ b/challenge-169/dario-mazzeo/README @@ -0,0 +1 @@ +Solutions by Dario Mazzeo. diff --git a/challenge-169/dario-mazzeo/perl/ch-1.pl b/challenge-169/dario-mazzeo/perl/ch-1.pl new file mode 100755 index 0000000000..08fbc5a5b7 --- /dev/null +++ b/challenge-169/dario-mazzeo/perl/ch-1.pl @@ -0,0 +1,24 @@ +# Autore: Dario Mazzeo (dmazzeo@ingele.com) +# THE WEEKLY CHALLENGE - 169 +# Task 1: Brilliant Numbers + +my @primi=(2,3,5,7,11,13,17,19,23); +my %ris=(); +my $out=""; + +foreach my $i (@primi){ + foreach my $j (@primi){ + if ($ris{$i*$j}==0 && length($i) eq length($j)){ + $ris{$i*$j}=1; + } + } +} + +my $c=0; +foreach my $i (sort {$a <=> $b} keys %ris){ + if ($c<20){$out.="$i, ";} + $c++; +} + +$out=~s/, $//; +print "$out\n"; \ No newline at end of file -- cgit