aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2023-10-29 23:42:17 +0000
committerGitHub <noreply@github.com>2023-10-29 23:42:17 +0000
commit84bbb97e59da43755cfc05343a81d8d54ba173ec (patch)
tree23dc51b2dc3e15172f26483b0d496430e1eccef5
parentc4a58a2c3a21cfeffe5a04cd41f89b9a23f583f7 (diff)
parentfcd8dfe826ab67e9c19d65337d6736d9e7da6db4 (diff)
downloadperlweeklychallenge-club-84bbb97e59da43755cfc05343a81d8d54ba173ec.tar.gz
perlweeklychallenge-club-84bbb97e59da43755cfc05343a81d8d54ba173ec.tar.bz2
perlweeklychallenge-club-84bbb97e59da43755cfc05343a81d8d54ba173ec.zip
Merge pull request #8963 from adamcrussell/challenge-240
initial commit
-rw-r--r--challenge-240/adam-russell/blog.txt1
-rw-r--r--challenge-240/adam-russell/blog1.txt1
-rw-r--r--challenge-240/adam-russell/perl/ch-1.pl17
-rw-r--r--challenge-240/adam-russell/perl/ch-2.pl16
-rw-r--r--challenge-240/adam-russell/prolog/ch-1.p6
-rw-r--r--challenge-240/adam-russell/prolog/ch-2.p5
6 files changed, 46 insertions, 0 deletions
diff --git a/challenge-240/adam-russell/blog.txt b/challenge-240/adam-russell/blog.txt
new file mode 100644
index 0000000000..8c2f165d9c
--- /dev/null
+++ b/challenge-240/adam-russell/blog.txt
@@ -0,0 +1 @@
+http://www.rabbitfarm.com/cgi-bin/blosxom/perl/2023/10/29 \ No newline at end of file
diff --git a/challenge-240/adam-russell/blog1.txt b/challenge-240/adam-russell/blog1.txt
new file mode 100644
index 0000000000..d7bd8393f3
--- /dev/null
+++ b/challenge-240/adam-russell/blog1.txt
@@ -0,0 +1 @@
+http://www.rabbitfarm.com/cgi-bin/blosxom/prolog/2023/10/29 \ No newline at end of file
diff --git a/challenge-240/adam-russell/perl/ch-1.pl b/challenge-240/adam-russell/perl/ch-1.pl
new file mode 100644
index 0000000000..99ac6c1e84
--- /dev/null
+++ b/challenge-240/adam-russell/perl/ch-1.pl
@@ -0,0 +1,17 @@
+use v5.38;
+##
+# You are given an array of strings and a check string.
+# Write a script to find out if the check string is the acronym of the words in the given
+# array.
+##
+use boolean;
+sub acronym{
+ my($strings, $acronym) = @_;
+ return boolean(join(q//, map {(split //, lc $_)[0]} @{$strings}) eq lc $acronym);
+}
+
+MAIN:{
+ say acronym [qw/Perl Python Pascal/], q/ppp/;
+ say acronym [qw/Perl Raku/], q/rp/;
+ say acronym [qw/Oracle Awk C/], q/oac/;
+} \ No newline at end of file
diff --git a/challenge-240/adam-russell/perl/ch-2.pl b/challenge-240/adam-russell/perl/ch-2.pl
new file mode 100644
index 0000000000..1a28504077
--- /dev/null
+++ b/challenge-240/adam-russell/perl/ch-2.pl
@@ -0,0 +1,16 @@
+use v5.38;
+##
+# You are given an array of integers.
+# Write a script to create an array such that new[i] = old[old[i]] where
+# 0 <= i < new.length.
+##
+sub build_array{
+ push @{$_[0]}, $_[$_[@{$_[0]} + 1] + 1];
+ return $_[0] if @{$_[0]} == @_ - 1;
+ goto __SUB__;
+}
+
+MAIN:{
+ say join q/, /, @{build_array([], 0, 2, 1, 5, 3, 4)};
+ say join q/, /, @{build_array([], 5, 0, 1, 2, 3, 4)};
+} \ No newline at end of file
diff --git a/challenge-240/adam-russell/prolog/ch-1.p b/challenge-240/adam-russell/prolog/ch-1.p
new file mode 100644
index 0000000000..504811e747
--- /dev/null
+++ b/challenge-240/adam-russell/prolog/ch-1.p
@@ -0,0 +1,6 @@
+acronym(Strings, CheckString):-
+ maplist(nth(1), Strings, CheckStringUpperCaseCodes),
+ maplist(char_code, CheckStringUpperCase, CheckStringUpperCaseCodes),
+ maplist(lower_upper, CheckStringLowerCase, CheckStringUpperCase),
+ atom_chars(CheckStringA, CheckStringLowerCase),
+ atom_codes(CheckStringA, CheckString). \ No newline at end of file
diff --git a/challenge-240/adam-russell/prolog/ch-2.p b/challenge-240/adam-russell/prolog/ch-2.p
new file mode 100644
index 0000000000..8ec6b08ca7
--- /dev/null
+++ b/challenge-240/adam-russell/prolog/ch-2.p
@@ -0,0 +1,5 @@
+build_list(_, [], []).
+build_list(Old, [OldH|OldT], [NewH|NewT]):-
+ succ(OldH, I),
+ nth(I, Old, NewH),
+ build_list(Old, OldT, NewT). \ No newline at end of file