diff options
| -rw-r--r-- | challenge-083/nunovieira220/perl/ch-1.pl | 14 | ||||
| -rw-r--r-- | challenge-083/nunovieira220/perl/ch-2.pl | 24 |
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 |
