aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-209/eric-cheung/python/ch-1.py27
-rwxr-xr-xchallenge-209/eric-cheung/python/ch-2.py27
-rw-r--r--challenge-209/laurent-rosenfeld/blog.txt1
-rw-r--r--challenge-209/laurent-rosenfeld/perl/ch-1.pl18
-rw-r--r--challenge-209/laurent-rosenfeld/perl/ch-2.pl37
-rw-r--r--challenge-209/laurent-rosenfeld/raku/ch-1.raku13
-rw-r--r--challenge-209/laurent-rosenfeld/raku/ch-2.raku24
-rwxr-xr-xchallenge-209/perlboy1967/perl/ch-1.pl (renamed from challenge-209/perlboy1967/ch1.pl)0
-rwxr-xr-xchallenge-209/perlboy1967/perl/ch-2.pl (renamed from challenge-209/perlboy1967/ch2.pl)0
-rw-r--r--challenge-209/robert-dicicco/julia/ch-1.jl62
-rw-r--r--challenge-209/robert-dicicco/perl/ch-1.pl68
-rw-r--r--challenge-209/robert-dicicco/perl/ch-2.pl69
-rw-r--r--challenge-209/robert-dicicco/python/ch-1.py48
-rw-r--r--challenge-209/robert-dicicco/raku/ch-1.raku64
-rw-r--r--challenge-209/robert-dicicco/raku/ch-2.raku57
-rw-r--r--challenge-209/robert-dicicco/ruby/ch-1.rb62
-rw-r--r--challenge-209/ulrich-rieke/cpp/ch-1.cpp29
-rw-r--r--challenge-209/ulrich-rieke/cpp/ch-2.cpp120
-rw-r--r--challenge-209/ulrich-rieke/haskell/ch-1.hs17
-rw-r--r--challenge-209/ulrich-rieke/haskell/ch-2.hs52
-rw-r--r--challenge-209/ulrich-rieke/perl/ch-1.pl29
-rw-r--r--challenge-209/ulrich-rieke/perl/ch-2.pl85
-rw-r--r--challenge-209/ulrich-rieke/raku/ch-1.raku19
-rw-r--r--challenge-209/ulrich-rieke/rust/ch-1.rs35
-rw-r--r--stats/pwc-challenge-001.json1019
-rw-r--r--stats/pwc-challenge-002.json477
-rw-r--r--stats/pwc-challenge-003.json283
-rw-r--r--stats/pwc-challenge-004.json319
-rw-r--r--stats/pwc-challenge-006.json229
-rw-r--r--stats/pwc-challenge-007.json249
-rw-r--r--stats/pwc-challenge-008.json471
-rw-r--r--stats/pwc-challenge-009.json254
-rw-r--r--stats/pwc-challenge-010.json466
-rw-r--r--stats/pwc-challenge-011.json311
-rw-r--r--stats/pwc-challenge-012.json509
-rw-r--r--stats/pwc-challenge-013.json267
-rw-r--r--stats/pwc-challenge-014.json555
-rw-r--r--stats/pwc-challenge-015.json291
-rw-r--r--stats/pwc-challenge-016.json251
-rw-r--r--stats/pwc-challenge-017.json283
-rw-r--r--stats/pwc-challenge-018.json291
-rw-r--r--stats/pwc-challenge-019.json317
-rw-r--r--stats/pwc-challenge-020.json279
-rw-r--r--stats/pwc-challenge-021.json285
-rw-r--r--stats/pwc-challenge-022.json435
-rw-r--r--stats/pwc-challenge-023.json445
-rw-r--r--stats/pwc-challenge-024.json445
-rw-r--r--stats/pwc-challenge-025.json258
-rw-r--r--stats/pwc-challenge-026.json425
-rw-r--r--stats/pwc-challenge-027.json379
-rw-r--r--stats/pwc-challenge-034.json255
-rw-r--r--stats/pwc-challenge-039.json382
-rw-r--r--stats/pwc-challenge-175.json539
-rw-r--r--stats/pwc-challenge-196.json277
-rw-r--r--stats/pwc-challenge-197.json227
-rw-r--r--stats/pwc-challenge-208.json740
-rw-r--r--stats/pwc-current.json430
-rw-r--r--stats/pwc-language-breakdown-summary.json74
-rw-r--r--stats/pwc-language-breakdown.json1433
-rw-r--r--stats/pwc-leaders.json862
-rw-r--r--stats/pwc-summary-1-30.json112
-rw-r--r--stats/pwc-summary-121-150.json48
-rw-r--r--stats/pwc-summary-151-180.json36
-rw-r--r--stats/pwc-summary-181-210.json112
-rw-r--r--stats/pwc-summary-211-240.json114
-rw-r--r--stats/pwc-summary-241-270.json38
-rw-r--r--stats/pwc-summary-271-300.json44
-rw-r--r--stats/pwc-summary-31-60.json102
-rw-r--r--stats/pwc-summary-61-90.json60
-rw-r--r--stats/pwc-summary-91-120.json38
-rw-r--r--stats/pwc-summary.json140
71 files changed, 9418 insertions, 7401 deletions
diff --git a/challenge-209/eric-cheung/python/ch-1.py b/challenge-209/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..b6dadfb137
--- /dev/null
+++ b/challenge-209/eric-cheung/python/ch-1.py
@@ -0,0 +1,27 @@
+
+def IsLastCharA(arrToLoad):
+
+ if len(arrToLoad) % 2 == 0:
+ return False
+
+ if len(arrToLoad) == 1 and arrToLoad[0] == 0:
+ return True
+
+ for nIndx in range(0, len(arrToLoad) - 2, 2):
+ if arrToLoad[nIndx:nIndx + 2] != [1, 0] and arrToLoad[nIndx:nIndx + 2] != [1, 1]:
+ return False
+
+ if arrToLoad[-1] == 0:
+ return True
+
+ return False
+
+
+arrInput = [1, 0, 0] ## Example 1
+## arrInput = [1, 1, 1, 0] ## Example 2
+
+
+if IsLastCharA(arrInput):
+ print ("1")
+else:
+ print ("0")
diff --git a/challenge-209/eric-cheung/python/ch-2.py b/challenge-209/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..624ac7029f
--- /dev/null
+++ b/challenge-209/eric-cheung/python/ch-2.py
@@ -0,0 +1,27 @@
+
+## arrAccount = [["A", "a1@a.com", "a2@a.com"], ["B", "b1@b.com"], ["A", "a3@a.com", "a1@a.com"]] ## Example 1
+arrAccount = [["A", "a1@a.com", "a2@a.com"], ["B", "b1@b.com"], ["A", "a3@a.com"], ["B", "b2@b.com", "b1@b.com"]] ## Example 2
+
+arrUser = [arrAccount[0][0]]
+arrEmail = [arrAccount[0][1:]]
+arrFinal = []
+
+for nIndx in range(1, len(arrAccount)):
+ if arrAccount[nIndx][0] not in arrUser:
+ arrUser.append(arrAccount[nIndx][0])
+ arrEmail.append(arrAccount[nIndx][1:])
+ else:
+ nFindIndx = arrUser.index(arrAccount[nIndx][0])
+ if len(list(set(arrEmail[nFindIndx]) & set(arrAccount[nIndx][1:]))) == 0:
+ arrUser.append(arrAccount[nIndx][0])
+ arrEmail.append(arrAccount[nIndx][1:])
+ else:
+ arrEmail[nFindIndx] = sorted(list(set(arrEmail[nFindIndx] + arrAccount[nIndx][1:])))
+
+## print (arrUser)
+## print (arrEmail)
+
+for nIndx in range(0, len(arrUser)):
+ arrFinal.append([arrUser[nIndx], str(arrEmail[nIndx][:])[1:-1]])
+
+print (arrFinal)
diff --git a/challenge-209/laurent-rosenfeld/blog.txt b/challenge-209/laurent-rosenfeld/blog.txt
new file mode 100644
index 0000000000..4139988770
--- /dev/null
+++ b/challenge-209/laurent-rosenfeld/blog.txt
@@ -0,0 +1 @@
+https://blogs.perl.org/users/laurent_r/2023/03/perl-weekly-challenge-209-special-bit-characters-and-merge-account.html
diff --git a/challenge-209/laurent-rosenfeld/perl/ch-1.pl b/challenge-209/laurent-rosenfeld/perl/ch-1.pl
new file mode 100644
index 0000000000..58d48bc7d5
--- /dev/null
+++ b/challenge-209/laurent-rosenfeld/perl/ch-1.pl
@@ -0,0 +1,18 @@
+use strict;
+use warnings;
+use feature "say";
+
+sub ends_with_a {
+ my $i = 0;
+ my $end = $#_;
+ while (1) {
+ return 1 if $i == $end;
+ $i += $_[$i] == 0 ? 1 : 2;
+ return 0 if $i > $end;
+ }
+}
+
+for my $test ([<1 0 0>], [<1 1 1 0>],
+ [<0 0 0 1 0>], [<1 1 0>]) {
+ printf "%-12s => %d\n", "@$test", ends_with_a @$test;
+}
diff --git a/challenge-209/laurent-rosenfeld/perl/ch-2.pl b/challenge-209/laurent-rosenfeld/perl/ch-2.pl
new file mode 100644
index 0000000000..fbe84c8b20
--- /dev/null
+++ b/challenge-209/laurent-rosenfeld/perl/ch-2.pl
@@ -0,0 +1,37 @@
+use strict;
+use warnings;
+use feature "say";
+
+sub merge_account {
+ my %merged;
+ for my $part (@_) {
+ # say Dumper $part;
+ my ($key, @values) = @$part;
+ $merged{$key}{$_} = 1 for @values;
+ }
+ # say %merged;
+ return \%merged;
+}
+
+my @tests = ( [ [<A a1\@a.com a2\@a.com>],
+ [<B b1\@b.com>],
+ [<A a3\@a.com a1\@a.com>] ],
+
+ [ [<A a1\@a.com a2\@a.com>],
+ [<B b1\@b.com>],
+ [<A a3\@a.com>],
+ [<B b2\@b.com b1\@b.com>] ] );
+
+for my $test (@tests) {
+ # say Dumper $test, " => ";
+ for my $part (@$test) {
+ print join " ", @$part;
+ print " - ";
+ }
+ say " =>";
+ my %merged = %{merge_account @$test};
+ for my $k (sort keys %merged) {
+ say "\t[", (join " ", $k, sort keys %{$merged{$k}}), "]";
+ };
+ say "";
+}
diff --git a/challenge-209/laurent-rosenfeld/raku/ch-1.raku b/challenge-209/laurent-rosenfeld/raku/ch-1.raku
new file mode 100644
index 0000000000..f07f8b0ac6
--- /dev/null
+++ b/challenge-209/laurent-rosenfeld/raku/ch-1.raku
@@ -0,0 +1,13 @@
+sub ends-with-a (@in) {
+ my $i = 0;
+ my $end = @in.end;
+ loop {
+ return 1 if $i == $end;
+ $i += @in[$i] == 0 ?? 1 !! 2;
+ return 0 if $i > $end;
+ }
+}
+
+for <1 0 0>, <1 1 1 0>, <0 0 0 1 0>, <1 1 0> -> @test {
+ say (~ @test).fmt("%-12s => "), ends-with-a @test;
+}
diff --git a/challenge-209/laurent-rosenfeld/raku/ch-2.raku b/challenge-209/laurent-rosenfeld/raku/ch-2.raku
new file mode 100644
index 0000000000..da69540cc7
--- /dev/null
+++ b/challenge-209/laurent-rosenfeld/raku/ch-2.raku
@@ -0,0 +1,24 @@
+sub merge-account (@in) {
+ my %merged;
+ for @in -> @part {
+ my ($key, @values) = @part;
+ %merged{$key}{$_} = True for @values;
+ }
+ return %merged;
+}
+
+my @tests = ( <A a1@a.com a2@a.com>,
+ <B b1@b.com>,
+ <A a3@a.com a1@a.com> ),
+ ( <A a1@a.com a2@a.com>,
+ <B b1@b.com>,
+ <A a3@a.com>,
+ <B b2@b.com b1@b.com> );
+for @tests -> @test {
+ say @test, " => ";
+ my %merged = merge-account @test;
+ for %merged.keys.sort -> $k {
+ say "\t[", (join " ", $k, |%merged{$k}.keys.sort), "]";
+ };
+ say "";
+}
diff --git a/challenge-209/perlboy1967/ch1.pl b/challenge-209/perlboy1967/perl/ch-1.pl
index f46b3b1204..f46b3b1204 100755
--- a/challenge-209/perlboy1967/ch1.pl
+++ b/challenge-209/perlboy1967/perl/ch-1.pl
diff --git a/challenge-209/perlboy1967/ch2.pl b/challenge-209/perlboy1967/perl/ch-2.pl
index ece03dbfa5..ece03dbfa5 100755
--- a/challenge-209/perlboy1967/ch2.pl
+++ b/challenge-209/perlboy1967/perl/ch-2.pl
diff --git a/challenge-209/robert-dicicco/julia/ch-1.jl b/challenge-209/robert-dicicco/julia/ch-1.jl
new file mode 100644
index 0000000000..117757b376
--- /dev/null
+++ b/challenge-209/robert-dicicco/julia/ch-1.jl
@@ -0,0 +1,62 @@
+#!/usr/bin/env julia
+#=
+------------------------------------------
+AUTHOR: Robert DiCicco
+DATE ; 2023-03-21
+Challenge 209 Special Bit Chars ( Julia )
+------------------------------------------
+=#
+using Printf
+
+bits = [[1, 0, 0],[1, 1, 1, 0]]
+ln = length(bits)
+
+lastchar = ' '
+flag = 0
+for sub in bits
+ global lastchar
+ global flag
+ @printf("Input: @bits = %s\n", sub)
+ ref_len = length(sub)
+ #flag = 0
+ for x in (1:ref_len)
+ if sub[x] == 1
+ if flag == 0
+ flag = 1
+ else
+ @printf("%s",'c')
+ lastchar = 'c'
+ flag = 0
+ end
+ elseif sub[x] == 0
+ if flag == 0
+ @printf("%s",'a')
+ lastchar = 'a'
+ elseif flag == 1
+ @printf("%s",'b')
+ lastchar = 'b'
+ flag = 0
+ end
+ end
+ end
+ println(" ")
+ if (lastchar == 'a') && (flag == 0)
+ println("Output: 1")
+ else
+ println("Output: 0")
+ end
+ println(" ")
+end
+#=
+------------------------------------------
+SAMPLE OUTPUT
+julia .\SpecialBit.jl
+Input: @bits = [1, 0, 0]
+ba
+Output: 1
+
+Input: @bits = [1, 1, 1, 0]
+cb
+Output: 0
+------------------------------------------
+=#
diff --git a/challenge-209/robert-dicicco/perl/ch-1.pl b/challenge-209/robert-dicicco/perl/ch-1.pl
new file mode 100644
index 0000000000..29d06dee27
--- /dev/null
+++ b/challenge-209/robert-dicicco/perl/ch-1.pl
@@ -0,0 +1,68 @@
+#!/usr/bin/env perl
+=begin comment
+-------------------------------------------
+AUTHOR: Robert DiCicco
+DATE : 2023-03-21
+Challenge 209 Special Bit Chars ( Perl )
+-------------------------------------------
+=cut
+use strict;
+use warnings;
+use feature 'say';
+use Switch::Plain;
+
+my @bits = ([1, 0, 0],[1, 1, 1, 0]);
+
+my $ln = scalar @bits;
+
+my $flag;
+my $lastchar = '';
+for (0..$ln - 1) {
+ my $ref = $bits[$_];
+ print "Input: \@list1 = @$ref\n";
+ my $ref_len = scalar @$ref;
+ $flag = 0;
+
+ for my $x (0..$ref_len-1) {
+ nswitch($ref->[$x]) {
+ case 1: {
+ if ($flag == 0){
+ $flag = 1;
+ } else {
+ print 'c ';
+ $lastchar = 'c';
+ $flag = 0;
+ }
+ }
+ case 0: {
+ if ($flag == 0) {
+ print 'a ';
+ $lastchar = 'a';
+ } elsif ($flag == 1) {
+ print 'b ';
+ $lastchar = 'b';
+ $flag = 0;
+ }
+ }
+ }
+ }
+ if ($lastchar eq 'a' and $flag == 0) {
+ say "\nOutput: 1\n";
+ } else {
+ say "\nOutput: 0\n";
+ }
+}
+
+=begin comment
+-------------------------------------------
+SAMPLE OUTPUT
+perl .\SpecialBit.pl
+Input: @list1 = 1 0 0
+b a
+Output: 1
+
+Input: @list1 = 1 1 1 0
+c b
+Output: 0
+-------------------------------------------
+=cut
diff --git a/challenge-209/robert-dicicco/perl/ch-2.pl b/challenge-209/robert-dicicco/perl/ch-2.pl
new file mode 100644
index 0000000000..001d396351
--- /dev/null
+++ b/challenge-209/robert-dicicco/perl/ch-2.pl
@@ -0,0 +1,69 @@
+#!/usr/bin/env perl
+=begin comment
+----------------------------------------
+AUTHOR: Robert DiCicco
+DATE : 2023-03-25
+Challenge 209 Merge Account ( Perl )
+----------------------------------------
+=cut
+use strict;
+use warnings;
+use feature "say";
+use List::Uniq ':all';
+
+my $accounts = [ ["A", "a1\@a.com", "a2\@a.com"], ["B", "b1\@b.com"], ["A", "a3\@a.com", "a1\@a.com"] ];
+
+#my $accounts = [ ["A", "a1\@a.com", "a2\@a.com"], ["B", "b1\@b.com"], ["A", "a3\@a.com"], ["B", "b2\@b.com", "b1\@b.com"] ];
+
+my @a = ();
+my @temp = ();
+my @b = ();
+
+print "Input: ";
+for (@$accounts) {
+ print "[@$_ ]";
+}
+say " ";
+for (@$accounts) {
+ my @sub = @{$_};
+ my $ln = scalar @sub;
+ $ln -= 1;
+ if ($sub[0] eq 'A') {
+ @temp = map { $_ } @sub[1..$ln];
+ push(@a,@temp);
+ }
+ if ($sub[0] eq 'B') {
+ @temp = map { $_ } @sub[1..$ln];
+ push(@b,@temp);
+ }
+}
+
+print "Output: ";
+print "[[A ";
+for (uniq(@a)) {
+ print "$_ ";
+}
+print "]\n";
+
+print " [B ";
+for (uniq(@b)) {
+ print "$_ ";
+}
+print "]]\n";
+
+=begin comment
+----------------------------------------
+SAMPLE OUTPUT
+ perl .\MergeAccount.pl
+ PS G:\Projects\Perl\Challenges> perl .\MergeAccount.pl
+Input: [A a1@a.com a2@a.com ][B b1@b.com ][A a3@a.com a1@a.com ]
+Output: [[A a1@a.com a2@a.com a3@a.com ]
+ [B b1@b.com ]]
+
+Input: [A a1@a.com a2@a.com ][B b1@b.com ][A a3@a.com ][B b2@b.com b1@b.com ]
+Output: [[A a1@a.com a2@a.com a3@a.com ]
+ [B b1@b.com b2@b.com ]]
+=cut
+
+
+
diff --git a/challenge-209/robert-dicicco/python/ch-1.py b/challenge-209/robert-dicicco/python/ch-1.py
new file mode 100644
index 0000000000..4072aa31c7
--- /dev/null
+++ b/challenge-209/robert-dicicco/python/ch-1.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+#-------------------------------------------
+# AUTHOR: Robert DiCicco
+# DATE : 2023-03-21
+# Challenge 209 Special Bit Chars ( Python )
+#-------------------------------------------
+
+bits = [[1, 0, 0],[1, 1, 1, 0]]
+
+ln = len(bits)
+flag = 0
+
+for mysub in bits:
+ print("\nInput: @bits = ",mysub)
+ ref_len = len(mysub)
+ for x in range(ref_len):
+ if mysub[x] == 1:
+ if flag == 0 :
+ flag = 1
+ else:
+ print('c ',end='')
+ lastchar = 'c'
+ flag = 0
+
+ elif mysub[x] == 0:
+ if flag == 0:
+ print('a ',end='')
+ lastchar = 'a'
+ elif flag == 1:
+ print('b ',end='')
+ lastchar = 'b'
+ flag = 0
+ if lastchar == 'a' and flag == 0:
+ print("\nOutput: 1")
+ else:
+ print("\nOutput: 0")
+#-------------------------------------------
+# SAMPLE OUTPUT
+# python .\SpecialBit.py
+
+# Input: @bits = [1, 0, 0]
+# b a
+# Output: 1
+
+# Input: @bits = [1, 1, 1, 0]
+# c b
+# Output: 0
+#-------------------------------------------
diff --git a/challenge-209/robert-dicicco/raku/ch-1.raku b/challenge-209/robert-dicicco/raku/ch-1.raku
new file mode 100644
index 0000000000..4da46e73d2
--- /dev/null
+++ b/challenge-209/robert-dicicco/raku/ch-1.raku
@@ -0,0 +1,64 @@
+#!/usr/bin/env raku
+#`{
+-----------------------------------------
+AUTHOR: Robert DiCicco
+DATE : 2023-03-21
+Challenge 209 Special Bit Chars ( Raku )
+-----------------------------------------
+}
+
+my @bits = ([1, 0, 0],[1, 1, 1, 0]);
+
+my $ln = @bits.elems;
+
+my $flag = 0;
+my $lastchar = '';
+
+for (0..$ln - 1) -> $sub {
+ say "Input: \@list1 = \[@bits[$sub]\]";
+ my $ref_len = @bits[$sub].elems;
+ for (0..$ref_len-1) -> $x {
+ given (@bits[$sub][$x]) {
+ when 1 {
+ if ($flag == 0) {
+ $flag = 1;
+ } else {
+ print 'c '.gist;
+ $lastchar = 'c';
+ $flag = 0;
+ }
+ }
+ when 0 {
+ if ($flag == 0) {
+ print 'a '.gist;
+ $lastchar = 'a';
+ } elsif ($flag == 1) {
+ print 'b '.gist;
+ $lastchar = 'b';
+ $flag = 0;
+ }
+ }
+ }
+
+}
+say " ";
+if ($lastchar eq 'a' and $flag == 0) {
+ say "Output: 1";
+ } else {
+ say "Output: 0";
+ }
+ say " ";
+}
+#`{
+-----------------------------------------
+SAMPLE OUTPUT
+raku .\SpecialBit.rk
+Input: @list1 = [1 0 0]
+b a
+Output: 1
+
+Input: @list1 = [1 1 1 0]
+c b
+Output: 0
+-----------------------------------------
+}
diff --git a/challenge-209/robert-dicicco/raku/ch-2.raku b/challenge-209/robert-dicicco/raku/ch-2.raku
new file mode 100644
index 0000000000..1f91c9555e
--- /dev/null
+++ b/challenge-209/robert-dicicco/raku/ch-2.raku
@@ -0,0 +1,57 @@
+#!/usr/bin/env raku
+#`{
+-----------------------------------------
+AUTHOR: Robert DiCicco
+DATE : 2023-03-25
+Challenge 209 Merge Account ( Raku )
+-----------------------------------------
+}
+use v6;
+
+#my @accounts = [ ["A", "a1\@a.com", "a2\@a.com"], ["B", "b1\@b.com"], ["A", "a3\@a.com", "a1\@a.com"] ];
+
+my @accounts = [ ["A", "a1\@a.com", "a2\@a.com"], ["B", "b1\@b.com"], ["A", "a3\@a.com"], ["B", "b2\@b.com", "b1\@b.com"] ];
+