aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-171/0rir/raku/ch-1.raku44
-rw-r--r--challenge-171/0rir/raku/ch-2.raku48
-rwxr-xr-xchallenge-171/2colours/raku/ch-1.raku12
-rwxr-xr-xchallenge-171/2colours/raku/ch-2.raku7
-rwxr-xr-xchallenge-171/brxfork/perl/ch-1.sh2
-rwxr-xr-xchallenge-171/dario-mazzeo/perl/ch-1.pl23
-rw-r--r--challenge-171/dave-jacoby/perl/ch-1.pl44
-rw-r--r--challenge-171/dave-jacoby/perl/ch-2.pl23
-rw-r--r--challenge-171/deadmarshal/cpp/ch-1.cpp34
-rw-r--r--challenge-171/deadmarshal/cpp/ch-2.cpp17
-rw-r--r--challenge-171/deadmarshal/d/ch1.d28
-rw-r--r--challenge-171/deadmarshal/d/ch2.d10
-rw-r--r--challenge-171/deadmarshal/haskell/ch-1.hs11
-rw-r--r--challenge-171/deadmarshal/haskell/ch-2.hs2
-rw-r--r--challenge-171/deadmarshal/lua/ch-1.lua30
-rw-r--r--challenge-171/deadmarshal/lua/ch-2.lua10
-rw-r--r--challenge-171/deadmarshal/pascal/ch1.pas43
-rw-r--r--challenge-171/deadmarshal/pascal/ch2.pas25
-rw-r--r--challenge-171/deadmarshal/perl/ch-1.pl16
-rw-r--r--challenge-171/deadmarshal/perl/ch-2.pl15
-rwxr-xr-xchallenge-171/e-choroba/perl/ch-1.pl27
-rwxr-xr-xchallenge-171/e-choroba/perl/ch-2.pl20
-rwxr-xr-xchallenge-171/eric-cheung/python/ch-1.py59
-rwxr-xr-xchallenge-171/eric-cheung/python/ch-2.py27
-rw-r--r--challenge-171/james-smith/README.md255
-rw-r--r--challenge-171/james-smith/blog.txt2
-rw-r--r--challenge-171/james-smith/perl/ch-1.pl48
-rw-r--r--challenge-171/james-smith/perl/ch-2.pl33
-rw-r--r--challenge-171/laurent-rosenfeld/blog.txt1
-rw-r--r--challenge-171/laurent-rosenfeld/perl/ch-1.pl23
-rw-r--r--challenge-171/laurent-rosenfeld/perl/ch-2.pl7
-rw-r--r--challenge-171/laurent-rosenfeld/raku/ch-1.raku11
-rw-r--r--challenge-171/laurent-rosenfeld/raku/ch-2.raku8
-rw-r--r--challenge-171/luca-ferrari/blog-1.txt1
-rw-r--r--challenge-171/luca-ferrari/blog-2.txt1
-rw-r--r--challenge-171/luca-ferrari/blog-3.txt1
-rw-r--r--challenge-171/luca-ferrari/blog-4.txt1
-rw-r--r--challenge-171/luca-ferrari/blog-5.txt1
-rw-r--r--challenge-171/luca-ferrari/blog-6.txt1
-rw-r--r--challenge-171/luca-ferrari/postgresql/ch-1.plperl67
-rw-r--r--challenge-171/luca-ferrari/postgresql/ch-1.sql38
-rw-r--r--challenge-171/luca-ferrari/postgresql/ch-2.plperl54
-rw-r--r--challenge-171/luca-ferrari/postgresql/ch-2.sql17
-rwxr-xr-xchallenge-171/luca-ferrari/raku/ch-1.p617
-rwxr-xr-xchallenge-171/luca-ferrari/raku/ch-2.p624
-rwxr-xr-xchallenge-171/mattneleigh/perl/ch-1.pl111
-rwxr-xr-xchallenge-171/mattneleigh/perl/ch-2.pl68
-rw-r--r--challenge-171/mohammad-anwar/perl/ch-1.pl43
-rw-r--r--challenge-171/mohammad-anwar/perl/ch-2.pl37
-rw-r--r--challenge-171/pokgopun/go/ch-1.go28
-rw-r--r--challenge-171/pokgopun/go/ch-2.go59
-rw-r--r--challenge-171/robert-dicicco/julia/ch-1.jl54
-rw-r--r--challenge-171/robert-dicicco/perl/ch-1.pl35
-rw-r--r--challenge-171/robert-dicicco/raku/ch-1.raku41
-rw-r--r--challenge-171/robert-dicicco/ruby/ch-1.rb35
-rwxr-xr-xchallenge-171/roger-bell-west/javascript/ch-1.js74
-rwxr-xr-xchallenge-171/roger-bell-west/javascript/ch-2.js22
-rw-r--r--challenge-171/roger-bell-west/kotlin/ch-1.kt50
-rw-r--r--challenge-171/roger-bell-west/kotlin/ch-2.kt18
-rwxr-xr-xchallenge-171/roger-bell-west/lua/ch-1.lua76
-rwxr-xr-xchallenge-171/roger-bell-west/lua/ch-2.lua28
-rwxr-xr-xchallenge-171/roger-bell-west/perl/ch-1.pl30
-rwxr-xr-xchallenge-171/roger-bell-west/perl/ch-2.pl24
-rw-r--r--challenge-171/roger-bell-west/postscript/ch-1.ps148
-rw-r--r--challenge-171/roger-bell-west/postscript/ch-2.ps62
-rwxr-xr-xchallenge-171/roger-bell-west/python/ch-1.py43
-rwxr-xr-xchallenge-171/roger-bell-west/python/ch-2.py17
-rwxr-xr-xchallenge-171/roger-bell-west/raku/ch-1.p648
-rwxr-xr-xchallenge-171/roger-bell-west/raku/ch-2.p620
-rwxr-xr-xchallenge-171/roger-bell-west/ruby/ch-1.rb51
-rwxr-xr-xchallenge-171/roger-bell-west/ruby/ch-2.rb21
-rwxr-xr-xchallenge-171/roger-bell-west/rust/ch-1.rs49
-rwxr-xr-xchallenge-171/roger-bell-west/rust/ch-2.rs21
-rw-r--r--challenge-171/wlmb/blog.txt1
-rwxr-xr-xchallenge-171/wlmb/perl/ch-1.pl18
-rwxr-xr-xchallenge-171/wlmb/perl/ch-2.pl17
-rw-r--r--stats/pwc-challenge-170.json676
-rw-r--r--stats/pwc-current.json616
-rw-r--r--stats/pwc-language-breakdown-summary.json74
-rw-r--r--stats/pwc-language-breakdown.json2421
-rw-r--r--stats/pwc-leaders.json412
-rw-r--r--stats/pwc-summary-1-30.json108
-rw-r--r--stats/pwc-summary-121-150.json108
-rw-r--r--stats/pwc-summary-151-180.json46
-rw-r--r--stats/pwc-summary-181-210.json110
-rw-r--r--stats/pwc-summary-211-240.json130
-rw-r--r--stats/pwc-summary-241-270.json50
-rw-r--r--stats/pwc-summary-31-60.json52
-rw-r--r--stats/pwc-summary-61-90.json48
-rw-r--r--stats/pwc-summary-91-120.json52
-rw-r--r--stats/pwc-summary.json88
91 files changed, 5002 insertions, 2526 deletions
diff --git a/challenge-171/0rir/raku/ch-1.raku b/challenge-171/0rir/raku/ch-1.raku
new file mode 100644
index 0000000000..0a852dff03
--- /dev/null
+++ b/challenge-171/0rir/raku/ch-1.raku
@@ -0,0 +1,44 @@
+#!/usr/bin/env raku
+# :vim ft=raku sw=4 expandtab # ∅ ≡ ∩ ≢
+use v6.d;
+
+=begin comment
+Task 1: Abundant Number Submitted by: Mohammad S Anwar
+
+Generate the first 20 Abundant Odd Numbers. An abundant number is
+defined as a number n for which the sum of proper divisors > n.
+Odd means odd.
+
+945 is the first Abundant Odd Number because the proper divisor summed
+are greater than 945:
+1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 105 + 135 + 189 + 315 = 975
+=end comment
+
+sub proper-divisors (Int $n where $n > 0 --> Array ) {
+ # after the Rosetta code
+ my @result = 1 if $n > 1;
+ ( 2 .. $n.sqrt.Int ).map: -> $d {
+ unless $n % $d {
+ @result.push: $d;
+ my $y = $n div $d;
+ @result.push: $y if $y != $d
+ }
+ }
+ @result;
+}
+
+constant @odd-abundant = gather {
+ my Int $i = 943;
+ loop {
+ $i += 2;
+ next if $i.is-prime;
+ if $i < [+] proper-divisors( $i) {
+ take $i;
+ next;
+ }
+ }
+}
+
+say @odd-abundant[ 0 .. 19].join( ', ');
+exit;
+
diff --git a/challenge-171/0rir/raku/ch-2.raku b/challenge-171/0rir/raku/ch-2.raku
new file mode 100644
index 0000000000..a36c479e6f
--- /dev/null
+++ b/challenge-171/0rir/raku/ch-2.raku
@@ -0,0 +1,48 @@
+#!/usr/bin/env raku
+# :vim ft=raku sw=4 expandtab # ∅ ≡ ∩ ≢
+use v6.d;
+use Test;
+
+=begin comment
+Task 2: First-class Function Submitted by: Mohammad S Anwar
+
+Create sub compose($f, $g) which takes in two parameters $f and $g
+as subroutine refs and returns subroutine ref i.e. compose($f, $g)->($x) = $f->($g->($x))
+The argument functions both are variadic ( one to ∞ ).
+
+After 'h = compose(f, g)' then
+'f(g($x,$y, ... )) == h($x,$y, ...)' is True for any $x, $y, ...
+=end comment
+
+sub compose( &one, &two ) {
+ sub ( *@a where @a[0].defined --> Array ) { one( two( @a )); }
+}
+
+sub twice ( *@a where @a[0].defined --> Array) { [ @a.map: * × 2 ]; }
+
+sub incre( *@a is copy where @a[0].defined -->Array ) {
+ @a[$_] = @a[$_] +1 for 0 .. @a.end ;
+ @a;
+}
+
+
+my @test = [ 2, ], [ 2, 10], [ 0, 0], [ -2, -10, 100 ], [ -1, 1, 5, 9, 11, 15, 19, 23, 29];
+
+my &both = compose( &twice, &incre) ;
+
+
+plan 6 + @test.elems;
+
+dies-ok { incre() }, 'incre requires arg dies';
+dies-ok { twice() }, 'twice requires arg dies';
+dies-ok { both() }, 'both requires arg dies';
+is incre( 2, 10), [3, 11], 'incre( 2, 10)';
+is twice( 2, 10), [4, 20], 'twice( 2, 10)';
+
+is both(2, 10, 20, 30), twice(incre(2, 10, 20, 30 )),
+ "both( 2, 10, 20, 30) ==> " ~ both( 2, 10, 20, 30) ~ ' hand';
+
+for @test -> @t {
+ is both(@t), twice(incre( @t )), "both( @t[]) ==> " ~ both( @t);
+}
+done-testing;
diff --git a/challenge-171/2colours/raku/ch-1.raku b/challenge-171/2colours/raku/ch-1.raku
new file mode 100755
index 0000000000..f2e0dcc88d
--- /dev/null
+++ b/challenge-171/2colours/raku/ch-1.raku
@@ -0,0 +1,12 @@
+#!/usr/bin/env raku
+
+sub divisors($num) {
+ my @small-divisors = (1 .. sqrt $num).grep: $num %% *;
+ (|@small-divisors, |($num <<div<< @small-divisors )).Set
+}
+
+1, 3 ... * andthen
+ .grep: { .&divisors.keys.sum > 2 * $_ } andthen
+ .head: 20 andthen
+ .join: ', ' andthen
+ .say;
diff --git a/challenge-171/2colours/raku/ch-2.raku b/challenge-171/2colours/raku/ch-2.raku
new file mode 100755
index 0000000000..e767caecd7
--- /dev/null
+++ b/challenge-171/2colours/raku/ch-2.raku
@@ -0,0 +1,7 @@
+#!/usr/bin/env raku
+
+sub compose(&f, &g) {
+ sub (|args) { f(g(|args)) }
+}
+
+[* * 3, &infix:<+>].reduce(&compose)(3, 4).say; \ No newline at end of file
diff --git a/challenge-171/brxfork/perl/ch-1.sh b/challenge-171/brxfork/perl/ch-1.sh
new file mode 100755
index 0000000000..8c1be89dcd
--- /dev/null
+++ b/challenge-171/brxfork/perl/ch-1.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+perl -E '$_="N"; $" = "+" ; while ($sol < 20) {$_.="NN";my @sum;/^(N+?)\1+$(?{push @sum,length$1})(?!)/;eval "@sum" > length() and ++$sol and say length()," < ", eval "@sum" , " = ", "@sum" }'
diff --git a/challenge-171/dario-mazzeo/perl/ch-1.pl b/challenge-171/dario-mazzeo/perl/ch-1.pl
new file mode 100755
index 0000000000..b3113fc87d
--- /dev/null
+++ b/challenge-171/dario-mazzeo/perl/ch-1.pl
@@ -0,0 +1,23 @@
+# THE WEEKLY CHALLENGE - 171
+# Task 1: Abundant Number
+# Autore: Dario Mazzeo
+
+my $abu=1;
+my $num=0;
+do {
+ my $tot=0;
+ foreach my $div (1 .. 100){
+ if ($div<$abu && SeDivisore($abu,$div)==1){$tot+=$div;}
+ }
+ if ($tot>$abu){$num++; print "$abu\n";}
+ $abu++;
+} while ($num<20);
+exit;
+
+sub SeDivisore{
+my $a=$_[0];
+my $b=$_[1];
+
+if (($a % $b)==0){return 1;}
+else {return 0;}
+} \ No newline at end of file
diff --git a/challenge-171/dave-jacoby/perl/ch-1.pl b/challenge-171/dave-jacoby/perl/ch-1.pl
new file mode 100644
index 0000000000..45dd7bc0f3
--- /dev/null
+++ b/challenge-171/dave-jacoby/perl/ch-1.pl
@@ -0,0 +1,44 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use experimental qw{ say postderef signatures state };
+
+use List::Util qw{ sum0 };
+
+$| = 1;
+
+# abundant odd number
+my @abundant;
+my $iter = make_iterator(945);
+while ( my $i = $iter->() ) {
+ next if $i % 2 == 0;
+ next unless is_abundant($ i );
+ push @abundant, $i;
+ last if scalar @abundant >20;
+}
+
+say join ' ', @abundant;
+
+sub is_abundant( $n ) {
+ my @factors = get_factors($n);
+ my $sum = sum0 @factors;
+ return $sum > $n ? 1 : 0;
+}
+
+sub get_factors( $n ) {
+ my @factors;
+ for my $i ( 1 .. 1 + $n / 2 ) {
+ next unless $n % $i == 0;
+ push @factors, $i;
+ }
+ return @factors;
+}
+
+sub make_iterator($n) {
+ return sub {
+ state $v = $n;
+ return $v++;
+ }
+}
+
diff --git a/challenge-171/dave-jacoby/perl/ch-2.pl b/challenge-171/dave-jacoby/perl/ch-2.pl
new file mode 100644
index 0000000000..3c4cddf2c7
--- /dev/null
+++ b/challenge-171/dave-jacoby/perl/ch-2.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use experimental qw{ say postderef signatures state };
+
+my $f = sub ( $sub ) {
+ return sub ( $x ) { return uc $sub->($x) }
+};
+
+my $g = sub ( $val ) {
+ return join ' ', map { $val } 1 .. 3;
+};
+
+my $h = compose( $f, $g );
+say join " / ", $h->(qw{ sub refs are fun });
+
+sub compose ( $f, $g ) {
+ my $sub = $f->($g);
+ return sub ( @x ) {
+ return map { $sub->($_) } @x;
+ }
+}
diff --git a/challenge-171/deadmarshal/cpp/ch-1.cpp b/challenge-171/deadmarshal/cpp/ch-1.cpp
new file mode 100644
index 0000000000..388cb0b7a4
--- /dev/null
+++ b/challenge-171/deadmarshal/cpp/ch-1.cpp
@@ -0,0 +1,34 @@
+#include<iostream>
+#include<vector>
+#include<cmath>
+
+template<typename T>
+T divisors_sum(T n)
+{
+ T sum{};
+ for(T i = 1; i < n / 2+1; ++i)
+ if(n % i == 0) sum += i;
+ return sum;
+}
+
+template<typename T>
+std::vector<T> abundant_odd_numbers()
+{
+ std::vector<T> vec{};
+ int i = 1;
+ do{
+ if((divisors_sum(i) > i) && (i % 2 != 0)) vec.push_back(i);
+ i++;
+ }while(vec.size() != 20);
+ return vec;
+}
+
+int main()
+{
+ std::vector<int> vec = abundant_odd_numbers<int>();
+ for(const auto& e : vec)
+ std::cout << e << ' ';
+ std::cout << '\n';
+ return 0;
+}
+
diff --git a/challenge-171/deadmarshal/cpp/ch-2.cpp b/challenge-171/deadmarshal/cpp/ch-2.cpp
new file mode 100644
index 0000000000..ff23f617ed
--- /dev/null
+++ b/challenge-171/deadmarshal/cpp/ch-2.cpp
@@ -0,0 +1,17 @@
+#include<iostream>
+#include<functional>
+
+std::function<int(int)> f = [](auto n){return n + 2;};
+std::function<int(int)> g = [](auto n){return n * 2;};
+
+template<typename F, typename G>
+auto compose(F f, G g)
+{
+ return [f,g](auto n){return f(g(n));};
+}
+
+int main()
+{
+ std::cout << compose(f, g)(5) << '\n';
+ return 0;
+}
diff --git a/challenge-171/deadmarshal/d/ch1.d b/challenge-171/deadmarshal/d/ch1.d
new file mode 100644
index 0000000000..670b38fc1e
--- /dev/null
+++ b/challenge-171/deadmarshal/d/ch1.d
@@ -0,0 +1,28 @@
+import std.stdio:writeln,write;
+
+int divisors_sum(int n)
+{
+ int sum = 0;
+ for(int i = 1; i < n / 2+1; ++i)
+ if(n % i == 0) sum += i;
+ return sum;
+}
+
+int[] abundant_odd_numbers()
+{
+ int[] arr;
+ int i = 1;
+ do{
+ if((divisors_sum(i) > i) && (i % 2 != 0)) arr ~= i;
+ i++;
+ }while(arr.length != 20);
+ return arr;
+}
+
+void main()
+{
+ int[] arr = abundant_odd_numbers();
+ foreach(e; arr)
+ write(e, ' ');
+ writeln;
+}
diff --git a/challenge-171/deadmarshal/d/ch2.d b/challenge-171/deadmarshal/d/ch2.d
new file mode 100644
index 0000000000..fb8b004af4
--- /dev/null
+++ b/challenge-171/deadmarshal/d/ch2.d
@@ -0,0 +1,10 @@
+import std.stdio:writeln;
+import std.functional:compose;
+
+auto f = (int n) => n + 2;
+auto g = (int n) => n * 2;
+
+void main()
+{
+ writeln(compose!(f, g)(5));
+}
diff --git a/challenge-171/deadmarshal/haskell/ch-1.hs b/challenge-171/deadmarshal/haskell/ch-1.hs
new file mode 100644
index 0000000000..9b5e59b5a7
--- /dev/null
+++ b/challenge-171/deadmarshal/haskell/ch-1.hs
@@ -0,0 +1,11 @@
+divisorsSum :: (Integral a) => a -> a
+divisorsSum n = sum [x | x <- [1..(div n 2+1)], mod n x == 0]
+
+abundantOddNumbers :: (Integral a) => [