aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMyoungjin JEON <jeongoon@gmail.com>2020-07-27 16:10:03 +1000
committerMyoungjin JEON <jeongoon@gmail.com>2020-07-27 16:10:03 +1000
commit9f5aee78a5569f7e0c8f742dd907663bd1e04642 (patch)
tree8f864d8438c06983ab9438e1e9839628cfe18520
parentfde6b9fbc1e5fa1378acd6b1b5c6aed854f4f156 (diff)
parent450eab302dee5452d66be1f388cea4fafb0b5a31 (diff)
downloadperlweeklychallenge-club-9f5aee78a5569f7e0c8f742dd907663bd1e04642.tar.gz
perlweeklychallenge-club-9f5aee78a5569f7e0c8f742dd907663bd1e04642.tar.bz2
perlweeklychallenge-club-9f5aee78a5569f7e0c8f742dd907663bd1e04642.zip
Merge remote-tracking branch 'upstream/master'
-rw-r--r--challenge-065/mohammad-anwar/swift/ch-1.swift112
-rw-r--r--challenge-066/mohammad-anwar/swift/ch-1.swift82
-rw-r--r--challenge-068/mohammad-anwar/swift/ch-1.swift90
-rw-r--r--challenge-069/colin-crain/perl/ch-1.pl59
-rwxr-xr-xchallenge-069/jo-37/perl/ch-2.pl2
-rw-r--r--challenge-069/mohammad-anwar/swift/ch-1.swift73
-rw-r--r--challenge-069/simon-proctor/raku/ch-1.raku35
-rw-r--r--challenge-069/simon-proctor/raku/ch-2.raku15
-rw-r--r--challenge-070/arne-sommer/blog.txt1
-rwxr-xr-xchallenge-070/arne-sommer/node/ch-2.js62
-rwxr-xr-xchallenge-070/arne-sommer/node/gray-code-seq-node62
-rwxr-xr-xchallenge-070/arne-sommer/perl/ch-1.pl32
-rwxr-xr-xchallenge-070/arne-sommer/perl/ch-2.pl48
-rwxr-xr-xchallenge-070/arne-sommer/perl/charswap-perl32
-rwxr-xr-xchallenge-070/arne-sommer/perl/gray-code-seq-perl48
-rwxr-xr-xchallenge-070/arne-sommer/raku/ch-1.raku18
-rwxr-xr-xchallenge-070/arne-sommer/raku/ch-2.raku34
-rwxr-xr-xchallenge-070/arne-sommer/raku/charswap18
-rwxr-xr-xchallenge-070/arne-sommer/raku/charswap-mod25
-rwxr-xr-xchallenge-070/arne-sommer/raku/charswap-node38
-rwxr-xr-xchallenge-070/arne-sommer/raku/charswap-sans-mod24
-rwxr-xr-xchallenge-070/arne-sommer/raku/gray-code-seq34
-rw-r--r--challenge-070/athanasius/perl/ch-1.pl131
-rw-r--r--challenge-070/athanasius/perl/ch-2.pl125
-rw-r--r--challenge-070/athanasius/raku/ch-1.raku114
-rw-r--r--challenge-070/athanasius/raku/ch-2.raku113
-rw-r--r--challenge-070/bob-lied/README1
-rw-r--r--challenge-070/cheok-yin-fung/common-lisp/ch-2.lsp17
-rw-r--r--challenge-070/cheok-yin-fung/perl/ch-1.pl24
-rw-r--r--challenge-070/cheok-yin-fung/perl/ch-2.pl21
-rwxr-xr-xchallenge-070/dave-jacoby/perl/ch-1.pl65
-rwxr-xr-xchallenge-070/dave-jacoby/perl/ch-2.pl76
-rwxr-xr-xchallenge-070/e-choroba/perl/ch-1.pl77
-rwxr-xr-xchallenge-070/e-choroba/perl/ch-2.pl39
-rw-r--r--challenge-070/jo-37/perl/ch-1.pl26
-rwxr-xr-xchallenge-070/jo-37/perl/ch-2.pl62
-rw-r--r--challenge-070/luca-ferrari/blog-1.txt1
-rw-r--r--challenge-070/luca-ferrari/blog-2.txt1
-rw-r--r--challenge-070/luca-ferrari/raku/ch-1.p618
-rw-r--r--challenge-070/luca-ferrari/raku/ch-2.p623
-rw-r--r--challenge-070/mark-anderson/raku/ch-1.raku21
-rw-r--r--challenge-070/mark-anderson/raku/ch-2.raku15
-rw-r--r--challenge-070/mohammad-anwar/blog1.txt1
-rw-r--r--challenge-070/mohammad-anwar/blog2.txt1
-rw-r--r--challenge-070/mohammad-anwar/blog3.txt1
-rwxr-xr-xchallenge-070/mohammad-anwar/perl/ch-2a.pl4
-rwxr-xr-xchallenge-070/mohammad-anwar/raku/ch-1.raku28
-rwxr-xr-xchallenge-070/mohammad-anwar/raku/ch-1a.raku34
-rwxr-xr-xchallenge-070/mohammad-anwar/raku/ch-2.raku44
-rwxr-xr-xchallenge-070/mohammad-anwar/raku/ch-2a.raku49
-rwxr-xr-xchallenge-070/mohammad-anwar/swift/ch-1.swift63
-rw-r--r--challenge-070/noud/raku/ch-1.p644
-rw-r--r--challenge-070/noud/raku/ch-2.p651
-rwxr-xr-xchallenge-070/perlboy1967/perl/ch-1.pl61
-rwxr-xr-xchallenge-070/perlboy1967/perl/ch-2.pl38
-rw-r--r--challenge-070/pete-houston/perl/ch-1.pl46
-rw-r--r--challenge-070/pete-houston/perl/ch-2.pl34
-rw-r--r--challenge-070/roger-bell-west/blog.txt1
-rw-r--r--challenge-070/shahed-nooshmand/blog.txt1
-rw-r--r--challenge-070/shahed-nooshmand/raku/ch-1.raku3
-rw-r--r--challenge-070/shahed-nooshmand/raku/ch-2.raku1
-rw-r--r--challenge-070/simon-proctor/raku/ch-1.raku20
-rw-r--r--challenge-070/simon-proctor/raku/ch-2.raku18
-rw-r--r--challenge-070/ulrich-rieke/cpp/ch-1.cpp29
-rw-r--r--challenge-070/ulrich-rieke/perl/ch-1.pl23
-rw-r--r--challenge-070/ulrich-rieke/perl/ch-2.pl38
-rw-r--r--challenge-070/ulrich-rieke/raku/ch-1.raku16
-rw-r--r--challenge-070/ulrich-rieke/raku/ch-2.raku21
-rw-r--r--challenge-070/walt-mankowski/c/Makefile23
-rw-r--r--challenge-070/walt-mankowski/c/ch-1.c19
-rw-r--r--challenge-070/walt-mankowski/c/ch-2.c29
-rw-r--r--challenge-070/walt-mankowski/perl/ch-1.pl51
-rw-r--r--challenge-070/walt-mankowski/perl/ch-2.pl59
-rw-r--r--challenge-070/walt-mankowski/python/ch-1.py15
-rw-r--r--challenge-070/walt-mankowski/python/ch-2.py12
-rw-r--r--challenge-070/wanderdoc/perl/ch-1.pl63
-rw-r--r--challenge-070/wanderdoc/perl/ch-2.pl57
-rw-r--r--challenge-070/x1mandi/README1
-rw-r--r--challenge-070/x1mandi/perl/ch-1.pl44
-rw-r--r--members.json2
-rw-r--r--stats/pwc-challenge-069.json289
-rw-r--r--stats/pwc-current.json391
-rw-r--r--stats/pwc-language-breakdown-summary.json66
-rw-r--r--stats/pwc-language-breakdown.json482
-rw-r--r--stats/pwc-leaders.json496
-rw-r--r--stats/pwc-summary-1-30.json62
-rw-r--r--stats/pwc-summary-121-150.json74
-rw-r--r--stats/pwc-summary-151-180.json66
-rw-r--r--stats/pwc-summary-31-60.json66
-rw-r--r--stats/pwc-summary-61-90.json138
-rw-r--r--stats/pwc-summary-91-120.json82
-rw-r--r--stats/pwc-summary.json448
92 files changed, 4412 insertions, 1207 deletions
diff --git a/challenge-065/mohammad-anwar/swift/ch-1.swift b/challenge-065/mohammad-anwar/swift/ch-1.swift
new file mode 100644
index 0000000000..c353776ff9
--- /dev/null
+++ b/challenge-065/mohammad-anwar/swift/ch-1.swift
@@ -0,0 +1,112 @@
+import Foundation
+
+/*
+Perl Weekly Challenge - 065
+
+Task #1: Digits Sum
+
+https://perlweeklychallenge.org/blog/perl-weekly-challenge-065/
+*/
+
+do {
+ let paramCount:Int = Int(CommandLine.argc)
+
+ if paramCount <= 1 {
+ throw ParamError.missingDigitsAndSum
+ }
+ else if paramCount <= 2 {
+ throw ParamError.missingSum
+ }
+
+ let digits:String = String(CommandLine.arguments[1])
+ let sum:String = String(CommandLine.arguments[2])
+
+ let start:Int = try startIndex(d: digits)
+ let stop:Int = try stopIndex(d: digits)
+
+ print(digitsSum(start, stop, sum))
+}
+catch ParamError.missingDigitsAndSum {
+ print("Missing Digits and Sum")
+}
+catch ParamError.missingDigits {
+ print("Missing Digits")
+}
+catch ParamError.missingSum {
+ print("Missing Sum")
+}
+catch let error {
+ print(error)
+}
+
+//
+//
+// Functions
+
+enum ParamError: Error {
+ case missingDigitsAndSum
+ case missingDigits
+ case missingSum
+}
+
+func digitsSum(_ start:Int, _ stop:Int, _ sum:String) -> String {
+
+ var s:String = ""
+ for i in start...stop {
+ let _sum:String = sumDigits(n: String(i))
+ if sum == _sum {
+ if s == "" {
+ s = String(i)
+ }
+ else {
+ s = s + ", " + String(i)
+ }
+ }
+ }
+
+ return s
+}
+
+func startIndex(d digits:String) throws -> Int {
+
+ guard let count:Int = Int(digits) else {
+ throw ParamError.missingDigits
+ }
+
+ var index:String = "1"
+ for _ in 1..<count {
+ index = index + "0"
+ }
+
+ guard let s:Int = Int(index) else { return Int() }
+ return s
+}
+
+func stopIndex(d digits:String) throws -> Int {
+
+ guard let count:Int = Int(digits) else {
+ throw ParamError.missingDigits
+ }
+
+ var index:String = ""
+ for _ in 1...count {
+ index = index + "9"
+ }
+
+ guard let s:Int = Int(index) else { return Int() }
+ return s
+}
+
+func sumDigits(n number:String) -> String {
+
+ let digits = Array(number)
+ var sum:Int = 0
+
+ for i in digits {
+ if let i:Int = Int(String(i)) {
+ sum = sum + i
+ }
+ }
+
+ return String(sum)
+}
diff --git a/challenge-066/mohammad-anwar/swift/ch-1.swift b/challenge-066/mohammad-anwar/swift/ch-1.swift
new file mode 100644
index 0000000000..6436d29fcd
--- /dev/null
+++ b/challenge-066/mohammad-anwar/swift/ch-1.swift
@@ -0,0 +1,82 @@
+import Foundation
+
+/*
+Perl Weekly Challenge - 066
+
+Task #1: Divide Integers
+
+https://perlweeklychallenge.org/blog/perl-weekly-challenge-066/
+*/
+
+enum ParamError: Error {
+ case missingDividendAndDivisor
+ case missingDivisor
+ case invalidDividend
+ case invalidDivisor
+}
+
+do {
+ let paramCount:Int = Int(CommandLine.argc)
+
+ if paramCount <= 1 {
+ throw ParamError.missingDividendAndDivisor
+ }
+ else if paramCount <= 2 {
+ throw ParamError.missingDivisor
+ }
+
+ let dividend:Int = Int(CommandLine.arguments[1])!
+ let divisor:Int = Int(CommandLine.arguments[2])!
+
+ var abs_dividend = abs(dividend)
+ let abs_divisor = abs(divisor)
+
+ if abs_dividend < abs_divisor {
+ throw ParamError.invalidDividend
+ }
+
+ if divisor == 0 {
+ throw ParamError.invalidDivisor
+ }
+
+ var sign:String = "";
+ if dividend < 0 {
+ if divisor > 0 {
+ sign = "-"
+ }
+ }
+ else {
+ if divisor < 0 {
+ sign = "-"
+ }
+ }
+
+ var i:Int = 0
+ while abs_dividend >= abs_divisor {
+ i += 1
+ abs_dividend -= abs_divisor
+ }
+
+ if sign != "" {
+ i += 1
+ print(i)
+ }
+ else {
+ print(sign + String(i))
+ }
+}
+catch ParamError.missingDividendAndDivisor {
+ print("Missing Dividend and Divisor")
+}
+catch ParamError.missingDivisor {
+ print("Missing Divisor")
+}
+catch ParamError.invalidDividend {
+ print("Invalid Dividend. (Dividend > Divisor)")
+}
+catch ParamError.invalidDivisor {
+ print("Invalid Divisor. Divisor > 0")
+}
+catch let error {
+ print(error)
+}
diff --git a/challenge-068/mohammad-anwar/swift/ch-1.swift b/challenge-068/mohammad-anwar/swift/ch-1.swift
new file mode 100644
index 0000000000..ea0c701008
--- /dev/null
+++ b/challenge-068/mohammad-anwar/swift/ch-1.swift
@@ -0,0 +1,90 @@
+import Foundation
+
+/*
+Perl Weekly Challenge - 068
+
+Task #1: Zero Matrix
+
+https://perlweeklychallenge.org/blog/perl-weekly-challenge-068
+*/
+
+enum ParamError: Error {
+ case missingRowsandCols
+ case missingCols
+}
+
+var rows:Int = 0
+var cols:Int = 0
+var matrix = [[Int]]()
+
+do {
+ let paramCount:Int = Int(CommandLine.argc)
+
+ if paramCount <= 1 {
+ throw ParamError.missingRowsandCols
+ }
+ else if paramCount <= 2 {
+ throw ParamError.missingCols
+ }
+
+ rows = Int(CommandLine.arguments[1])!
+ cols = Int(CommandLine.arguments[2])!
+ matrix = generateMatrix(rows, cols)
+}
+catch ParamError.missingRowsandCols {
+ rows = 3
+ cols = 3
+ matrix = [[1, 0, 1], [1, 1, 1], [1, 0, 1]]
+}
+catch ParamError.missingCols {
+ rows = Int(CommandLine.arguments[1])!
+ cols = 3
+ matrix = generateMatrix(rows, cols)
+}
+
+var zeroMatrix:[[Int]] = initZeroMatrix(rows, cols)
+for r in 0..<rows {
+ for c in 0..<cols {
+ if matrix[r][c] == 0 {
+ // make zero row
+ for i in 0..<cols {
+ zeroMatrix[r][i] = 0
+ }
+ // make zero col
+ for j in 0..<rows {
+ zeroMatrix[j][c] = 0
+ }
+ }
+ }
+}
+
+print(zeroMatrix)
+
+
+// Functions
+
+func generateMatrix(_ rows:Int, _ cols:Int) -> [[Int]] {
+ var matrix = [[Int]]()
+ for _ in 1...rows {
+ var row:[Int] = []
+ for _ in 1...cols {
+ row.append(Int.random(in: 0..<2))
+ }
+ matrix.append(row)
+ }
+
+ return matrix
+}
+
+func initZeroMatrix(_ rows:Int, _ cols:Int) -> [[Int]] {
+ var matrix = [[Int]]()
+ for _ in 1...rows {
+ var row:[Int] = []
+ for _ in 1...cols {
+ row.append(1)
+ }
+ matrix.append(row)
+ }
+
+ return matrix
+}
diff --git a/challenge-069/colin-crain/perl/ch-1.pl b/challenge-069/colin-crain/perl/ch-1.pl
index c1a3c8d434..ef6497300d 100644
--- a/challenge-069/colin-crain/perl/ch-1.pl
+++ b/challenge-069/colin-crain/perl/ch-1.pl
@@ -28,65 +28,58 @@ use feature ":5.26";
## ## ## ## ## MAIN:
-my ($A, $B) = @ARGV; ## low, high bounds
-# ($A, $B) = (1000, 2000000000);
+my ($A, $B) = @ARGV; ## low, high bounds
+
# the order is the length of the half number that is modified and
-# joined to itself, with or without the pivot digit in the center.
-# Thus a given order will generate numbers up to 2n+1 places long, or
-# 10^(2n+1) The order is calculated to theoretically create numbers as
-# large as B. As this value scales by magnitude 100, this number can
-# be quite a bit larger, but will larger and we can guarantee none of
-# the next larger order will be required. It serves as an upper bound
+# joined to itself, with or without the pivot digit in the
+# center. Thus a given order will generate numbers up to 2n+1
+# places long, or numbers up to but less than 10^(2n+1) The order
+# is calculated to be large enough to create all numbers as large
+# as B. As the maximum of the range scales by magnitude 100, the
+# largest number created can still be quite a bit larger, but we
+# can guarantee it will be large enough and also that none of the
+# next larger order will be required. It serves as an upper bound
# to the calculation space.
my $order = int(length($B)/2);
my @list = (0, 1, 6, 8, 9);
my @center = (0, 1, 8);
-my @num = @list[1..@list-1]; ## remove leadin