aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-173/athanasius/perl/ch-1.pl129
-rw-r--r--challenge-173/athanasius/perl/ch-2.pl129
-rw-r--r--challenge-173/athanasius/raku/ch-1.raku103
-rw-r--r--challenge-173/athanasius/raku/ch-2.raku132
-rw-r--r--challenge-173/bruce-gray/raku/ch-1.raku37
-rw-r--r--challenge-173/bruce-gray/raku/ch-2.raku19
-rwxr-xr-xchallenge-173/colin-crain/perl/ch-1.pl55
-rwxr-xr-xchallenge-173/colin-crain/perl/ch-2.pl66
-rw-r--r--challenge-173/deadmarshal/ada/Ch2.gpr10
-rw-r--r--challenge-173/deadmarshal/ada/ch1.adb31
-rw-r--r--challenge-173/deadmarshal/ada/ch2.adb30
-rw-r--r--challenge-173/deadmarshal/c/Makefile12
-rw-r--r--challenge-173/deadmarshal/c/ch-1.c34
-rw-r--r--challenge-173/deadmarshal/c/ch-2.c53
-rw-r--r--challenge-173/deadmarshal/d/ch1.d32
-rw-r--r--challenge-173/deadmarshal/d/ch2.d14
-rw-r--r--challenge-173/deadmarshal/lua/ch-1.lua23
-rw-r--r--challenge-173/deadmarshal/lua/ch-2.lua24
-rw-r--r--challenge-173/deadmarshal/modula-3/ch1/src/Ch1.m340
-rw-r--r--challenge-173/deadmarshal/modula-3/ch1/src/m3makefile5
-rw-r--r--challenge-173/deadmarshal/modula-3/ch2/src/Ch2.m329
-rw-r--r--challenge-173/deadmarshal/modula-3/ch2/src/m3makefile5
-rw-r--r--challenge-173/deadmarshal/perl/ch-1.pl31
-rw-r--r--challenge-173/deadmarshal/perl/ch-2.pl15
-rw-r--r--challenge-173/habere-et-dispetire/raku/ch-1.raku15
-rw-r--r--challenge-173/habere-et-dispetire/raku/ch-2.raku9
-rwxr-xr-xchallenge-173/jo-37/perl/ch-1.pl83
-rwxr-xr-xchallenge-173/jo-37/perl/ch-2.pl51
-rw-r--r--challenge-173/laurent-rosenfeld/blog1.txt1
-rw-r--r--challenge-173/laurent-rosenfeld/d/ch-1.d22
-rw-r--r--challenge-173/laurent-rosenfeld/d/ch-2.d11
-rw-r--r--challenge-173/laurent-rosenfeld/dart/ch-2.dart1
-rw-r--r--challenge-173/laurent-rosenfeld/dc/ch-2.dc19
-rw-r--r--challenge-173/laurent-rosenfeld/go/ch-1.go26
-rw-r--r--challenge-173/laurent-rosenfeld/go/ch-2.go17
-rw-r--r--challenge-173/laurent-rosenfeld/javascript/ch-2.js7
-rw-r--r--challenge-173/laurent-rosenfeld/kotlin/ch-1.kt20
-rw-r--r--challenge-173/laurent-rosenfeld/kotlin/ch-2.kt10
-rw-r--r--challenge-173/laurent-rosenfeld/lua/ch-2.lua7
-rw-r--r--challenge-173/laurent-rosenfeld/nim/ch-1.nim15
-rw-r--r--challenge-173/laurent-rosenfeld/nim/ch-2.nim7
-rw-r--r--challenge-173/laurent-rosenfeld/tcl/ch-2.tcl6
-rw-r--r--challenge-173/lubos-kolouch/perl/ch-1.pl22
-rw-r--r--challenge-173/lubos-kolouch/perl/ch-2.pl34
-rw-r--r--challenge-173/lubos-kolouch/python/ch-1.py15
-rw-r--r--challenge-173/lubos-kolouch/python/ch-2.py28
-rw-r--r--challenge-173/massa/raku/ch-1.raku4
-rw-r--r--challenge-173/massa/raku/ch-2.raku3
-rw-r--r--challenge-173/mohammad-anwar/java/theweeklychallenge/EstheticNumber.java50
-rw-r--r--challenge-173/mohammad-anwar/java/theweeklychallenge/SylvesterSequence.java65
-rw-r--r--challenge-173/mohammad-anwar/perl/ch-2.pl48
-rw-r--r--challenge-173/mohammad-anwar/python/ch-2.py44
-rw-r--r--challenge-173/mohammad-anwar/raku/ch-2.raku45
-rw-r--r--challenge-173/mohammad-anwar/swift/ch-1.swift63
-rw-r--r--challenge-173/roger-bell-west/blog.txt1
-rwxr-xr-xchallenge-173/roger-bell-west/javascript/ch-1.js60
-rwxr-xr-xchallenge-173/roger-bell-west/javascript/ch-2.js56
-rw-r--r--challenge-173/roger-bell-west/kotlin/ch-1.kt60
-rw-r--r--challenge-173/roger-bell-west/kotlin/ch-2.kt31
-rwxr-xr-xchallenge-173/roger-bell-west/lua/ch-1.lua56
-rwxr-xr-xchallenge-173/roger-bell-west/perl/ch-1.pl47
-rwxr-xr-xchallenge-173/roger-bell-west/perl/ch-2.pl32
-rw-r--r--challenge-173/roger-bell-west/postscript/ch-1.ps74
-rwxr-xr-xchallenge-173/roger-bell-west/python/ch-1.py38
-rwxr-xr-xchallenge-173/roger-bell-west/python/ch-2.py27
-rwxr-xr-xchallenge-173/roger-bell-west/raku/ch-1.p646
-rwxr-xr-xchallenge-173/roger-bell-west/raku/ch-2.p628
-rwxr-xr-xchallenge-173/roger-bell-west/ruby/ch-1.rb46
-rwxr-xr-xchallenge-173/roger-bell-west/ruby/ch-2.rb30
-rwxr-xr-xchallenge-173/roger-bell-west/rust/ch-1.rs47
-rw-r--r--challenge-173/roger-bell-west/rust/ch-2.rs28
-rw-r--r--challenge-173/sgreen/README.md4
-rw-r--r--challenge-173/sgreen/blog.txt1
-rwxr-xr-xchallenge-173/sgreen/perl/ch-1.pl24
-rwxr-xr-xchallenge-173/sgreen/perl/ch-2.pl22
-rwxr-xr-xchallenge-173/sgreen/python/ch-1.py21
-rwxr-xr-xchallenge-173/sgreen/python/ch-2.py18
-rw-r--r--challenge-173/walt-mankowski/README.md2
-rw-r--r--challenge-173/wambash/raku/ch-1.raku19
-rw-r--r--challenge-173/wambash/raku/ch-2.raku25
-rw-r--r--stats/pwc-current.json536
-rw-r--r--stats/pwc-language-breakdown-summary.json66
-rw-r--r--stats/pwc-language-breakdown.json2410
-rw-r--r--stats/pwc-leaders.json772
-rw-r--r--stats/pwc-summary-1-30.json116
-rw-r--r--stats/pwc-summary-121-150.json110
-rw-r--r--stats/pwc-summary-151-180.json34
-rw-r--r--stats/pwc-summary-181-210.json100
-rw-r--r--stats/pwc-summary-211-240.json130
-rw-r--r--stats/pwc-summary-241-270.json46
-rw-r--r--stats/pwc-summary-31-60.json48
-rw-r--r--stats/pwc-summary-61-90.json48
-rw-r--r--stats/pwc-summary-91-120.json44
-rw-r--r--stats/pwc-summary.json66
94 files changed, 5007 insertions, 2168 deletions
diff --git a/challenge-173/athanasius/perl/ch-1.pl b/challenge-173/athanasius/perl/ch-1.pl
new file mode 100644
index 0000000000..ece58cccaa
--- /dev/null
+++ b/challenge-173/athanasius/perl/ch-1.pl
@@ -0,0 +1,129 @@
+#!perl
+
+###############################################################################
+=comment
+
+Perl Weekly Challenge 173
+=========================
+
+TASK #1
+-------
+*Esthetic Number*
+
+Submitted by: Mohammad S Anwar
+
+You are given a positive integer, $n.
+
+Write a script to find out if the given number is Esthetic Number.
+
+
+ An esthetic number is a positive integer where every adjacent digit differs
+ from its neighbour by 1.
+
+
+For example,
+
+ 5456 is an esthetic number as |5 - 4| = |4 - 5| = |5 - 6| = 1
+ 120 is not an esthetic number as |1 - 2| != |2 - 0| != 1
+
+=cut
+###############################################################################
+
+#--------------------------------------#
+# Copyright © 2022 PerlMonk Athanasius #
+#--------------------------------------#
+
+#==============================================================================
+=comment
+
+Note on Leading Zeros
+---------------------
+$n might be input as "0345434", which would fail the esthetic test because
+|0 - 3| != 1. But since $n is specified as a positive integer, I have chosen to
+interpret "0345434" as 345434, which passes the test.
+
+Algorithm
+---------
+This is straightforward: test each digit from first to second-last against its
+successor: if the absolute value of the difference between them is not 1, $n is
+not esthetic; if all digits pass this test, $n is esthetic.
+
+Note that "differs from its neighbour by 1" is a commutative operation, so it
+is only necessary to test the digits in one direction.
+
+=cut
+#==============================================================================
+
+use strict;
+use warnings;
+use Const::Fast;
+use Regexp::Common qw( number );
+
+const my $USAGE =>
+"Usage:
+ perl $0 <n>
+
+ <n> A positive integer\n";
+
+#------------------------------------------------------------------------------
+BEGIN
+#------------------------------------------------------------------------------
+{
+ $| = 1;
+ print "\nChallenge 173, Task #1: Esthetic Number (Perl)\n\n";
+}
+
+#==============================================================================
+MAIN:
+#==============================================================================
+{
+ my $n = parse_command_line();
+ my $esthetic = is_esthetic( $n );
+
+ printf "%d is%s an esthetic number\n", $n, $esthetic ? '' : ' not';
+}
+
+#------------------------------------------------------------------------------
+sub is_esthetic
+#------------------------------------------------------------------------------
+{
+ my ($n) = @_;
+ my @digits = split //, $n;
+
+ for my $i (0 .. $#digits - 1)
+ {
+ return 0 unless abs( $digits[ $i ] - $digits[ $i + 1 ] ) == 1;
+ }
+
+ return 1;
+}
+
+#------------------------------------------------------------------------------
+sub parse_command_line
+#------------------------------------------------------------------------------
+{
+ my $args = scalar @ARGV;
+ $args == 1 or error( "Expected 1 command line argument, found $args" );
+
+ my $n = $ARGV[ 0 ];
+
+ $n =~ / ^ $RE{num}{int} $ /x
+ or error( qq[Argument "$n" is not a valid integer] );
+
+ $n > 0 or error( qq[Argument "$n" is not positive] );
+
+ $n += 0; # Remove any initial zeros
+
+ return $n;
+}
+
+#------------------------------------------------------------------------------
+sub error
+#------------------------------------------------------------------------------
+{
+ my ($message) = @_;
+
+ die "ERROR: $message\n$USAGE";
+}
+
+###############################################################################
diff --git a/challenge-173/athanasius/perl/ch-2.pl b/challenge-173/athanasius/perl/ch-2.pl
new file mode 100644
index 0000000000..c8419c9352
--- /dev/null
+++ b/challenge-173/athanasius/perl/ch-2.pl
@@ -0,0 +1,129 @@
+#!perl
+
+###############################################################################
+=comment
+
+Perl Weekly Challenge 173
+=========================
+
+TASK #2
+-------
+*Sylvester’s sequence*
+
+Submitted by: Mohammad S Anwar
+
+Write a script to generate first 10 members of Sylvester's sequence. For more
+informations, please refer to the [ https://en.wikipedia.org/wiki/Sylvester
+%27s_sequence |wikipedia page].
+
+Output
+
+ 2
+ 3
+ 7
+ 43
+ 1807
+ 3263443
+ 10650056950807
+ 113423713055421844361000443
+ 12864938683278671740537145998360961546653259485195807
+ 165506647324519964198468195444439180017513152706377497841851388766535868639
+ 572406808911988131737645185443
+
+=cut
+###############################################################################
+
+#--------------------------------------#
+# Copyright © 2022 PerlMonk Athanasius #
+#--------------------------------------#
+
+#==============================================================================
+=comment
+
+Interface
+---------
+Since numbers in Sylvester's sequence quickly become very large, they may be
+easier to read with their digits separated into groups of 3. To do this, set
+the constant $SEP to the value of the separator required (e.g., a comma or a
+space).
+
+Algorithm
+---------
+Large numbers are accommodated via the "use bigint;" pragma.
+
+Successive elements of Sylvester's sequence are calculated using the recurrence
+relation:
+
+ a(n+1) = a(n)² - a(n) + 1
+
+from [1]. This is re-arranged to the equivalent:
+
+ a(n+1) = a(n) × (a(n) - 1) + 1.
+
+References
+----------
+[1] "A000058 Sylvester's sequence: a(n+1) = a(n)^2 - a(n) + 1, with a(0) = 2.",
+ OEIS, https://oeis.org/A000058
+[2] "Sylvester's sequence", Wikipedia,
+ https://en.wikipedia.org/wiki/Sylvester%27s_sequence
+
+=cut
+#==============================================================================
+
+use strict;
+use warnings;
+use bigint;
+use Const::Fast;
+
+const my $SEP => '';
+const my $TARGET => 10;
+const my $USAGE => "Usage:\n perl $0\n";
+const my $WRAP => 72;
+
+#------------------------------------------------------------------------------
+BEGIN
+#------------------------------------------------------------------------------
+{
+ $| = 1;
+ print "\nChallenge 173, Task #2: Sylvester's sequence (Perl)\n\n";
+}
+
+#==============================================================================
+MAIN:
+#==============================================================================
+{
+ my $args = scalar @ARGV;
+ $args == 0 or die 'ERROR: Expected 0 command line arguments, found ' .
+ "$args\n$USAGE";
+
+ print "The first $TARGET numbers of Sylvester's sequence:\n";
+
+ my $sylvester = 2;
+
+ printf "%2d: %d\n", 1, $sylvester;
+
+ for my $i (2 .. $TARGET)
+ {
+ $sylvester *= $sylvester - 1;
+ ++$sylvester;
+
+ my $string = $SEP ? add_separators( $sylvester, $SEP ) : $sylvester;
+ $string = substr( $string, 0, $WRAP ) . "\n " .
+ substr( $string, $WRAP ) if length $string > $WRAP;
+
+ printf "%2d: %s\n", $i, $string;
+ }
+}
+
+#-------------------------------------------------------------------------------
+sub add_separators
+#-------------------------------------------------------------------------------
+{
+ my ($num, $sep) = @_;
+
+ # Regex from perlfaq5: "How can I output my numbers with commas added?"
+
+ return $num =~ s/(^\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1$sep/gr;
+}
+
+###############################################################################
diff --git a/challenge-173/athanasius/raku/ch-1.raku b/challenge-173/athanasius/raku/ch-1.raku
new file mode 100644
index 0000000000..5275f1e309
--- /dev/null
+++ b/challenge-173/athanasius/raku/ch-1.raku
@@ -0,0 +1,103 @@
+use v6d;
+
+###############################################################################
+=begin comment
+
+Perl Weekly Challenge 173
+=========================
+
+TASK #1
+-------
+*Esthetic Number*
+
+Submitted by: Mohammad S Anwar
+
+You are given a positive integer, $n.
+
+Write a script to find out if the given number is Esthetic Number.
+
+
+ An esthetic number is a positive integer where every adjacent digit differs
+ from its neighbour by 1.
+
+
+For example,
+
+ 5456 is an esthetic number as |5 - 4| = |4 - 5| = |5 - 6| = 1
+ 120 is not an esthetic number as |1 - 2| != |2 - 0| != 1
+
+=end comment
+###############################################################################
+
+#--------------------------------------#
+# Copyright © 2022 PerlMonk Athanasius #
+#--------------------------------------#
+
+#==============================================================================
+=begin comment
+
+Note on Leading Zeros
+---------------------
+$n might be input as "0345434", which would fail the esthetic test because
+|0 - 3| != 1. But since $n is specified as a positive integer, I have chosen to
+interpret "0345434" as 345434, which passes the test.
+
+Algorithm
+---------
+This is straightforward: test each digit from first to second-last against its
+successor: if the absolute value of the difference between them is not 1, $n is
+not esthetic; if all digits pass this test, $n is esthetic.
+
+Note that "differs from its neighbour by 1" is a commutative operation, so it
+is only necessary to test the digits in one direction.
+
+=end comment
+#=============================================================================