aboutsummaryrefslogtreecommitdiff
path: root/challenge-199
diff options
context:
space:
mode:
authorBob Lied <boblied+github@gmail.com>2023-01-14 06:30:38 -0600
committerGitHub <noreply@github.com>2023-01-14 06:30:38 -0600
commita2fcd3539045b5ff54ea81bc6cbec004c0f1fea7 (patch)
tree2891d52ef32c29b32d1b6ee5e40f879c74e1bd18 /challenge-199
parent060e309523bbbf50e6cb9684d858e7059344f31b (diff)
parent70a1571ce4c48f53a1eebc84eddb5c035f88b987 (diff)
downloadperlweeklychallenge-club-a2fcd3539045b5ff54ea81bc6cbec004c0f1fea7.tar.gz
perlweeklychallenge-club-a2fcd3539045b5ff54ea81bc6cbec004c0f1fea7.tar.bz2
perlweeklychallenge-club-a2fcd3539045b5ff54ea81bc6cbec004c0f1fea7.zip
Merge branch 'manwar:master' into master
Diffstat (limited to 'challenge-199')
-rwxr-xr-xchallenge-199/0rir/raku/ch-1.raku68
-rwxr-xr-xchallenge-199/0rir/raku/ch-2.raku94
-rw-r--r--challenge-199/arpad-toth/perl/ch-1.sh15
-rw-r--r--challenge-199/arpad-toth/perl/ch-2.sh11
-rw-r--r--challenge-199/dave-jacoby/blog.txt1
-rw-r--r--challenge-199/dave-jacoby/perl/ch-1.pl34
-rw-r--r--challenge-199/dave-jacoby/perl/ch-2.pl44
-rw-r--r--challenge-199/deadmarshal/c/ch-1.c23
-rw-r--r--challenge-199/deadmarshal/c/ch-2.c29
-rw-r--r--challenge-199/deadmarshal/cpp/ch-1.cpp22
-rw-r--r--challenge-199/deadmarshal/cpp/ch-2.cpp28
-rw-r--r--challenge-199/deadmarshal/d/ch1.d21
-rw-r--r--challenge-199/deadmarshal/d/ch2.d24
-rw-r--r--challenge-199/deadmarshal/lua/ch-1.lua17
-rw-r--r--challenge-199/deadmarshal/lua/ch-2.lua22
-rw-r--r--challenge-199/deadmarshal/modula-3/ch1/src/Ch1.m328
-rw-r--r--challenge-199/deadmarshal/modula-3/ch1/src/m3makefile4
-rw-r--r--challenge-199/deadmarshal/modula-3/ch2/src/Ch2.m335
-rw-r--r--challenge-199/deadmarshal/modula-3/ch2/src/m3makefile3
-rw-r--r--challenge-199/deadmarshal/nelua/ch-1.nelua21
-rw-r--r--challenge-199/deadmarshal/nelua/ch-2.nelua28
-rw-r--r--challenge-199/deadmarshal/oberon/Ch1.Mod36
-rw-r--r--challenge-199/deadmarshal/oberon/Ch2.Mod43
-rw-r--r--challenge-199/deadmarshal/pascal/ch1.pas23
-rw-r--r--challenge-199/deadmarshal/pascal/ch2.pas29
-rw-r--r--challenge-199/deadmarshal/perl/ch-1.pl19
-rw-r--r--challenge-199/deadmarshal/perl/ch-2.pl23
-rw-r--r--challenge-199/deadmarshal/raku/ch-1.raku17
-rw-r--r--challenge-199/deadmarshal/raku/ch-2.raku22
-rwxr-xr-xchallenge-199/e-choroba/perl/ch-1.pl21
-rwxr-xr-xchallenge-199/e-choroba/perl/ch-2.pl28
-rw-r--r--challenge-199/ealvar3z/go/ch-1.go30
-rw-r--r--challenge-199/ealvar3z/python/ch-2.py21
-rwxr-xr-xchallenge-199/feng-chang/raku/ch-1.raku7
-rwxr-xr-xchallenge-199/feng-chang/raku/ch-1a.raku5
-rwxr-xr-xchallenge-199/feng-chang/raku/ch-2.raku9
-rw-r--r--challenge-199/jeanluc2020/blog-1.txt1
-rw-r--r--challenge-199/jeanluc2020/blog-2.txt1
-rwxr-xr-xchallenge-199/jeanluc2020/perl/ch-1.pl44
-rwxr-xr-xchallenge-199/jeanluc2020/perl/ch-2.pl52
-rwxr-xr-xchallenge-199/jo-37/perl/ch-1.pl77
-rwxr-xr-xchallenge-199/jo-37/perl/ch-2.pl85
-rw-r--r--challenge-199/laurent-rosenfeld/blog.txt1
-rw-r--r--challenge-199/laurent-rosenfeld/perl/ch-1.pl19
-rw-r--r--challenge-199/laurent-rosenfeld/perl/ch-2.pl25
-rw-r--r--challenge-199/laurent-rosenfeld/raku/ch-1.raku12
-rw-r--r--challenge-199/laurent-rosenfeld/raku/ch-2.raku23
-rw-r--r--challenge-199/luca-ferrari/blog-1.txt1
-rw-r--r--challenge-199/luca-ferrari/blog-2.txt1
-rw-r--r--challenge-199/luca-ferrari/blog-3.txt1
-rw-r--r--challenge-199/luca-ferrari/blog-4.txt1
-rw-r--r--challenge-199/luca-ferrari/blog-5.txt1
-rw-r--r--challenge-199/luca-ferrari/blog-6.txt1
-rw-r--r--challenge-199/luca-ferrari/postgresql/ch-1.plperl24
-rw-r--r--challenge-199/luca-ferrari/postgresql/ch-1.sql30
-rw-r--r--challenge-199/luca-ferrari/postgresql/ch-2.plperl34
-rw-r--r--challenge-199/luca-ferrari/postgresql/ch-2.sql29
-rw-r--r--challenge-199/luca-ferrari/raku/ch-1.p616
-rw-r--r--challenge-199/luca-ferrari/raku/ch-2.p633
-rw-r--r--challenge-199/mark-anderson/raku/ch-1.raku13
-rw-r--r--challenge-199/mark-anderson/raku/ch-2.raku16
-rwxr-xr-xchallenge-199/perlboy1967/perl/ch-1.pl48
-rwxr-xr-xchallenge-199/perlboy1967/perl/ch-2.pl61
-rw-r--r--challenge-199/peter-campbell-smith/blog.txt1
-rwxr-xr-xchallenge-199/peter-campbell-smith/perl/ch-1.pl43
-rwxr-xr-xchallenge-199/peter-campbell-smith/perl/ch-2.pl57
-rw-r--r--challenge-199/rawleyfowler/README.md4
-rw-r--r--challenge-199/rawleyfowler/raku/ch-1.raku10
-rw-r--r--challenge-199/rawleyfowler/raku/ch-2.raku16
-rw-r--r--challenge-199/robbie-hatley/blog.txt1
-rwxr-xr-xchallenge-199/robbie-hatley/perl/ch-1.pl53
-rwxr-xr-xchallenge-199/robbie-hatley/perl/ch-2.pl69
-rw-r--r--challenge-199/robert-dicicco/julia/ch-1.jl109
-rw-r--r--challenge-199/robert-dicicco/perl/ch-1.pl113
-rw-r--r--challenge-199/robert-dicicco/perl/ch-2.pl119
-rw-r--r--challenge-199/robert-dicicco/python/ch-1.py95
-rw-r--r--challenge-199/robert-dicicco/raku/ch-1.raku103
-rw-r--r--challenge-199/robert-dicicco/raku/ch-2.raku117
-rw-r--r--challenge-199/robert-dicicco/ruby/ch-1.rb107
-rwxr-xr-xchallenge-199/roger-bell-west/javascript/ch-1.js38
-rwxr-xr-xchallenge-199/roger-bell-west/javascript/ch-2.js33
-rw-r--r--challenge-199/roger-bell-west/kotlin/ch-1.kt38
-rw-r--r--challenge-199/roger-bell-west/kotlin/ch-2.kt35
-rwxr-xr-xchallenge-199/roger-bell-west/lua/ch-1.lua39
-rwxr-xr-xchallenge-199/roger-bell-west/lua/ch-2.lua33
-rwxr-xr-xchallenge-199/roger-bell-west/perl/ch-1.pl21
-rwxr-xr-xchallenge-199/roger-bell-west/perl/ch-2.pl27
-rw-r--r--challenge-199/roger-bell-west/postscript/ch-1.ps70
-rw-r--r--challenge-199/roger-bell-west/postscript/ch-2.ps68
-rwxr-xr-xchallenge-199/roger-bell-west/python/ch-1.py27
-rwxr-xr-xchallenge-199/roger-bell-west/python/ch-2.py23
-rwxr-xr-xchallenge-199/roger-bell-west/raku/ch-1.p619
-rwxr-xr-xchallenge-199/roger-bell-west/raku/ch-2.p625
-rwxr-xr-xchallenge-199/roger-bell-west/ruby/ch-1.rb31
-rwxr-xr-xchallenge-199/roger-bell-west/ruby/ch-2.rb32
-rwxr-xr-xchallenge-199/roger-bell-west/rust/ch-1.rs32
-rwxr-xr-xchallenge-199/roger-bell-west/rust/ch-2.rs28
-rw-r--r--challenge-199/roger-bell-west/tests.yaml50
-rw-r--r--challenge-199/spadacciniweb/README1
-rw-r--r--challenge-199/spadacciniweb/perl/ch-1.pl14
-rw-r--r--challenge-199/spadacciniweb/perl/ch-2.pl35
-rw-r--r--challenge-199/steve-g-lynn/blog.txt1
-rwxr-xr-xchallenge-199/steve-g-lynn/perl/ch-1.sh3
-rwxr-xr-xchallenge-199/steve-g-lynn/perl/ch-2.pl17
-rwxr-xr-xchallenge-199/steve-g-lynn/raku/ch-1.sh3
-rwxr-xr-xchallenge-199/steve-g-lynn/raku/ch-2.p613
-rw-r--r--challenge-199/wlmb/blog.txt2
-rwxr-xr-xchallenge-199/wlmb/perl/ch-1.pl12
-rwxr-xr-xchallenge-199/wlmb/perl/ch-1a.pl16
-rwxr-xr-xchallenge-199/wlmb/perl/ch-2.pl17
-rw-r--r--challenge-199/zapwai/perl/ch-1.pl17
-rw-r--r--challenge-199/zapwai/perl/ch-2.pl22
-rw-r--r--challenge-199/zapwai/raku/ch-1.raku15
-rw-r--r--challenge-199/zapwai/raku/ch-2.raku15
-rw-r--r--challenge-199/ziameraj16/java/GoodPairs.java20
115 files changed, 3462 insertions, 2 deletions
diff --git a/challenge-199/0rir/raku/ch-1.raku b/challenge-199/0rir/raku/ch-1.raku
new file mode 100755
index 0000000000..867cc81695
--- /dev/null
+++ b/challenge-199/0rir/raku/ch-1.raku
@@ -0,0 +1,68 @@
+#!/usr/bin/env raku
+# :vim ft=raku sw=4 expandtab # 🦋 ∅ ≡ ∩ ≢ ∈ «␤»
+use v6.d;
+use lib $?FILE.IO.parent(2).add("lib");
+use Test;
+
+=begin comment
+199-1: Good Pairs Submitted by: Mohammad S Anwar
+Given a list of integers, @list, find the total count of Good Pairs.
+A pair (i, j) is called good if list[i] == list[j] and i < j.
+
+Example 1
+Input: @list = (1,2,3,1,1,3)
+Output: 4
+
+4 good pairs found: (0,3) (0,4) (3,4) (2,5)
+
+Example 2
+Input: @list = (1,2,3)
+Output: 0
+
+Example 3
+Input: @list = (1,1,1,1)
+Output: 6
+
+Good pairs are: (0,1) (0,2) (0,3) (1,2) (1,3) (2,3)
+=end comment
+
+multi sub ct-good-pairs( Empty --> 0 ) {}
+multi sub ct-good-pairs( @list --> Int) {
+ #A pair (i, j) is called good if list[i] == list[j] and i < j.
+ my $return = 0;
+ for 0..@list.end -> $i {
+ for $i^..@list.end -> $j {
+ ++ $return if @list[$i] == @list[$j];
+ }
+ }
+ $return;
+}
+
+multi MAIN ( ) {
+ my @Test =
+ [6,6,6,6] => 6,
+ [3,3,3] => 3,
+ [1,1] => 1,
+ [0,] => 0,
+ [0,2,3] => 0,
+ [1,2,1,2] => 2,
+ [1,2,3,1,2,3] => 3,
+ [1,2,9,1,2,9,1,2,9] => 9,
+ [3,4,5,3,4,5,1,2,12,1,2,12,1,2,12] => 12,
+ [12,11,10,3,4,5,3,4,5,1,2,9,1,2,9,1,2,9] => 12,
+ [12,11,10,6,7,8,3,4,5,3,4,5,1,2,9,1,2,9,1,2,9] => 12,
+ ;
+ plan 2 * @Test +1;
+
+ is ct-good-pairs(Empty), 0, '0 <- ' ~ (Empty).raku;
+ for @Test -> $p {
+ is ct-good-pairs( $p.key), $p.value, "$p.value() <- $p.key().raku()";
+ is ct-good-pairs( $p.key.pick(*)), $p.value,
+ "$p.value() <- $p.key().pick(*).Array.raku() shuffle";
+ }
+ done-testing;
+
+ my @list = [12,11,10,3,4,5,3,4,5,1,2,9,1,2,9,1,2,9];
+ say "\nInput: \@list = @list.raku()\nOutput: &ct-good-pairs(@list)";
+ exit;
+}
diff --git a/challenge-199/0rir/raku/ch-2.raku b/challenge-199/0rir/raku/ch-2.raku
new file mode 100755
index 0000000000..562400e230
--- /dev/null
+++ b/challenge-199/0rir/raku/ch-2.raku
@@ -0,0 +1,94 @@
+#!/usr/bin/env raku
+# :vim ft=raku sw=4 expandtab #