diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-01-02 21:03:27 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-01-02 21:03:27 +0000 |
| commit | 79335458f4f82deed9d4caca0f563fd7adfbb276 (patch) | |
| tree | 9f22b050ef42f61cdef338bd3d4ff455f71e5128 | |
| parent | 00cc4d779f1fdbdd6a22b1c029f2fbdc857ff132 (diff) | |
| download | perlweeklychallenge-club-79335458f4f82deed9d4caca0f563fd7adfbb276.tar.gz perlweeklychallenge-club-79335458f4f82deed9d4caca0f563fd7adfbb276.tar.bz2 perlweeklychallenge-club-79335458f4f82deed9d4caca0f563fd7adfbb276.zip | |
- Added solutions by Robert DiCicco.
| -rw-r--r-- | challenge-198/robert-dicicco/julia/ch-2.jl | 69 | ||||
| -rw-r--r-- | challenge-198/robert-dicicco/perl/ch-2.pl | 75 | ||||
| -rw-r--r-- | challenge-198/robert-dicicco/python/ch-2.py | 81 | ||||
| -rw-r--r-- | challenge-198/robert-dicicco/raku/ch-2.raku | 65 | ||||
| -rw-r--r-- | challenge-198/robert-dicicco/ruby/ch-2.rb | 73 | ||||
| -rw-r--r-- | challenge-198/ziameraj16/java/PrimeCount.java | 37 | ||||
| -rw-r--r-- | stats/pwc-current.json | 117 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 80 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 1250 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 360 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 126 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 30 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 88 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 90 | ||||
| -rw-r--r-- | stats/pwc-summary-211-240.json | 32 | ||||
| -rw-r--r-- | stats/pwc-summary-241-270.json | 60 | ||||
| -rw-r--r-- | stats/pwc-summary-271-300.json | 44 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 38 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 110 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 42 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 54 |
21 files changed, 1670 insertions, 1251 deletions
diff --git a/challenge-198/robert-dicicco/julia/ch-2.jl b/challenge-198/robert-dicicco/julia/ch-2.jl new file mode 100644 index 0000000000..01b5fcc756 --- /dev/null +++ b/challenge-198/robert-dicicco/julia/ch-2.jl @@ -0,0 +1,69 @@ +#!/usr/bin/env julia + +#= + +AUTHOR: Robert DiCicco + +DATE : 2023-01-02 + +Challenge 198 Prime Count ( Julia ) + +=# + +using Printf + +using Primes + + + +arr = [10,15,1,25] + + + +for n in arr + + cnt = 0 + + @printf("Input: \$n = %d\n",n) + + for x in 1:n + + if isprime(x) + + cnt += 1 + + end + + end + + @printf("Output: %d\n\n",cnt) + +end + +#= + +julia .\PrimeCount.jl + +Input: $n = 10 + +Output: 4 + + + +Input: $n = 15 + +Output: 6 + + + +Input: $n = 1 + +Output: 0 + + + +Input: $n = 25 + +Output: 9 + +=# diff --git a/challenge-198/robert-dicicco/perl/ch-2.pl b/challenge-198/robert-dicicco/perl/ch-2.pl new file mode 100644 index 0000000000..d45956061a --- /dev/null +++ b/challenge-198/robert-dicicco/perl/ch-2.pl @@ -0,0 +1,75 @@ +#!/usr/bin/env perl + +=begin + +AUTHOR: Robert DiCicco + +DATE : 2023-01-02 + +Challenge 198 Prime Count ( Perl ) + +=cut + +use strict; + +use warnings; + +use feature qw/say/; + +use ntheory qw/is_prime/; + + + +my @arr = (10,15,1,25); + + + +for my $x (0..scalar(@arr)-1) { + + my $cnt = 0; + + print "Input: \$n = $arr[$x]\n"; # find primes less than @arr[$x] + + for my $n (0..$arr[$x]){ + + if(is_prime($n)) { + + $cnt++; + + } + + } + + print "Output: $cnt\n\n"; + +} + + + +=begin + +perl .\PrimeCount.pl + +Input: $n = 10 + +Output: 4 + + + +Input: $n = 15 + +Output: 6 + + + +Input: $n = 1 + +Output: 0 + + + +Input: $n = 25 + +Output: 9 + +=cut diff --git a/challenge-198/robert-dicicco/python/ch-2.py b/challenge-198/robert-dicicco/python/ch-2.py new file mode 100644 index 0000000000..71d5718b18 --- /dev/null +++ b/challenge-198/robert-dicicco/python/ch-2.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python + +''' + +AUTHOR: Robert DiCicco + +DATE : 2023-01-02 + +Challenge 198 Prime Count ( Python ) + +''' + + + +arr = [10,15,1,25] + + + +def isprime(num): + + if num > 1: + + for n in range(2,num): + + if (num % n) == 0: + + return False + + return True + + else: + + return False + + + +for n in arr: + + cnt = 0 + + print(f"Input: $n = {n}") + + for x in range(n): + + if isprime(x): + + #rint(x) + + cnt += 1 + + print(f"Output: {cnt}\n") + + + +''' + +python .\PrimeCount.py + +Input: $n = 10 + +Output: 4 + + + +Input: $n = 15 + +Output: 6 + + + +Input: $n = 1 + +Output: 0 + + + +Input: $n = 25 + +Output: 9 + +''' diff --git a/challenge-198/robert-dicicco/raku/ch-2.raku b/challenge-198/robert-dicicco/raku/ch-2.raku new file mode 100644 index 0000000000..fdda9118f9 --- /dev/null +++ b/challenge-198/robert-dicicco/raku/ch-2.raku @@ -0,0 +1,65 @@ +#!/usr/bin/env raku + +#`{ + +AUTHOR: Robert DiCicco + +DATE : 2023-01-02 + +Challenge 198 Prime Count ( Raku ) + +} + + + +my @arr = [10,15,1,25]; + + + +for (@arr) -> $n { + + my $cnt = 0; + + print "Input: \$n = $n\n"; # find primes less than @arr[$n] + + for (0 .. $n - 1) -> $x { + + if $x.is-prime { + + $cnt++; + + } + + } + + print "Output: $cnt\n\n"; + +} + +#`{ + +raku .\PrimeCount.rk + +Input: $n = 10 + +Output: 4 + + + +Input: $n = 15 + +Output: 6 + + + +Input: $n = 1 + +Output: 0 + + + +Input: $n = 25 + +Output: 9 + +} diff --git a/challenge-198/robert-dicicco/ruby/ch-2.rb b/challenge-198/robert-dicicco/ruby/ch-2.rb new file mode 100644 index 0000000000..81b9fb45a5 --- /dev/null +++ b/challenge-198/robert-dicicco/ruby/ch-2.rb @@ -0,0 +1,73 @@ +#!/usr/bin/env ruby + +=begin + +AUTHOR: Robert DiCicco + +DATE : 2023-01-02 + +Challenge 198 Prime Count ( Ruby ) + +=end + + + +require 'prime' + +arr = [10,15,1,25] + + + +arr.each do |n| + + cnt = 0 + + puts("Input: $n = #{n}") + + for x in 0..n-1 do + + if Prime.prime?(x) #=> true + + cnt += 1 + + end + + end + + puts("Output: #{cnt}") + + puts(" ") + +end + + + +=begin + +ruby .\PrimeCount.rb + +Input: $n = 10 + +Output: 4 + + + +Input: $n = 15 + +Output: 6 + + + +Input: $n = 1 + +Output: 0 + + + +Input: $n = 25 + +Output: 9 + + + +=end diff --git a/challenge-198/ziameraj16/java/PrimeCount.java b/challenge-198/ziameraj16/java/PrimeCount.java new file mode 100644 index 0000000000..26e5d75b0f --- /dev/null +++ b/challenge-198/ziameraj16/java/PrimeCount.java @@ -0,0 +1,37 @@ +import java.util.Scanner; + +public class PrimeCount { + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + System.out.println("Enter a number"); + final int i = Integer.parseInt(scanner.nextLine()); + int numberOfPrimes = 1; + if (i == 1) { + System.out.println(0); + } else if (i == 2) { + System.out.println(1); + } else { + for (int j = 3 ; j <= i; j++) { + if (isPrime(j)) { + numberOfPrimes++; + } + } + System.out.println(numberOfPrimes); + } + } + + private static boolean isPrime(int num) { + if (num % 2 == 0) { + return false; + } + int i = 3; + while (i < num / 2) { + if (num % i == 0) { + return false; + } + i = i + 2; + } + return true; + } +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 1202f0b794..dc99361369 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,6 +1,6 @@ { - "title" : { - "text" : "The Weekly Challenge - 198" + "xAxis" : { + "type" : "category" }, "drilldown" : { "series" : [ @@ -15,27 +15,41 @@ "name" : "Bruce Gray" }, { - "name" : "Mark Anderson", "id" : "Mark Anderson", "data" : [ [ "Raku", 2 ] - ] + ], + "name" : "Mark Anderson" }, { - "name" : "Niels van Dijke", - "id" : "Niels van Dijke", "data" : [ [ "Perl", 2 ] - ] + ], + "id" : "Niels van Dijke", + "name" : "Niels van Dijke" }, { - "id" : "Roger Bell_West", + "data" : [ + [ + "Perl", + 1 + ], + [ + "Raku", + 1 + ] + ], + "id" : "Robert DiCicco", + "name" : "Robert DiCicco" + }, + { + "name" : "Roger Bell_West", "data" : [ [ "Perl", @@ -46,11 +60,10 @@ 2 ] ], - "name" : "Roger Bell_West" + "id" : "Roger Bell_West" }, { "name" : "Thomas Kohler", - "id" : "Thomas Kohler", "data" : [ [ "Perl", @@ -60,7 +73,8 @@ "Blog", 2 ] - ] + ], + "id" : "Thomas Kohler" }, { "name" : "Ulrich Rieke", @@ -78,56 +92,41 @@ } ] }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "subtitle" : { - "text" : "[Champions: 6] Last updated at 2023-01-02 14:19:43 GMT" - }, - "tooltip" : { - "followPointer" : 1, - "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>", - "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>" - }, - "chart" : { - "type" : "column" - }, "legend" : { "enabled" : 0 }, - "plotOptions" : { - "series" : { - "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - }, - "borderWidth" : 0 - } + "subtitle" : { + "text" : "[Champions: 7] Last updated at 2023-01-02 21:00:08 GMT" }, "series" : [ { + "name" : "The Weekly Challenge - 198", + "colorByPoint" : 1, "data" : [ { - "drilldown" : "Bruce Gray", "name" : "Bruce Gray", + "drilldown" : "Bruce Gray", "y" : 2 }, { - "drilldown" : "Mark Anderson", + "y" : 2, "name" : "Mark Anderson", - "y" : 2 + "drilldown" : "Mark Anderson" }, { - "y" : 2, + "drilldown" : "Niels van Dijke", "name" : "Niels van Dijke", - "drilldown" : "Niels van Dijke" + "y" : 2 + }, + { + "drilldown" : "Robert DiCicco", + "name" : "Robert DiCicco", + "y" : 2 }, { "y" : 4, - "name" : "Roger Bell_West", - "drilldown" : "Roger Bell_West" + "drilldown" : "Roger Bell_West", + "name" : "Roger Bell_West" }, { "name" : "Thomas Kohler", @@ -135,16 +134,36 @@ "y" : 4 }, { - "y" : 4, "name" : "Ulrich Rieke", - "drilldown" : "Ulrich Rieke" + "drilldown" : "Ulrich Rieke", + "y" : 4 } - ], - "colorByPoint" : 1, - "name" : "The Weekly Challenge - 198" + ] } ], - "xAxis" : { - "type" : "category" + "tooltip" : { + "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>", + "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>", + "followPointer" : 1 + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "chart" : { + "type" : "column" + }, + "title" : { + "text" : "The Weekly Challenge - 198" + }, + "plotOptions" : { + "series" : { + "dataLabels" : { + "format" : "{point.y}", + "enabled" : 1 + }, + "borderWidth" : 0 + } } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 523250bde9..30d4159066 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,15 +1,33 @@ { - "xAxis" : { - "labels" : { - "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" - } - }, - "type" : "category" + "title" : { + "text" : "The Weekly Challenge Contributions [2019 - 2022]" + }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + }, + "yAxis" : { + "min" : 0, + "title" : { + "text" : null + } + }, + "chart" : { + "type" : "column" }, "series" : [ { + "dataLabels" : { + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + }, + "y" : 10, + "format" : "{point.y:.0f}", + "enabled" : "true", + "color" : "#FFFFFF", + "align" : "right", + "rotation" : -90 + }, "name" : "Contributions", "data" : [ [ @@ -18,46 +36,28 @@ ], [ "Perl", - 9706 + 9707 ], [ "Raku", - 5823 + 5824 ] - ], - "dataLabels" : { - "color" : "#FFFFFF", - "enabled" : "true", - "align" : "right", - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - }, - "format" : "{point.y:.0f}", - "y" : 10, - "rotation" : -90 - } + ] } ], - "legend" : { - "enabled" : "false" - }, - "chart" : { - "type" : "column" - }, - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" - }, "subtitle" : { - "text" : "Last updated at 2023-01-02 14:19:43 GMT" + "text" : "Last updated at 2023-01-02 21:00:08 GMT" }, - "yAxis" : { - "title" : { - "text" : null - }, - "min" : 0 + "xAxis" : { + "type" : "category", + "labels" : { + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + } + } }, - "title" : { - "text" : "The Weekly Challenge Contributions [2019 - 2022]" + "legend" : { + "enabled" : "false" } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 6ae260f8e6..329ae4e0b9 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,13 +1,11 @@ { - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } + "legend" : { + "enabled" : "false" }, "drilldown" : { "series" : [ { - "name" : "001", + "id" : "001", "data" : [ [ "Perl", @@ -22,11 +20,10 @@ 11 ] ], - "id" : "001" + "name" : "001" }, { "name" : "002", - "id" : "002", "data" : [ [ "Perl", @@ -40,11 +37,10 @@ "Blog", 10 ] - ] + ], + "id" : "002" }, { - "name" : "003", - "id" : "003", "data" : [ [ "Perl", @@ -58,11 +54,11 @@ "Blog", 9 ] - ] + ], + "id" : "003", + "name" : "003" }, { - "name" : "004", - "id" : "004", "data" : [ [ "Perl", @@ -76,10 +72,13 @@ "Blog", 10 ] - ] + ], + "id" : "004", + "name" : "004" }, { "name" : "005", + "id" : "005", "data" : [ [ "Perl", @@ -93,11 +92,11 @@ "Blog", 12 ] - ], - "id" : "005" + ] }, { "name" : "006", + "id" : "006", "data" : [ [ "Perl", @@ -111,10 +110,10 @@ "Blog", 7 ] - ], - "id" : "006" + ] }, { + "id" : "007", "data" : [ [ "Perl", @@ -129,10 +128,10 @@ 10 ] ], - "id" : "007", "name" : "007" }, { + "name" : "008", "data" : [ [ "Perl", @@ -147,10 +146,10 @@ 12 ] ], - "id" : "008", - "name" : "008" + "id" : "008" }, { + "name" : "009", "id" : "009", "data" : [ [ @@ -165,10 +164,10 @@ "Blog", 13 ] - ], - "name" : "009" + ] }, { + "name" : "010", "data" : [ [ "Perl", @@ -183,10 +182,10 @@ 11 ] ], - "id" : "010", - "name" : "010" + "id" : "010" }, { + "id" : "011", "data" : [ [ "Perl", @@ -201,12 +200,9 @@ 10 ] ], - "id" : "011", "name" : "011" }, { - "name" : "012", - "id" : "012", "data" : [ [ "Perl", @@ -220,7 +216,9 @@ "Blog", 11 ] - ] + ], + "id" : "012", + "name" : "012" }, { "data" : [ @@ -241,7 +239,6 @@ "name" : "013" }, { - "id" : "014", "data" : [ [ "Perl", @@ -256,10 +253,12 @@ 15 ] ], + "id" : "014", "name" : "014" }, { "name" : "015", + "id" : "015", "data" : [ [ "Perl", @@ -273,10 +272,11 @@ "Blog", 15 ] - ], - "id" : "015" + ] }, { + "name" : "016", + "id" : "016", "data" : [ [ "Perl", @@ -290,12 +290,9 @@ "Blog", 12 ] - ], - "id" : "016", - "name" : "016" + ] }, { - "name" : "017", "data" : [ [ "Perl", @@ -310,9 +307,11 @@ 12 ] ], - "id" : "017" + "id" : "017", + "name" : "017" }, { + "name" : "018", "id" : "018", "data" : [ [ @@ -327,11 +326,9 @@ "Blog", 14 ] - ], - "name" : "018" + ] }, { - "name" : "019", "data" : [ [ "Perl", @@ -346,9 +343,11 @@ 13 ] ], - "id" : "019" + "id" : "019", + "name" : "019" }, { + "id" : "020", "data" : [ [ "Perl", @@ -363,11 +362,9 @@ 13 ] ], - "id" : "020", "name" : "020" }, { - "id" : "021", "data" : [ [ "Perl", @@ -382,9 +379,11 @@ 10 ] ], + "id" : "021", "name" : "021" }, { + "name" : "022", "data" : [ [ "Perl", @@ -399,8 +398,7 @@ 10 ] ], - "id" : "022", - "name" : "022" + "id" : "022" }, { "data" : [ @@ -421,8 +419,6 @@ "name" : "023" }, { - "name" : "024", - "id" : "024", "data" : [ [ "Perl", @@ -436,7 +432,9 @@ "Blog", 11 ] - ] + ], + "id" : "024", + "name" : "024" }, { "name" : "025", @@ -457,6 +455,7 @@ "id" : "025" }, { + "name" : "026", "id" : "026", "data" : [ [ @@ -471,11 +470,10 @@ "Blog", 10 ] - ], - "name" : "026" + ] }, { - "id" : "027", + "name" : "027", "data" : [ [ "Perl", @@ -490,10 +488,10 @@ 9 ] ], - "name" : "027" + "id" : "027" }, { - "id" : "028", + "name" : "028", "data" : [ [ "Perl", @@ -508,10 +506,9 @@ 9 ] ], - "name" : "028" + "id" : "028" }, { - "id" : "029", "data" : [ [ "Perl", @@ -526,6 +523,7 @@ 12 ] ], + "id" : "029", "name" : "029" }, { @@ -547,6 +545,8 @@ "name" : "030" }, { + "name" : "031", + "id" : "031", "data" : [ [ "Perl", @@ -560,9 +560,7 @@ "Blog", 9 ] - ], - "id" : "031", - "name" : "031" + ] }, { "name" : "032", @@ -583,6 +581,7 @@ "id" : "032" }, { + "id" : "033", "data" : [ [ "Perl", @@ -597,10 +596,11 @@ 10 ] ], - "id" : "033", "name" : "033" }, { + "name" : "034", + "id" : "034", "data" : [ [ |
