diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-02-14 08:03:38 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-02-14 08:03:38 +0000 |
| commit | 6051a217ebf6f4804bf3015fc670971a489aecb0 (patch) | |
| tree | 8bc53d3afbbaf85c73869423c339cef31b2e50b6 | |
| parent | 986b633b77c54044dc1679939a79cdb8d3164a4d (diff) | |
| download | perlweeklychallenge-club-6051a217ebf6f4804bf3015fc670971a489aecb0.tar.gz perlweeklychallenge-club-6051a217ebf6f4804bf3015fc670971a489aecb0.tar.bz2 perlweeklychallenge-club-6051a217ebf6f4804bf3015fc670971a489aecb0.zip | |
- Added solutions by Mark Anderson.
- Added solutions by Lubos Kolouch.
- Added solutions by Luca Ferrari.
- Added solutions by Andrew Shitov.
- Added solutions by W. Luis Mochan.
- Added solutions by Thomas Kohler.
- Added solutions by Matthew Neleigh.
- Added solutions by E. Choroba.
- Added solutions by Carlos Oliveira.
- Added solutions by Robbie Hatley.
26 files changed, 2740 insertions, 2144 deletions
diff --git a/challenge-204/chatgpt/README b/challenge-204/ash/chatgpt/README index 7735e06a24..7735e06a24 100644 --- a/challenge-204/chatgpt/README +++ b/challenge-204/ash/chatgpt/README diff --git a/challenge-204/chatgpt/blog-1.txt b/challenge-204/ash/chatgpt/blog-1.txt index 59e520d49a..59e520d49a 100644 --- a/challenge-204/chatgpt/blog-1.txt +++ b/challenge-204/ash/chatgpt/blog-1.txt diff --git a/challenge-204/chatgpt/blog-2.txt b/challenge-204/ash/chatgpt/blog-2.txt index 8fabcdca67..8fabcdca67 100644 --- a/challenge-204/chatgpt/blog-2.txt +++ b/challenge-204/ash/chatgpt/blog-2.txt diff --git a/challenge-204/chatgpt/raku/ch-1.raku b/challenge-204/ash/chatgpt/raku/ch-1.raku index cbc18bdd63..cbc18bdd63 100644 --- a/challenge-204/chatgpt/raku/ch-1.raku +++ b/challenge-204/ash/chatgpt/raku/ch-1.raku diff --git a/challenge-204/chatgpt/raku/ch-2.raku b/challenge-204/ash/chatgpt/raku/ch-2.raku index 20375d1164..20375d1164 100644 --- a/challenge-204/chatgpt/raku/ch-2.raku +++ b/challenge-204/ash/chatgpt/raku/ch-2.raku diff --git a/challenge-204/eric-cheung/python/ch-1.py b/challenge-204/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..e4399c7369 --- /dev/null +++ b/challenge-204/eric-cheung/python/ch-1.py @@ -0,0 +1,33 @@ +
+def IsMonotone(arrInput):
+
+ bConstantArr = True
+ bMontoneInc = False
+
+ for nLastIndx in range(1, len(arrInput)):
+ if arrInput[nLastIndx - 1] == arrInput[nLastIndx]:
+ continue
+
+ bConstantArr = False
+
+ if arrInput[nLastIndx - 1] < arrInput[nLastIndx]:
+ bMontoneInc = True
+ break
+
+ break
+
+ if bConstantArr:
+ return "1"
+
+ for nLoopIndx in range(nLastIndx + 1, len(arrInput)):
+ if bMontoneInc and arrInput[nLoopIndx - 1] > arrInput[nLoopIndx] or not bMontoneInc and arrInput[nLoopIndx - 1] < arrInput[nLoopIndx]:
+ return "0"
+
+ return "1"
+
+
+## nInputArr = [1, 2, 2, 3] ## Example 1
+## nInputArr = [1, 3, 2] ## Example 2
+nInputArr = [6, 5, 5, 4] ## Example 3
+
+print (IsMonotone(nInputArr))
diff --git a/challenge-204/eric-cheung/python/ch-2.py b/challenge-204/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..5c6194a631 --- /dev/null +++ b/challenge-204/eric-cheung/python/ch-2.py @@ -0,0 +1,32 @@ +
+import numpy as np
+
+## Example 1
+## matrixInput = np.array([[1, 2], [3, 4]])
+## nMatrixReShapeRow = 1
+## nMatrixReShapeCol = 4
+
+## Example 2
+## matrixInput = np.array([[1, 2, 3], [4, 5, 6]])
+## nMatrixReShapeRow = 3
+## nMatrixReShapeCol = 2
+
+## Example 3
+matrixInput = np.array([1, 2])
+nMatrixReShapeRow = 3
+nMatrixReShapeCol = 2
+
+
+nMatrixRow = len(matrixInput)
+
+try:
+ nMatrixCol = len(matrixInput[0])
+except:
+ nMatrixCol = 0
+
+
+if nMatrixRow * nMatrixCol != nMatrixReShapeRow * nMatrixReShapeCol:
+ print ("0")
+else:
+ matrixOutput = matrixInput.reshape(nMatrixReShapeRow, nMatrixReShapeCol)
+ print (matrixOutput)
diff --git a/challenge-204/robert-dicicco/julia/ch-1.jl b/challenge-204/robert-dicicco/julia/ch-1.jl new file mode 100644 index 0000000000..ff3d7727b9 --- /dev/null +++ b/challenge-204/robert-dicicco/julia/ch-1.jl @@ -0,0 +1,101 @@ +#!/usr/bin/env julia + +#= + +----------------------------------------- + +AUTHOR: Robert DiCicco + +DATE : 2023-02-13 + +Challenge 204 Monotonic Array ( Julia ) + +----------------------------------------- + +=# + +using Printf + + + +nums = [[1,2,2,3],[1,3,2],[6,5,5,4]] + + + +function CheckIncreasing(arr, ln) + + cnt = 1 + + while cnt < ln + + arr[cnt + 1] >= arr[cnt] ? (cnt += 1) : (return 0) + + end + + return 1 + +end + + + +function CheckDecreasing(arr, ln) + + cnt = 1 + + while cnt < ln + + arr[cnt + 1] <= arr[cnt] ? (cnt += 1) : (return 0) + + end + + return 1 + +end + + + +for n in nums + + @printf("Input: @nums = %s\n", n) + + len = length(n) + + if (CheckIncreasing(n, len) == 0) && (CheckDecreasing(n,len) == 0) + + println("0") + + end + + if (CheckIncreasing(n, len) == 1) || (CheckDecreasing(n,len) == 1) + + println("1") + + end + +end + + + +#= + +----------------------------------------- + +SAMPLE OUTPUY + +julia .\Monotones.jl + +Input: @nums = [1, 2, 2, 3] + +1 + +Input: @nums = [1, 3, 2] + +0 + +Input: @nums = [6, 5, 5, 4] + +1 + +----------------------------------------- + +=# diff --git a/challenge-204/robert-dicicco/raku/ch-1.raku b/challenge-204/robert-dicicco/raku/ch-1.raku new file mode 100644 index 0000000000..ed98510134 --- /dev/null +++ b/challenge-204/robert-dicicco/raku/ch-1.raku @@ -0,0 +1,91 @@ +#!/usr/bin/env raku + +#`{ + +------------------------------------------------- + +AUTHOR: Robert DiCicco + +DATE : 2023-02-13 + +Challenge 204 Monotonic Array ( Raku ) + +------------------------------------------------- + +} + + + +my @nums = <1 2 2 3>,<1 3 2>,<6 5 5 4>; + + + +sub CheckIncreasing (@arr, $len) { + + my $cnt = 0; + + while $cnt < $len - 1 { + + @arr[$cnt + 1] >= @arr[$cnt] ?? $cnt++ !! return 0; + + } + + return 1; + +} + + + +sub CheckDecreasing (@arr, $len) { + + my $cnt = 0; + + while $cnt < $len - 1 { + + @arr[$cnt + 1] <= @arr[$cnt] ?? $cnt++ !! return 0; + + } + + return 1; + +} + + + +for (@nums) -> @n { + + print "Input: \@nums = (",@n,")\n"; + + my $len = @n.elems; + + say "0" if CheckIncreasing(@n,$len) == 0 and CheckDecreasing(@n,$len) == 0 ; + + say "1" if CheckIncreasing(@n,$len) == 1 or CheckDecreasing(@n,$len) == 1 ; + +} + + + +#`{ + +------------------------------------------------- + +SAMPLE OUTPUT + +raku .\Monotones.rk + +Input: @nums = (1 2 2 3) + +1 + +Input: @nums = (1 3 2) + +0 + +Input: @nums = (6 5 5 4) + +1 + +------------------------------------------------- + +} diff --git a/challenge-204/robert-dicicco/ruby/ch-1.rb b/challenge-204/robert-dicicco/ruby/ch-1.rb new file mode 100644 index 0000000000..5754ba0776 --- /dev/null +++ b/challenge-204/robert-dicicco/ruby/ch-1.rb @@ -0,0 +1,79 @@ +#!/usr/bin/env ruby + +=begin + +AUTHOR: Robert DiCicco + +DATE : 2023-02-13 + +Challenge 204 Monotonic Array ( Raku ) + +=end + + + +nums = [[1,2,2,3],[1,3,2],[6,5,5,4]] + + + +def CheckIncreasing(arr,ln) + + cnt = 0 + + while cnt < ln - 1 + + arr[cnt + 1] >= arr[cnt] ? (cnt += 1) : (return 0) + + end + + return 1 + +end + + def CheckDecreasing(arr,ln) + + cnt = 0 + + while cnt < ln - 1 + + arr[cnt + 1] <= arr[cnt] ? (cnt += 1) : (return 0) + + end + + return 1 + +end + + + +nums.each do |n| + + print("Input: \@nums = #{n}\n") + + len = n.length + + puts("0") if (CheckIncreasing(n,len) == 0) && (CheckDecreasing(n,len) == 0) + + puts("1") if (CheckIncreasing(n,len) == 1) || (CheckDecreasing(n,len) == 1) + +end + + + +=begin + +ruby .\Monotones.rb + +Input: @nums = [1, 2, 2, 3] + +1 + +Input: @nums = [1, 3, 2] + +0 + +Input: @nums = [6, 5, 5, 4] + +1 + +=end diff --git a/stats/pwc-challenge-203.json b/stats/pwc-challenge-203.json new file mode 100644 index 0000000000..8905d07e01 --- /dev/null +++ b/stats/pwc-challenge-203.json @@ -0,0 +1,570 @@ +{ + "tooltip" : { + "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>", + "followPointer" : 1, + "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>" + }, + "xAxis" : { + "type" : "category" + }, + "title" : { + "text" : "The Weekly Challenge - 203" + }, + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } + }, + "subtitle" : { + "text" : "[Champions: 30] Last updated at 2023-02-14 07:56:57 GMT" + }, + "legend" : { + "enabled" : 0 + }, + "drilldown" : { + "series" : [ + { + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Arne Sommer", + "id" : "Arne Sommer" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ], + "name" : "Athanasius", + "id" : "Athanasius" + }, + { + "name" : "BarrOff", + "id" : "BarrOff", + "data" : [ + [ + "Raku", + 2 + ] + ] + }, + { + "name" : "Carlos Oliveira", + "id" : "Carlos Oliveira", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "id" : "Cheok-Yin Fung", + "name" : "Cheok-Yin Fung", + "data" : [ + [ + "Perl", + 1 + ] + ] + }, + { + "id" : "Chicagoist", + "name" : "Chicagoist", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "Colin Crain", + "id" : "Colin Crain" + }, + { + "id" : "Dave Jacoby", + "name" : "Dave Jacoby", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "id" : "David Ferrone", + "name" : "David Ferrone", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "Duncan C. White", + "id" : "Duncan C. White" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "E. Choroba", + "id" : "E. Choroba" + }, + { + "id" : "Flavio Poletti", + "name" : "Flavio Poletti", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "James Smith", + "id" : "James Smith" + }, + { + "data" : [ + [ + "Raku", + 2 + ] + ], + "name" : "Jan Krnavek", + "id" : "Jan Krnavek" + }, + { + "id" : "Jorg Sommrey", + "name" : "Jorg Sommrey", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Kjetil Skotheim", + "name" : "Kjetil Skotheim" + }, + { + "id" : "Laurent Rosenfeld", + "name" : "Laurent Rosenfeld", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "name" : "Luca Ferrari", + "id" : "Luca Ferrari", + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 6 + ] + ] + }, + { + "name" : "Mariano Spadaccini", + "id" : "Mariano Spadaccini", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "id" : "Mark Anderson", + "name" : "Mark Anderson", + "data" : [ + [ + "Raku", + 2 + ] + ] + }, + { + "id" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ], + "id" : "Pip Stuart", + "name" : "Pip Stuart" + }, + { + "name" : "Robbie Hatley", + "id" : "Robbie Hatley", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 1 + ], + [ + "Raku", + 1 + ] + ], + "name" : "Robert DiCicco", + "id" : "Robert DiCicco" + }, + { + "data" : [ + [ + "Raku", + 2 + ] + ], + "name" : "Robert Ransbottom", + "id" : "Robert Ransbottom" + }, + { + "name" : "Roger Bell_West", + "id" : "Roger Bell_West", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "Solathian", + "id" : "Solathian" + }, + { + "id" : "Thomas Kohler", + "name" : "Thomas Kohler", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 1 + ], + [ + "Raku", + 1 + ] + ], + "id" : "Ulrich Rieke", + "name" : "Ulrich Rieke" + }, + { + "name" : "W. Luis Mochan", + "id" : "W. Luis Mochan", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ] + } + ] + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "series" : [ + { + "colorByPoint" : 1, + "name" : "The Weekly Challenge - 203", + "data" : [ + { + "name" : "Arne Sommer", + "y" : 3, + "drilldown" : "Arne Sommer" + }, + { + "drilldown" : "Athanasius", + "y" : 4, + "name" : "Athanasius" + }, + { + "drilldown" : "BarrOff", + "y" : 2, + "name" : "BarrOff" + }, + { + "y" : 2, + "name" : "Carlos Oliveira", + "drilldown" : "Carlos Oliveira" + }, + { + "y" : 1, + "name" : "Cheok-Yin Fung", + "drilldown" : "Cheok-Yin Fung" + }, + { + "drilldown" : "Chicagoist", + "y" : 2, + "name" : "Chicagoist" + }, + { + "name" : "Colin Crain", + "y" : 2, + "drilldown" : "Colin Crain" + }, + { + "y" : 3, + "name" : "Dave Jacoby", + "drilldown" : "Dave Jacoby" + }, + { + "drilldown" : "David Ferrone", + "name" : "David Ferrone", + "y" : 2 + }, + { + "name" : "Duncan C. White", + "y" : 2, + "drilldown" : "Duncan C. White" + }, + { + "drilldown" : "E. Choroba", + "name" : "E. Choroba", + "y" : 2 + }, + { + "drilldown" : "Flavio Poletti", + "name" : "Flavio Poletti", + "y" : 6 + }, + { + "drilldown" : "James Smith", + "name" : "James Smith", + "y" : 3 + }, + { + "y" : 2, + "name" : "Jan Krnavek", + "drilldown" : "Jan Krnavek" + }, + { + "drilldown" : "Jorg Sommrey", + "y" : 2, + "name" : "Jorg Sommrey" + }, + { + "y" : 2, + "name" : "Kjetil Skotheim", + "drilldown" : "Kjetil Skotheim" + }, + { + "drilldown" : "Laurent Rosenfeld", + "y" : 5, + "name" : "Laurent Rosenfeld" + }, + { + "drilldown" : "Luca Ferrari", + "name" : "Luca Ferrari", + "y" : 8 + }, + { + "drilldown" : "Mariano Spadaccini", + "name" : "Mariano Spadaccini", + "y" : 2 + }, + { + "drilldown" : "Mark Anderson", + "y" : 2, + "name" : "Mark Anderson" + }, + { + "drilldown" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith", + "y" : 3 + }, + { + "name" : "Pip Stuart", + "y" : 4, + "drilldown" : "Pip Stuart" + }, + { + "drilldown" : "Robbie Hatley", + "y" : 3, + "name" : "Robbie Hatley" + }, + { + "drilldown" : "Robert DiCicco", + "name" : "Robert DiCicco", + "y" : 2 + }, + { + "drilldown" : "Robert Ransbottom", + "y" : 2, + "name" : "Robert Ransbottom" + }, + { + "drilldown" : "Roger Bell_West", + "y" : 5, + "name" : "Roger Bell_West" + }, + { + "drilldown" : "Solathian", + "name" : "Solathian", + "y" : 2 + }, + { + "drilldown" : "Thomas Kohler", + "name" : "Thomas Kohler", + "y" : 4 + }, + { + "drilldown" : "Ulrich Rieke", + "y" : 2, + "name" : "Ulrich Rieke" + }, + { + "drilldown" : "W. Luis Mochan", + "y" : 3, + "name" : "W. Luis Mochan" + } + ] + } + ], + "chart" : { + "type" : "column" + } +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 4f4472743c..5d1328b5d4 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,17 +1,102 @@ { "subtitle" : { - "text" : "[Champions: 30] Last updated at 2023-02-13 06:32:48 GMT" + "text" : "[Champions: 11] Last updated at 2023-02-14 08:01:05 GMT" + }, + "xAxis" : { + "type" : "category" }, "title" : { - "text" : "The Weekly Challenge - 203" + "text" : "The Weekly Challenge - 204" }, "legend" : { "enabled" : 0 }, + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } + }, + "series" : [ + { + "name" : "The Weekly Challenge - 204", + "data" : [ + { + "drilldown" : "Andrew Shitov", + "name" : "Andrew Shitov", + "y" : 4 + }, + { + "y" : 2, + "name" : "Carlos Oliveira", + "drilldown" : "Carlos Oliveira" + }, + { + "drilldown" : "E. Choroba", + "y" : 2, + "name" : "E. Choroba" + }, + { + "drilldown" : "Lubos Kolouch", + "name" : "Lubos Kolouch", + "y" : 2 + }, + { + "name" : "Luca Ferrari", + "y" : 8, + "drilldown" : "Luca Ferrari" + }, + { + "drilldown" : "Mark Anderson", + "y" : 2, + |
