aboutsummaryrefslogtreecommitdiff
path: root/challenge-251
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2024-01-08 19:15:36 +0000
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2024-01-08 19:15:36 +0000
commitda0d5dcf50f8fa8def91abaafce1fd5624ec1a61 (patch)
tree48d62d167588ce05b7ad7e5e2b321355d81a3f0f /challenge-251
parent066a38cc3004d179463b4c3cd5feb18b042ad36f (diff)
downloadperlweeklychallenge-club-da0d5dcf50f8fa8def91abaafce1fd5624ec1a61.tar.gz
perlweeklychallenge-club-da0d5dcf50f8fa8def91abaafce1fd5624ec1a61.tar.bz2
perlweeklychallenge-club-da0d5dcf50f8fa8def91abaafce1fd5624ec1a61.zip
i- Added solutions by Mark Anderson.
- Added solutions by PokGoPun. - Added solutions by Simon Proctor. - Added solutions by Luca Ferrari. - Added solutions by Thomas Kohler. - Added solutions by Peter Campbell Smith. - Added solutions by Niels van Dijke. - Added solutions by W. Luis Mochan. - Added solutions by David Ferrone. - Added solutions by Dave Jacoby. - Added solutions by Peter Meszaros. - Added solutions by Laurent Rosenfeld.
Diffstat (limited to 'challenge-251')
-rw-r--r--challenge-251/laurent-rosenfeld/blog.txt1
-rw-r--r--challenge-251/laurent-rosenfeld/perl/ch-1.pl18
-rw-r--r--challenge-251/laurent-rosenfeld/raku/ch-1.raku13
-rwxr-xr-xchallenge-251/perlboy1967/perl/ch-1.pl (renamed from challenge-251/perlboy1967/perl/ch1.pl)0
-rwxr-xr-xchallenge-251/perlboy1967/perl/ch-2.pl (renamed from challenge-251/perlboy1967/perl/ch2.pl)0
5 files changed, 32 insertions, 0 deletions
diff --git a/challenge-251/laurent-rosenfeld/blog.txt b/challenge-251/laurent-rosenfeld/blog.txt
new file mode 100644
index 0000000000..312e6abc5b
--- /dev/null
+++ b/challenge-251/laurent-rosenfeld/blog.txt
@@ -0,0 +1 @@
+https://blogs.perl.org/users/laurent_r/2024/01/perl-weekly-challenge-251-concatenation-value.html
diff --git a/challenge-251/laurent-rosenfeld/perl/ch-1.pl b/challenge-251/laurent-rosenfeld/perl/ch-1.pl
new file mode 100644
index 0000000000..8ff2ab1549
--- /dev/null
+++ b/challenge-251/laurent-rosenfeld/perl/ch-1.pl
@@ -0,0 +1,18 @@
+use strict;
+use warnings;
+use feature 'say';
+
+sub concat_vals {
+ my @in = @_;
+ my $concat;
+ while (@in > 1) {
+ $concat += (shift @in) . (pop @in);
+ }
+ $concat += shift @in if @in > 0; # if we have 1 item left
+ return $concat;
+}
+
+for my $test ([<6 12 25 1>], [<10 7 31 5 2 2>], [<1 2 10>]) {
+ printf "%-15s => ", "@$test";
+ say concat_vals @$test;
+}
diff --git a/challenge-251/laurent-rosenfeld/raku/ch-1.raku b/challenge-251/laurent-rosenfeld/raku/ch-1.raku
new file mode 100644
index 0000000000..341957a396
--- /dev/null
+++ b/challenge-251/laurent-rosenfeld/raku/ch-1.raku
@@ -0,0 +1,13 @@
+sub concat-vals (@in is copy) {
+ my $concat;
+ while @in.elems > 1 {
+ $concat += @in.shift ~ @in.pop;
+ }
+ $concat += shift @in if @in.elems > 0; # last item if any
+ return $concat;
+}
+
+for <6 12 25 1>, <10 7 31 5 2 2>, <1 2 10> -> @test {
+ printf "%-15s => ", "@test[]";
+ say concat-vals @test;
+}
diff --git a/challenge-251/perlboy1967/perl/ch1.pl b/challenge-251/perlboy1967/perl/ch-1.pl
index 57f97135fc..57f97135fc 100755
--- a/challenge-251/perlboy1967/perl/ch1.pl
+++ b/challenge-251/perlboy1967/perl/ch-1.pl
diff --git a/challenge-251/perlboy1967/perl/ch2.pl b/challenge-251/perlboy1967/perl/ch-2.pl
index 60cd0517ed..60cd0517ed 100755
--- a/challenge-251/perlboy1967/perl/ch2.pl
+++ b/challenge-251/perlboy1967/perl/ch-2.pl