From ec32f16e0c30775744311254eaf203a8c559256b Mon Sep 17 00:00:00 2001 From: sergio Date: Mon, 8 Apr 2019 17:15:46 +0200 Subject: Added sergiotarxz solutions --- challenge-003/sergiotarxz/ch-1.pl | 9 +++++++++ challenge-003/sergiotarxz/ch-2.pl | 10 ++++++++++ 2 files changed, 19 insertions(+) create mode 100644 challenge-003/sergiotarxz/ch-1.pl create mode 100644 challenge-003/sergiotarxz/ch-2.pl diff --git a/challenge-003/sergiotarxz/ch-1.pl b/challenge-003/sergiotarxz/ch-1.pl new file mode 100644 index 0000000000..e16fb7dea4 --- /dev/null +++ b/challenge-003/sergiotarxz/ch-1.pl @@ -0,0 +1,9 @@ +use v5.28; +my @a = (2,3,5); +for my $i (1..$ARGV[0]) { + my $a = $i; + for (@a) { + $a/=$_ while $a%$_==0; + } + $a==1 and say $i; +} diff --git a/challenge-003/sergiotarxz/ch-2.pl b/challenge-003/sergiotarxz/ch-2.pl new file mode 100644 index 0000000000..e08c0b10d5 --- /dev/null +++ b/challenge-003/sergiotarxz/ch-2.pl @@ -0,0 +1,10 @@ +$ARGV[0] > 2 or die "This program requires at least 3 rows to work"; +for (my $i = 1; $i<=$ARGV[0]; $i++) { + my $c = 1; + print " "x($ARGV[0]-$i); + for (my $e = 1; $e<=$i; $e++) { + print "$c "; + $c = int($c*($i-$e)/$e); + } + print "\n"; +} -- cgit From 094aab5236b5e74d1860362f7de3b6f7267a4825 Mon Sep 17 00:00:00 2001 From: sergio Date: Mon, 8 Apr 2019 17:23:36 +0200 Subject: Corrected directories --- challenge-003/sergiotarxz/ch-1.pl | 9 --------- challenge-003/sergiotarxz/ch-2.pl | 10 ---------- challenge-003/sergiotarxz/perl5/ch-1.pl | 9 +++++++++ challenge-003/sergiotarxz/perl5/ch-2.pl | 10 ++++++++++ 4 files changed, 19 insertions(+), 19 deletions(-) delete mode 100644 challenge-003/sergiotarxz/ch-1.pl delete mode 100644 challenge-003/sergiotarxz/ch-2.pl create mode 100644 challenge-003/sergiotarxz/perl5/ch-1.pl create mode 100644 challenge-003/sergiotarxz/perl5/ch-2.pl diff --git a/challenge-003/sergiotarxz/ch-1.pl b/challenge-003/sergiotarxz/ch-1.pl deleted file mode 100644 index e16fb7dea4..0000000000 --- a/challenge-003/sergiotarxz/ch-1.pl +++ /dev/null @@ -1,9 +0,0 @@ -use v5.28; -my @a = (2,3,5); -for my $i (1..$ARGV[0]) { - my $a = $i; - for (@a) { - $a/=$_ while $a%$_==0; - } - $a==1 and say $i; -} diff --git a/challenge-003/sergiotarxz/ch-2.pl b/challenge-003/sergiotarxz/ch-2.pl deleted file mode 100644 index e08c0b10d5..0000000000 --- a/challenge-003/sergiotarxz/ch-2.pl +++ /dev/null @@ -1,10 +0,0 @@ -$ARGV[0] > 2 or die "This program requires at least 3 rows to work"; -for (my $i = 1; $i<=$ARGV[0]; $i++) { - my $c = 1; - print " "x($ARGV[0]-$i); - for (my $e = 1; $e<=$i; $e++) { - print "$c "; - $c = int($c*($i-$e)/$e); - } - print "\n"; -} diff --git a/challenge-003/sergiotarxz/perl5/ch-1.pl b/challenge-003/sergiotarxz/perl5/ch-1.pl new file mode 100644 index 0000000000..d4dedb814f --- /dev/null +++ b/challenge-003/sergiotarxz/perl5/ch-1.pl @@ -0,0 +1,9 @@ +use v5.28; +my @a = (2,3,5); +for (my $i=1; $i<$ARGV[0]; $i++) { + my $a = $i; + for (@a) { + $a/=$_ until $a%$_; + } + $a==1 and say $i; +} diff --git a/challenge-003/sergiotarxz/perl5/ch-2.pl b/challenge-003/sergiotarxz/perl5/ch-2.pl new file mode 100644 index 0000000000..e08c0b10d5 --- /dev/null +++ b/challenge-003/sergiotarxz/perl5/ch-2.pl @@ -0,0 +1,10 @@ +$ARGV[0] > 2 or die "This program requires at least 3 rows to work"; +for (my $i = 1; $i<=$ARGV[0]; $i++) { + my $c = 1; + print " "x($ARGV[0]-$i); + for (my $e = 1; $e<=$i; $e++) { + print "$c "; + $c = int($c*($i-$e)/$e); + } + print "\n"; +} -- cgit