aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNuno Vieira <nunovieira220@gmail.com>2020-10-21 20:47:17 +0100
committerNuno Vieira <nunovieira220@gmail.com>2020-10-21 20:47:17 +0100
commit7793bc662990cc8e4ee41a40dee90782cd82aa5f (patch)
tree69daa12d6bbbd3e1954fa5f62a6c36b4633e1c5e
parent4ac8964e99ddcddbb76e7ad6486737472264637a (diff)
downloadperlweeklychallenge-club-7793bc662990cc8e4ee41a40dee90782cd82aa5f.tar.gz
perlweeklychallenge-club-7793bc662990cc8e4ee41a40dee90782cd82aa5f.tar.bz2
perlweeklychallenge-club-7793bc662990cc8e4ee41a40dee90782cd82aa5f.zip
Add nunovieira220 perl solution to challenge 083
-rw-r--r--challenge-083/nunovieira220/perl/ch-1.pl14
-rw-r--r--challenge-083/nunovieira220/perl/ch-2.pl24
2 files changed, 38 insertions, 0 deletions
diff --git a/challenge-083/nunovieira220/perl/ch-1.pl b/challenge-083/nunovieira220/perl/ch-1.pl
new file mode 100644
index 0000000000..869f26be00
--- /dev/null
+++ b/challenge-083/nunovieira220/perl/ch-1.pl
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use feature qw(say);
+
+# Input
+my $S = "The purpose of our lives is to be happy";
+
+# Output
+$S =~ s/^[^\s]+\s(.*)\s[^\s]+$/$1/;
+$S =~ s/\s//g;
+
+say length($S); \ No newline at end of file
diff --git a/challenge-083/nunovieira220/perl/ch-2.pl b/challenge-083/nunovieira220/perl/ch-2.pl
new file mode 100644
index 0000000000..4ac4eefaec
--- /dev/null
+++ b/challenge-083/nunovieira220/perl/ch-2.pl
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use feature qw(say);
+
+# Input
+my @A = (3, 10, 8);
+
+# Flip Array
+my @sums = (0);
+
+for my $val (@A) {
+ my @arr = ();
+
+ push @arr, ($_ + $val, $_ - $val) for (@sums);
+
+ @sums = @arr;
+}
+
+my @res = grep { $_ >= 0 } sort { $a <=> $b } @sums;
+
+# Output
+say $res[0]; \ No newline at end of file