aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Jacoby <jacoby.david@gmail.com>2023-09-27 13:44:45 -0400
committerDave Jacoby <jacoby.david@gmail.com>2023-09-27 13:44:45 -0400
commit70d383289a87a38a9fc7cd41febe14602bf1f837 (patch)
treef5263cd9aa5607d7e7ef34d7861e087406fd1622
parent3241d3ec32642e07ec394aedd105251d945c900d (diff)
parent200e728ec7b29b6f1807ed966264407834eb9f92 (diff)
downloadperlweeklychallenge-club-70d383289a87a38a9fc7cd41febe14602bf1f837.tar.gz
perlweeklychallenge-club-70d383289a87a38a9fc7cd41febe14602bf1f837.tar.bz2
perlweeklychallenge-club-70d383289a87a38a9fc7cd41febe14602bf1f837.zip
Merge branch 'master' of https://github.com/manwar/perlweeklychallenge-club
-rwxr-xr-xchallenge-236/e-choroba/perl/ch-1.pl35
-rwxr-xr-xchallenge-236/e-choroba/perl/ch-2.pl32
-rwxr-xr-xchallenge-236/eric-cheung/python/ch-1.py29
-rwxr-xr-xchallenge-236/eric-cheung/python/ch-2.py24
-rw-r--r--challenge-236/jaldhar-h-vyas/blog.txt1
-rwxr-xr-xchallenge-236/jaldhar-h-vyas/perl/ch-1.pl51
-rwxr-xr-xchallenge-236/jaldhar-h-vyas/perl/ch-2.pl26
-rwxr-xr-xchallenge-236/jaldhar-h-vyas/raku/ch-1.raku52
-rwxr-xr-xchallenge-236/jaldhar-h-vyas/raku/ch-2.raku27
-rw-r--r--challenge-236/jeanluc2020/blog-1.txt1
-rw-r--r--challenge-236/jeanluc2020/blog-2.txt1
-rwxr-xr-xchallenge-236/jeanluc2020/perl/ch-1.pl81
-rwxr-xr-xchallenge-236/jeanluc2020/perl/ch-2.pl98
-rwxr-xr-xchallenge-236/jeanluc2020/python/ch-1.py35
-rwxr-xr-xchallenge-236/jeanluc2020/python/ch-2.py34
-rw-r--r--challenge-236/laurent-rosenfeld/blog.txt1
-rw-r--r--challenge-236/laurent-rosenfeld/perl/ch-2.pl20
-rw-r--r--challenge-236/laurent-rosenfeld/raku/ch-2.raku24
-rw-r--r--challenge-236/lubos-kolouch/blog.txt1
-rw-r--r--challenge-236/lubos-kolouch/perl/ch-1.pl40
-rw-r--r--challenge-236/lubos-kolouch/perl/ch-2.pl59
-rw-r--r--challenge-236/lubos-kolouch/python/ch-1.py43
-rw-r--r--challenge-236/lubos-kolouch/python/ch-2.py40
-rw-r--r--challenge-236/lubos-kolouch/raku/ch-1.raku31
-rw-r--r--challenge-236/lubos-kolouch/raku/ch-2.raku34
-rw-r--r--challenge-236/luca-ferrari/blog-1.txt1
-rw-r--r--challenge-236/luca-ferrari/blog-2.txt1
-rw-r--r--challenge-236/luca-ferrari/blog-3.txt1
-rw-r--r--challenge-236/luca-ferrari/blog-4.txt1
-rw-r--r--challenge-236/luca-ferrari/blog-5.txt1
-rw-r--r--challenge-236/luca-ferrari/blog-6.txt1
-rw-r--r--challenge-236/luca-ferrari/postgresql/ch-1.plperl45
-rw-r--r--challenge-236/luca-ferrari/postgresql/ch-1.sql79
-rw-r--r--challenge-236/luca-ferrari/postgresql/ch-2.plperl37
-rw-r--r--challenge-236/luca-ferrari/postgresql/ch-2.sql37
-rw-r--r--challenge-236/luca-ferrari/raku/ch-1.p643
-rw-r--r--challenge-236/luca-ferrari/raku/ch-2.p634
-rw-r--r--challenge-236/mark-anderson/raku/ch-1.raku44
-rw-r--r--challenge-236/mark-anderson/raku/ch-2-slower.raku19
-rw-r--r--challenge-236/mark-anderson/raku/ch-2.raku17
-rw-r--r--challenge-236/peter-campbell-smith/blog.txt1
-rwxr-xr-xchallenge-236/peter-campbell-smith/perl/ch-1.pl70
-rwxr-xr-xchallenge-236/peter-campbell-smith/perl/ch-2.pl54
-rw-r--r--challenge-236/pokgopun/go/ch-1.go110
-rw-r--r--challenge-236/pokgopun/go/ch-2.go92
-rw-r--r--challenge-236/pokgopun/python/ch-1.py77
-rw-r--r--challenge-236/pokgopun/python/ch-2.py80
-rw-r--r--challenge-236/rcmlz/raku/ch-1.raku48
-rw-r--r--challenge-236/rcmlz/raku/ch-2.raku36
-rw-r--r--challenge-236/rcmlz/raku/task-one.rakumod48
-rw-r--r--challenge-236/rcmlz/raku/task-two.rakumod36
-rw-r--r--challenge-236/robert-dicicco/julia/ch-1.jl55
-rw-r--r--challenge-236/robert-dicicco/perl/ch-1.pl56
-rw-r--r--challenge-236/robert-dicicco/powershell/ch-1.psl53
-rw-r--r--challenge-236/robert-dicicco/python/ch-1.py50
-rw-r--r--challenge-236/robert-dicicco/raku/ch-1.raku56
-rw-r--r--challenge-236/robert-dicicco/ruby/ch-1.rb57
-rw-r--r--challenge-236/robert-dicicco/tcl/ch-1.tcl58
-rwxr-xr-xchallenge-236/roger-bell-west/javascript/ch-1.js72
-rwxr-xr-xchallenge-236/roger-bell-west/javascript/ch-2.js54
-rw-r--r--challenge-236/roger-bell-west/kotlin/ch-1.kt72
-rw-r--r--challenge-236/roger-bell-west/kotlin/ch-2.kt54
-rwxr-xr-xchallenge-236/roger-bell-west/lua/ch-1.lua87
-rwxr-xr-xchallenge-236/roger-bell-west/lua/ch-2.lua55
-rwxr-xr-xchallenge-236/roger-bell-west/perl/ch-1.pl59
-rwxr-xr-xchallenge-236/roger-bell-west/perl/ch-2.pl43
-rw-r--r--challenge-236/roger-bell-west/postscript/ch-1.ps221
-rw-r--r--challenge-236/roger-bell-west/postscript/ch-2.ps87
-rwxr-xr-xchallenge-236/roger-bell-west/python/ch-1.py49
-rwxr-xr-xchallenge-236/roger-bell-west/python/ch-2.py40
-rwxr-xr-xchallenge-236/roger-bell-west/raku/ch-1.p656
-rwxr-xr-xchallenge-236/roger-bell-west/raku/ch-2.p641
-rwxr-xr-xchallenge-236/roger-bell-west/ruby/ch-1.rb62
-rwxr-xr-xchallenge-236/roger-bell-west/ruby/ch-2.rb53
-rwxr-xr-xchallenge-236/roger-bell-west/rust/ch-1.rs71
-rwxr-xr-xchallenge-236/roger-bell-west/rust/ch-2.rs69
-rw-r--r--challenge-236/roger-bell-west/scala/ch-1.scala66
-rw-r--r--challenge-236/roger-bell-west/scala/ch-2.scala58
-rw-r--r--challenge-236/roger-bell-west/tests.yaml92
-rwxr-xr-xchallenge-236/ulrich-rieke/cpp/ch-2.cpp38
-rwxr-xr-xchallenge-236/ulrich-rieke/rust/ch-2.rs42
-rwxr-xr-xchallenge-236/wanderdoc/perl/ch-1.pl70
-rwxr-xr-xchallenge-236/wanderdoc/perl/ch-2.pl102
-rw-r--r--challenge-236/wlmb/blog.txt1
-rwxr-xr-xchallenge-236/wlmb/perl/ch-1.pl25
-rwxr-xr-xchallenge-236/wlmb/perl/ch-2.pl15
-rw-r--r--challenge-236/zapwai/perl/ch-1.pl25
-rw-r--r--challenge-236/zapwai/perl/ch-2.pl46
-rw-r--r--stats/pwc-challenge-235.json722
-rw-r--r--stats/pwc-current.json682
-rw-r--r--stats/pwc-language-breakdown-summary.json72
-rw-r--r--stats/pwc-language-breakdown.json1497
-rw-r--r--stats/pwc-leaders.json772
-rw-r--r--stats/pwc-summary-1-30.json40
-rw-r--r--stats/pwc-summary-121-150.json108
-rw-r--r--stats/pwc-summary-151-180.json52
-rw-r--r--stats/pwc-summary-181-210.json54
-rw-r--r--stats/pwc-summary-211-240.json110
-rw-r--r--stats/pwc-summary-241-270.json104
-rw-r--r--stats/pwc-summary-271-300.json118
-rw-r--r--stats/pwc-summary-31-60.json98
-rw-r--r--stats/pwc-summary-61-90.json104
-rw-r--r--stats/pwc-summary-91-120.json98
-rw-r--r--stats/pwc-summary.json716
104 files changed, 6883 insertions, 2507 deletions
diff --git a/challenge-236/e-choroba/perl/ch-1.pl b/challenge-236/e-choroba/perl/ch-1.pl
new file mode 100755
index 0000000000..4d2b2e34be
--- /dev/null
+++ b/challenge-236/e-choroba/perl/ch-1.pl
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use experimental qw( signatures );
+
+sub exact_change(@bills) {
+ my %change = map +($_ => 0), 5, 10;
+ for my $bill (@bills) {
+ if ($bill == 10) {
+ return unless $change{5}--;
+
+ } elsif ($bill == 20) {
+ # First try to return 10 + 5, we might need 5s later.
+ if ($change{10} && $change{5}) {
+ --$change{$_} for 5, 10;
+ } elsif ($change{5} > 2) {
+ $change{5} -= 3;
+ } else {
+ return
+ }
+ next # 20s are never returned.
+ }
+
+ ++$change{$bill};
+ }
+ return 1
+}
+
+use Test::More tests => 3 + 1;
+
+ok exact_change(5, 5, 5, 10, 20), 'Example 1';
+ok ! exact_change(5, 5, 10, 10, 20), 'Example 2';
+ok exact_change(5, 5, 5, 20), 'Example 3';
+
+ok exact_change(5, 5, 5, 5, 10, 20, 10), 'Keep the fives';
diff --git a/challenge-236/e-choroba/perl/ch-2.pl b/challenge-236/e-choroba/perl/ch-2.pl
new file mode 100755
index 0000000000..9a06826a7b
--- /dev/null
+++ b/challenge-236/e-choroba/perl/ch-2.pl
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use experimental qw( signatures );
+
+sub array_loops(@ints) {
+ my $count;
+ my @visited;
+ for my $i (0 .. $#ints) {
+ next if $visited[$i];
+
+ # Found a new loop. Visit all the members.
+ ++$count;
+ while (! $visited[$i]) {
+ $visited[$i] = 1;
+ $i = $ints[$i];
+ }
+ }
+ return $count
+}
+
+use Test::More tests => 3;
+
+is array_loops(4, 6, 3, 8, 15, 0, 13, 18, 7, 16, 14, 19, 17, 5, 11,
+ 1, 12, 2, 9, 10),
+ 3, 'Example 1';
+is array_loops(0, 1, 13, 7, 6, 8, 10, 11, 2, 14, 16, 4, 12, 9, 17,
+ 5, 3, 18, 15, 19),
+ 6, 'Example 2';
+is array_loops(9, 8, 3, 11, 5, 7, 13, 19, 12, 4, 14, 10, 18, 2, 16,
+ 1, 0, 15, 6, 17),
+ 1, 'Example 3';
diff --git a/challenge-236/eric-cheung/python/ch-1.py b/challenge-236/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..87c8692ed0
--- /dev/null
+++ b/challenge-236/eric-cheung/python/ch-1.py
@@ -0,0 +1,29 @@
+
+## arrInputBill = [5, 5, 5, 10, 20] ## Example 1
+## arrInputBill = [5, 5, 10, 10, 20] ## Example 2
+arrInputBill = [5, 5, 5, 20] ## Example 3
+
+arrChange = [0, 0, 0]
+bSucceed = True
+
+for nIndx in range(len(arrInputBill)):
+ if arrInputBill[nIndx] == 5:
+ arrChange[0] = arrChange[0] + 1
+ elif arrInputBill[nIndx] == 10:
+ if arrChange[0] < 1:
+ bSucceed = False
+ break
+ arrChange[0] = arrChange[0] - 1
+ arrChange[1] = arrChange[1] + 1
+ elif arrInputBill[nIndx] == 20:
+ if arrChange[0] < 3 and (arrChange[0] < 1 or arrChange[1] < 1):
+ bSucceed = False
+ break
+ arrChange[2] = arrChange[2] + 1
+ if arrChange[1] > 0:
+ arrChange[1] = arrChange[1] - 1
+ arrChange[0] = arrChange[0] - 1
+ else:
+ arrChange[0] = arrChange[0] - 3
+
+print (bSucceed)
diff --git a/challenge-236/eric-cheung/python/ch-2.py b/challenge-236/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..c503507ba1
--- /dev/null
+++ b/challenge-236/eric-cheung/python/ch-2.py
@@ -0,0 +1,24 @@
+
+arrInput = [4, 6, 3, 8, 15, 0, 13, 18, 7, 16, 14, 19, 17, 5, 11, 1, 12, 2, 9, 10] ## Example 1
+## arrInput = [0, 1, 13, 7, 6, 8, 10, 11, 2, 14, 16, 4, 12, 9, 17, 5, 3, 18, 15, 19] ## Example 2
+## arrInput = [9, 8, 3, 11, 5, 7, 13, 19, 12, 4, 14, 10, 18, 2, 16, 1, 0, 15, 6, 17] ## Example 3
+
+arrIndx = [0] * len(arrInput)
+arrOutput = []
+
+for nIndxLoop in range(len(arrIndx)):
+ if arrIndx[nIndxLoop] == 1:
+ continue
+
+ arrTemp = []
+ nTempIndxLoop = nIndxLoop
+
+ while arrInput[nTempIndxLoop] not in arrTemp:
+ arrTemp.append(arrInput[nTempIndxLoop])
+ arrIndx[nTempIndxLoop] = 1
+ nTempIndxLoop = arrInput[nTempIndxLoop]
+
+ arrOutput.append(arrTemp)
+
+## print (arrOutput)
+print (len(arrOutput))
diff --git a/challenge-236/jaldhar-h-vyas/blog.txt b/challenge-236/jaldhar-h-vyas/blog.txt
new file mode 100644
index 0000000000..a4390a3686
--- /dev/null
+++ b/challenge-236/jaldhar-h-vyas/blog.txt
@@ -0,0 +1 @@
+https://www.braincells.com/perl/2023/09/perl_weekly_challenge_week_236.html
diff --git a/challenge-236/jaldhar-h-vyas/perl/ch-1.pl b/challenge-236/jaldhar-h-vyas/perl/ch-1.pl
new file mode 100755
index 0000000000..abd29876b7
--- /dev/null
+++ b/challenge-236/jaldhar-h-vyas/perl/ch-1.pl
@@ -0,0 +1,51 @@
+#!/usr/bin/perl
+use 5.030;
+use warnings;
+use experimental qw/ switch /;
+
+sub nochange {
+ say 'false';
+ exit(0);
+}
+
+my $fives = 0;
+my $tens = 0;
+my $twenties = 0;
+
+for my $bill (@ARGV) {
+ given ($bill) {
+ when (5) {
+ $fives++;
+ }
+
+ when (10) {
+ if ($fives > 0) {
+ $fives--;
+ $tens++;
+ } else {
+ nochange();
+ }
+
+ }
+
+ when (20) {
+ if ($tens > 0 && $fives > 0) {
+ $tens -= 1;
+ $fives -= 1;
+ $twenties += 1;
+ } elsif ($fives > 2) {
+ $fives -= 3;