diff options
| -rw-r--r-- | challenge-192/robert-dicicco/julia/ch-2.jl | 195 | ||||
| -rw-r--r-- | challenge-192/robert-dicicco/raku/ch-2.raku | 183 | ||||
| -rw-r--r-- | challenge-192/robert-dicicco/ruby/ch-2.rb | 219 | ||||
| -rw-r--r-- | stats/pwc-current.json | 150 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 74 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 2548 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 730 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 106 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 34 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 108 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 108 | ||||
| -rw-r--r-- | stats/pwc-summary-211-240.json | 106 | ||||
| -rw-r--r-- | stats/pwc-summary-241-270.json | 30 | ||||
| -rw-r--r-- | stats/pwc-summary-271-300.json | 72 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 52 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 48 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 100 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 620 |
18 files changed, 3040 insertions, 2443 deletions
diff --git a/challenge-192/robert-dicicco/julia/ch-2.jl b/challenge-192/robert-dicicco/julia/ch-2.jl new file mode 100644 index 0000000000..80527dbc7e --- /dev/null +++ b/challenge-192/robert-dicicco/julia/ch-2.jl @@ -0,0 +1,195 @@ +#!/usr/bin/env julia + +#= + +AUTHOR: Robert DiCicco + +DATE: 2022-11-22 + +Challenge 192 Equal Distribution ( Julia ) + + + +You are given a list of integers greater than or equal to zero, @list. + + + +Write a script to distribute the number so that each members are same. If you succeed then print the total moves otherwise print -1. + + + +Please follow the rules (as suggested by Neils van Dijke [2022-11-21 13:00] + + + +1) You can only move a value of '1' per move + +2) You are only allowed to move a value of '1' to a direct neighbor/adjacent cell + +----------------------------------------------- + +SAMPLE OUTPUT + +julia .\EqualDistribution.jl + +Input: @lst = [1, 0, 5] + +[1, 1, 4] + +[1, 2, 3] + +[1, 3, 2] + +[2, 2, 2] + +Output: 4 + + + +Input: @lst = [0, 2, 0] + +Output: -1 + + + +Input: @lst = [0, 3, 0] + +[1, 2, 0] + +[1, 1, 1] + +Output: 2 + +=# + + + +using Printf + + + +lists = [[1,0,5],[0,2,0],[0,3,0]] + +cnt = 1 + + + +function MaxPos( arr ) + + maxv = 0 + + maxpos = -1 + + for x in 1:3 + + if arr[x] > maxv + + maxv = arr[x] + + maxpos = x + + end + + end + + return maxv, maxpos + +end + + + +function MinPos( arr ) + + minv = 9 + + minpos = -1 + + for x in 1:3 + + if (arr[x] < minv) + + minv = arr[x] + + minpos = x + + end + + end + + return minv, minpos + +end + + + +function GetTotalVal(arr) + + sum = 0 + + for x in 1:3 + + sum += arr[x]; + + end + + return sum + +end + + + +function EvenUp(arr) + + global cnt += 1 + + (maxv, maxpos) = MaxPos(arr) + + (minv, minpos) = MinPos(arr) + + if (cnt > 1); + + @printf("%s\n",arr) + + end + + arr[maxpos] -= 1 + + if maxpos == 1 || maxpos == 3 + + arr[2] += 1 + + else + + arr[minpos] += 1 + + end + + if ((arr[1] == arr[2]) && (arr[2] == arr[3])) + + @printf("%s\n",arr) + + @printf("Output: %d\n",cnt) + + println("\n") + + else + + EvenUp(arr) + + end + +end + + + +for lst in lists + + @printf("Input: @lst = %s\n", lst); + + global cnt = 0 + + target = (GetTotalVal(lst) / 3) + + target >= 1 ? EvenUp(lst) : @printf("Output: -1\n\n"); + +end diff --git a/challenge-192/robert-dicicco/raku/ch-2.raku b/challenge-192/robert-dicicco/raku/ch-2.raku new file mode 100644 index 0000000000..95d3d199e3 --- /dev/null +++ b/challenge-192/robert-dicicco/raku/ch-2.raku @@ -0,0 +1,183 @@ +use v6; + +#`{ + + AUTHOR: Robert DiCicco + + DATE: 2022-11-23 + + Challenge 192 Equal Distribution ( Raku ) + + + + You are given a list of integers greater than or equal to zero, @list. + + + + Write a script to distribute the number so that each members are same. If you succeed then print the total moves otherwise print -1. + + + + Please follow the rules (as suggested by Neils van Dijke [2022-11-21 13:00] + + + + 1) You can only move a value of '1' per move + + 2) You are only allowed to move a value of '1' to a direct neighbor/adjacent cell + + ----------------------------------------------- + + SAMPLE OUTPUT + + raku .\EqualDistribution.rk + + Input: @lst = (1 0 5) + + (1 1 4) + + (1 2 3) + + (1 3 2) + + (2 2 2) + + Output: 4 + + + + Input: @lst = (0 2 0) + + Output: -1 + + + + Input: @lst = (0 3 0) + + (1 2 0) + + (1 1 1) + + Output: 2 + + ----------------------------------------------- + +} + + + +my @lists = ([1,0,5], [0,2,0], [0,3,0]); + +my $cnt; + + + +sub MaxPos( @arr ) { + + my $max = 0; + + my $maxpos = -1; + + loop (my $x=0; $x < 3; $x++) { + + if (@arr[$x] > $max) { + + $max = @arr[$x]; + + $maxpos = $x; + + } + + } + + return $max, $maxpos; + +} + + + +sub MinPos( @arr ) { + + my $min = 9; + + my $minpos = -1; + + loop (my $x=0; $x < 3; $x++) { + + if (@arr[$x] < $min) { + + $min = @arr[$x]; + + $minpos = $x; + + } + + } + + return $min, $minpos; + +} + + + +sub GetTotalVal($arr) { + + my $sum = 0; + + for (0 .. 2) -> $i + + { + + $sum += @$arr[$i]; + + } + + return $sum + +} + + + +sub EvenUp( @arr) { + + $cnt++; + + my ($max, $maxpos) = MaxPos(@arr); + + my ($min, $minpos) = MinPos(@arr); + + print "\t(" ~ @arr ~ ")\n" if ($cnt > 1); + + @arr[$maxpos]--; + + ($maxpos == 0) || ($maxpos == 2) ?? @arr[1]++ !! @arr[$minpos]++; + + if ((@arr[0] == @arr[1] == @arr[2])) { + + print "\t(" ~ @arr ~ ")\n"; + + say "Output: $cnt"; + + say " "; + + } else { + + EvenUp(@arr); + + } + +} + + + +for (@lists) -> @lst { + + print("Input: \@lst = (" ~ @lst ~ ")\n"); + + $cnt = 0; + + my $target = (GetTotalVal(@lst) / 3); + + $target >= 1 ?? EvenUp(@lst) !! say "Output: -1\n"; + +} diff --git a/challenge-192/robert-dicicco/ruby/ch-2.rb b/challenge-192/robert-dicicco/ruby/ch-2.rb new file mode 100644 index 0000000000..1947411733 --- /dev/null +++ b/challenge-192/robert-dicicco/ruby/ch-2.rb @@ -0,0 +1,219 @@ +#!/usr/bin/env ruby + +=begin + +AUTHOR: Robert DiCicco + +DATE: 2022-11-22 + +Challenge 192 Equal Distribution ( Ruby ) + + + +You are given a list of integers greater than or equal to zero, @list. + + + +Write a script to distribute the number so that each members are same. If you succeed then print the total moves otherwise print -1. + + + +Please follow the rules (as suggested by Neils van Dijke [2022-11-21 13:00] + + + +1) You can only move a value of '1' per move + +2) You are only allowed to move a value of '1' to a direct neighbor/adjacent cell + + + +SAMPLE OUTPUT + +perl .\EqualDistribution.pl + +Input: @lst = (1 0 5) + + 1 1 4 + + 1 2 3 + + 1 3 2 + + 2 2 2 + +Output: 4 + + + +Input: @lst = (0 2 0) + +Output: -1 + + + +Input: @lst = (0 3 0) + + 1 2 0 + + 1 1 1 + +Output: 2 + + + +----------------------------------------- + +SAMPLE OUTPUT + +ruby .\EqualDistribution.rb + +Input: @lst = [1, 0, 5] + + [1, 1, 4] + + [1, 2, 3] + + [1, 3, 2] + + [2, 2, 2] + +Output: 4 + + + +Input: @lst = [0, 2, 0] + +Output: -1 + + + +Input: @lst = [0, 3, 0] + + [1, 2, 0] + + [1, 1, 1] + +Output: 2 + +----------------------------------------- + +=end + + + +lists = [[1,0,5],[0,2,0],[0,3,0]] + +$cnt = 0 + + + +def MaxPos( arr ) + + maxv = 0 + + maxpos = -1 + + for x in 0..2 do + + #puts "x = #{x}" + + if arr[x] > maxv + + maxv = arr[x] + + maxpos = x + + end + + end + + return maxv, maxpos + +end + + + +def MinPos( arr ) + + minv = 9 + + minpos = -1 + + for x in 0..2 do + + if (arr[x] < minv) + + minv = arr[x] + + minpos = x + + end + + end + + return minv, minpos + +end + + + +def EvenUp(arr) + + $cnt += 1 + + (maxv, maxpos) = MaxPos(arr) + + (minv, minpos) = MinPos(arr) + + puts "\t#{arr}" if ($cnt > 1); + + arr[maxpos] -= 1 + + maxpos == 0 || maxpos == 2 ?(arr[1] += 1) : (arr[minpos] += 1) + + if ((arr[0] == arr[1]) && (arr[1] == arr[2])) + + puts "\t#{arr}" + + puts "Output: #{$cnt}" + + puts " " + + else + + EvenUp(arr) + + end + +end + + + +def GetTotalVal(arr) + + sum = 0 + + (0..2).each { |x| + + sum += arr[x]; + + } + + return sum + +end + + + +lists.each do |lst| + + puts "Input: \@lst = #{lst}"; + + $cnt = 0 + + target = (GetTotalVal(lst) / 3); + + target >= 1 ? EvenUp(lst) : (puts "Output: -1\n"; puts " "); + +end diff --git a/stats/pwc-current.json b/stats/pwc-current.json index e9d75993f7..06dd2fab30 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,57 +1,37 @@ { - "chart" : { - "type" : "column" - }, - "title" : { - "text" : "The Weekly Challenge - 192" - }, "yAxis" : { "title" : { "text" : "Total Solutions" } }, - "legend" : { - "enabled" : 0 + "tooltip" : { + "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>", + "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>", + "followPointer" : 1 }, "xAxis" : { "type" : "category" }, - "plotOptions" : { - "series" : { - "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - }, - "borderWidth" : 0 - } - }, "subtitle" : { - "text" : "[Champions: 15] Last updated at 2022-11-23 10:50:16 GMT" - }, - "tooltip" : { - "followPointer" : 1, - "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>", - "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>" + "text" : "[Champions: 15] Last updated at 2022-11-24 11:15:33 GMT" }, "series" : [ { - "name" : "The Weekly Challenge - 192", - "colorByPoint" : 1, "data" : [ { - "name" : "Dario Mazzeo", "y" : 1, - "drilldown" : "Dario Mazzeo" + "drilldown" : "Dario Mazzeo", + "name" : "Dario Mazzeo" }, { + "name" : "E. Choroba", "drilldown" : "E. Choroba", - "y" : 2, - "name" : "E. Choroba" + "y" : 2 }, { "y" : 2, - "drilldown" : "Humberto Massa", - "name" : "Humberto Massa" + "name" : "Humberto Massa", + "drilldown" : "Humberto Massa" }, { "y" : 3, @@ -59,14 +39,14 @@ "name" : "James Smith" }, { - "drilldown" : "Luca Ferrari", "y" : 8, + "drilldown" : "Luca Ferrari", "name" : "Luca Ferrari" }, { - "drilldown" : "Mark Anderson", "y" : 2, - "name" : "Mark Anderson" + "name" : "Mark Anderson", + "drilldown" : "Mark Anderson" }, { "name" : "Niels van Dijke", @@ -74,48 +54,53 @@ "y" : 2 }, { - "y" : 1, + "name" : "Olivier Delouya", "drilldown" : "Olivier Delouya", - "name" : "Olivier Delouya" + "y" : 1 }, { + "y" : 3, "name" : "Peter Campbell Smith", - "drilldown" : "Peter Campbell Smith", - "y" : 3 + "drilldown" : "Peter Campbell Smith" }, { - "name" : "Robbie Hatley", "drilldown" : "Robbie Hatley", + "name" : "Robbie Hatley", "y" : 2 }, { "drilldown" : "Robert DiCicco", - "y" : 3, - "name" : "Robert DiCicco" + "name" : "Robert DiCicco", + "y" : 4 }, { "y" : 4, - "drilldown" : "Roger Bell_West", - "name" : "Roger Bell_West" + "name" : "Roger Bell_West", + "drilldown" : "Roger Bell_West" }, { - "drilldown" : "Simon Proctor", "y" : 2, + "drilldown" : "Simon Proctor", "name" : "Simon Proctor" }, { - "name" : "Tim Potapov", + "y" : 2, "drilldown" : "Tim Potapov", - "y" : 2 + "name" : "Tim Potapov" }, { - "drilldown" : "W. Luis Mochan", "y" : 3, - "name" : "W. Luis Mochan" + "name" : "W. Luis Mochan", + "drilldown" : "W. Luis Mochan" } - ] + ], + "colorByPoint" : 1, + "name" : "The Weekly Challenge - 192" } ], + "legend" : { + "enabled" : 0 + }, "drilldown" : { "series" : [ { @@ -129,14 +114,14 @@ ] }, { + "name" : "E. Choroba", "id" : "E. Choroba", "data" : [ [ "Perl", 2 ] - ], - "name" : "E. Choroba" + ] }, { "data" : [ @@ -149,6 +134,7 @@ "name" : "Humberto Massa" }, { + "name" : "James Smith", "id" : "James Smith", "data" : [ [ @@ -159,12 +145,10 @@ "Blog", 1 ] - ], - "name" : "James Smith" + ] }, { "name" : "Luca Ferrari", - "id" : "Luca Ferrari", "data" : [ [ "Raku", @@ -174,40 +158,40 @@ "Blog", 6 ] - ] + ], + "id" : "Luca Ferrari" }, { - "name" : "Mark Anderson", "data" : [ [ "Raku", 2 ] ], - "id" : "Mark Anderson" + "id" : "Mark Anderson", + "name" : "Mark Anderson" }, { + "name" : "Niels van Dijke", "id" : "Niels van Dijke", "data" : [ [ "Perl", 2 ] - ], - "name" : "Niels van Dijke" + ] }, { - "id" : "Olivier Delouya", "data" : [ [ "Perl", 1 ] ], + "id" : "Olivier Delouya", "name" : "Olivier Delouya" }, { - "name" : "Peter Campbell Smith", "id" : "Peter Campbell Smith", "data" : [ [ @@ -218,19 +202,22 @@ "Blog", 1 ] - ] + ], + "name" : "Peter Campbell Smith" }, { - "name" : "Robbie Hatley", + "id" : "Robbie Hatley", "data" : [ [ "Perl", 2 ] ], - "id" : "Robbie Hatley" + "name" : "Robbie Hatley" }, { + "name" : "Robert DiCicco", + "id" : "Robert DiCicco", "data" : [ [ "Perl", @@ -238,15 +225,12 @@ ], [ "Raku", - 1 + 2 ] - ], - "id" : "Robert DiCicco", - "name" : "Robert DiCicco" + ] }, { "name" : "Roger Bell_West", - "id" : "Roger Bell_West", "data" : [ [ "Perl", @@ -256,31 +240,31 @@ "Raku", 2 ] - ] + ], + "id" : "Roger Bell_West" }, { + "id" : "Simon Proctor", "data" : [ [ "Raku", 2 ] ], - "id" : "Simon Proctor", "name" : "Simon Proctor" }, { - "name" : "Tim Potapov", "id" : "Tim Potapov", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "Tim Potapov" }, { "name" : "W. Luis Mochan", - "id" : "W. Luis Mochan", "data" : [ [ "Perl", @@ -290,8 +274,24 @@ "Blog", 1 ] - ] + ], + "id" : "W. Luis Mochan" } ] + }, + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } + }, + "chart" : { + "type" : "column" + }, + "title" : { + "text" : "The Weekly Challenge - 192" } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index c85322766d..b27c57b1e1 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,42 +1,16 @@ { - "subtitle" : { - "text" : "Last updated at 2022-11-23 10:50:16 GMT" - }, - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" - }, - "yAxis" : { - "min" : 0, - "title" : { - "text" : null - } + "title" : { + "text" : "The Weekly Challenge Contributions [2019 - 2022]" }, - "xAxis" : { - "type" : "category", - "labels" : { - "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" - } - } + "chart" : { + "type" : "column" }, "legend" : { "enabled" : "false" }, "series" : [ { - "dataLabels" : { - "format" : "{point.y:.0f}", - "color" : "#FFFFFF", - "enabled" : "true", - "rotation" : -90, - "y" : 10, - "align" : "right", - "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" - } - }, + "name" : "Contributions", "data" : [ [ "Blog", @@ -48,16 +22,42 @@ ], [ "Raku", - 5635 + 5636 ] ], - "name" : "Contributions" + "dataLabels" : { + "align" : "right", + "enabled" : "true", + "color" : "#FFFFFF", + "format" : "{point.y:.0f}", + "rotation" : -90, + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + }, + "y" : 10 + } } ], - "chart" : { - "type" : "column" + "subtitle" : { + "text" : "Last updated at 2022-11-24 11:15:33 GMT" }, - "title" : { - "text" : "The Weekly Challenge Contributions [2019 - 2022]" + "yAxis" : { + "title" : { + "text" : null + }, + "min" : 0 + }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + }, + "xAxis" : { + "type" : "category", + "labels" : { + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + } + } } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 11abc5c968..dd62a5458e 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -8,994 +8,10 @@ "borderWidth" : 0 } }, - "title" : { - "text" : "The Weekly Challenge Language" - }, - "chart" : { - "type" : "column" - }, - "series" : [ - { - "data" : [ - { - "drilldown" : "001", - "y" : 161, - "name" : "#001" - }, - { - "name" : "#002", - "y" : 125, - "drilldown" : "002" - }, - { - "y" : 83, - "drilldown" : "003", - "name" : "#003" - }, - { - "name" : "#004", - "drilldown" : "004", - "y" : 99 - }, - { - "y" : 78, - "drilldown" : "005", - "name" : "#005" - }, - { - "y" : 58, - "drilldown" : "006", - "name" : "#006" - }, - { - "drilldown" : "007", - "y" : 65, - "name" : "#007" - }, - { - "drilldown" : "008", - "y" : 78, - "name" : "#008" - }, - { - "name" : "#009", - "drilldown" : "009", - "y" : 76 - }, - { - "name" : "#010", - "y" : 65, - "drilldown" : "010" - }, - { - "y" : 85, - "drilldown" : "011", - "name" : "#011" - }, - { - "name" : "#012", - "drilldown" : "012", - "y" : 89 - }, - { - "name" : "#013", - "y" : 85, - "drilldown" : "013" - }, - { - "name" : "#014", - "y" : 101, - "drilldown" : "014" - }, - { - "name" : "#015", - "drilldown" : "015", - "y" : 99 - }, - { - "drilldown" : "016", - "y" : 71, - "name" : "#016" - }, - { - "name" : "#017", - "y" : 84, - "drilldown" : "017" - }, - { - "name" : "#018", - "y" : 81, - "drilldown" : "018" - }, - { - "y" : 103, - "drilldown" : "019", - "name" : "#019" - }, - { - "name" : "#020", - "drilldown" : "020", - "y" : 101 - }, - { - "y" : 72, - "drilldown" : "021", - "name" : "#021" - }, - { - "name" : "#022", - "y" : 68, - "drilldown" : "022" - }, - { - "name" : "#023", - "y" : 97, - "drilldown" : "023" - }, - { - "drilldown" : "024", - "y" : 75, - "name" : "#024" - }, - { - "drilldown" : "025", - "y" : 59, - "name" : "#025" - }, - { - "y" : 74, - "drilldown" : "026", - "name" : "#026" - }, - { - "drilldown" : "027", - "y" : 62, - "name" : "#027" - }, - { - "y" : 82, - "drilldown" : "028", - "name" : "#028" - }, - { - "name" : "#029", - "y" : 81, - "drilldown" : "029" - }, - { - "y" : 119, - "drilldown" : "030", - "name" : "#030" - }, - { - "name" : "#031", - "y" : 91, - "drilldown" : "031" - }, - { - "name" : "#032", - "y" : 96, - "drilldown" : "032" - }, - { - "name" : "#033", - "drilldown" : "033", - "y" : 112 - }, - { - "name" : "#034", - "drilldown" : "034", - "y" : 66 - }, - { - "drilldown" : "035", - "y" : 66, - "name" : "#035" - }, - { - "name" : "#036", - "y" : 70, - "d |
