aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrbaggy <js5@sanger.ac.uk>2022-06-07 19:58:39 +0100
committerdrbaggy <js5@sanger.ac.uk>2022-06-07 19:58:39 +0100
commita396a798a421f65fa639aad2222b92fc156af20c (patch)
tree9cf6b6eecb431fc2e470d2cf8de9e48d1951bea3
parent26c48d1d97f7882cfd69edea26b78cf7a5095b69 (diff)
parentfe5f85a0913b16129fd528a9f43472c3012bd2de (diff)
downloadperlweeklychallenge-club-a396a798a421f65fa639aad2222b92fc156af20c.tar.gz
perlweeklychallenge-club-a396a798a421f65fa639aad2222b92fc156af20c.tar.bz2
perlweeklychallenge-club-a396a798a421f65fa639aad2222b92fc156af20c.zip
Merge remote-tracking branch 'upstream/master'
-rwxr-xr-xchallenge-168/2colours/raku/ch-1.raku8
-rwxr-xr-xchallenge-168/2colours/raku/ch-2.raku20
-rwxr-xr-xchallenge-168/eric-cheung/python/ch-1.py39
-rwxr-xr-xchallenge-168/eric-cheung/python/ch-2.py57
-rw-r--r--challenge-168/pokgopun/go/ch-1.go42
-rw-r--r--challenge-168/pokgopun/go/ch-2.go150
-rw-r--r--challenge-168/robert-dicicco/julia/ch-1.jl37
-rw-r--r--challenge-168/robert-dicicco/julia/ch-2.jl45
-rw-r--r--challenge-168/robert-dicicco/perl/ch-1.pl47
-rw-r--r--challenge-168/robert-dicicco/perl/ch-2.pl51
-rw-r--r--challenge-168/robert-dicicco/raku/ch-1.raku41
-rw-r--r--challenge-168/robert-dicicco/raku/ch-2.raku51
-rw-r--r--challenge-168/robert-dicicco/ruby/ch-1.rb37
-rw-r--r--challenge-168/steve-g-lynn/README1
-rwxr-xr-xchallenge-168/steve-g-lynn/perl/ch-1.pl59
-rwxr-xr-xchallenge-168/steve-g-lynn/raku/ch-1.p645
-rwxr-xr-xchallenge-168/wlmb/perl/ch-2.pl2
-rw-r--r--members.json1
-rw-r--r--stats/pwc-current.json169
-rw-r--r--stats/pwc-language-breakdown-summary.json64
-rw-r--r--stats/pwc-language-breakdown.json2336
-rw-r--r--stats/pwc-leaders.json374
-rw-r--r--stats/pwc-summary-1-30.json46
-rw-r--r--stats/pwc-summary-121-150.json40
-rw-r--r--stats/pwc-summary-151-180.json86
-rw-r--r--stats/pwc-summary-181-210.json120
-rw-r--r--stats/pwc-summary-211-240.json106
-rw-r--r--stats/pwc-summary-241-270.json50
-rw-r--r--stats/pwc-summary-31-60.json114
-rw-r--r--stats/pwc-summary-61-90.json118
-rw-r--r--stats/pwc-summary-91-120.json44
-rw-r--r--stats/pwc-summary.json582
32 files changed, 2906 insertions, 2076 deletions
diff --git a/challenge-168/2colours/raku/ch-1.raku b/challenge-168/2colours/raku/ch-1.raku
new file mode 100755
index 0000000000..b5c7508be4
--- /dev/null
+++ b/challenge-168/2colours/raku/ch-1.raku
@@ -0,0 +1,8 @@
+#!/usr/bin/env raku
+
+my @perrin-seq = 3, 0, 2, { $^c; $^a + $^b } ... *;
+my @result <==
+ @perrin-seq.grep: &is-prime
+ andthen .unique.head: 13
+ andthen .sort;
+say "f(13) = [{@result.join: ', '}]"; \ No newline at end of file
diff --git a/challenge-168/2colours/raku/ch-2.raku b/challenge-168/2colours/raku/ch-2.raku
new file mode 100755
index 0000000000..ddc4ecd2a7
--- /dev/null
+++ b/challenge-168/2colours/raku/ch-2.raku
@@ -0,0 +1,20 @@
+#!/usr/bin/env raku
+
+multi prime-factors(Int() $num) { samewith $num, 1 }
+multi prime-factors(1, $) { () }
+multi prime-factors($num where *.&is-prime, $) { ($num, ) }
+multi prime-factors($num is copy, $lower-bound) {
+ my $first-factor = ($lower-bound ^.. *).first: $num %% *;
+ my $first-exponent = 0;
+ while $num %% $first-factor {
+ $first-exponent++;
+ $num div= $first-factor;
+ }
+ |($first-factor xx $first-exponent), |prime-factors($num, $first-factor)
+}
+
+multi home-prime($num where *.&is-prime) { $num }
+multi home-prime($num) { samewith [~] prime-factors $num}
+
+my $n = prompt 'N = ';
+say home-prime($n); \ No newline at end of file
diff --git a/challenge-168/eric-cheung/python/ch-1.py b/challenge-168/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..df5ae80e8e
--- /dev/null
+++ b/challenge-168/eric-cheung/python/ch-1.py
@@ -0,0 +1,39 @@
+
+## Remarks
+## https://en.wikipedia.org/wiki/Perrin_number
+
+import math
+
+def IsPrime(nInput):
+
+ for nDiv in range(2, int(math.sqrt(nInput)) + 1):
+ if nInput % nDiv == 0:
+ return False
+
+ return True
+
+arrPerrinPrime = []
+arrPerrinNum = []
+
+arrPerrinNum.append(3)
+arrPerrinNum.append(0)
+arrPerrinNum.append(2)
+
+arrPerrinPrime.append(2)
+arrPerrinPrime.append(3)
+
+while len(arrPerrinPrime) < 13:
+ nNuNum = arrPerrinNum[-2] + arrPerrinNum[-3]
+ arrPerrinNum.append(nNuNum)
+
+ if not IsPrime(nNuNum):
+ continue
+
+ nCount = arrPerrinPrime.count(nNuNum)
+
+ if nCount > 0:
+ continue
+
+ arrPerrinPrime.append(nNuNum)
+
+print (arrPerrinPrime)
diff --git a/challenge-168/eric-cheung/python/ch-2.py b/challenge-168/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..4bcd6f1e3a
--- /dev/null
+++ b/challenge-168/eric-cheung/python/ch-2.py
@@ -0,0 +1,57 @@
+
+## Remarks
+## https://en.wikipedia.org/wiki/Home_prime
+
+import math
+
+def IsPrime(nInput):
+
+ for nDiv in range(2, int(math.sqrt(nInput)) + 1):
+ if nInput % nDiv == 0:
+ return False
+
+ return True
+
+
+def PrimeFact(nOrigInput):
+
+ nInput = nOrigInput
+ arrPrimeFact = []
+
+ for nDiv in range(2, nOrigInput):
+
+ while nInput % nDiv == 0 and nInput > 0:
+
+ nInput = nInput / nDiv
+ arrPrimeFact.append(nDiv)
+
+ if nInput == 0:
+ break
+
+ return arrPrimeFact
+
+
+def ConcatArray(arrInput):
+
+ strResult = ""
+
+ for arrElem in arrInput:
+ strResult = strResult + str(arrElem)
+
+ return int(strResult)
+
+
+## print (PrimeFact(511))
+## print (ConcatArray(PrimeFact(511)))
+## print (ConcatArray(PrimeFact(8)))
+
+
+nOrigInputNum = 10
+
+nInputNum = nOrigInputNum
+
+while not IsPrime(nInputNum):
+ nInputNum = ConcatArray(PrimeFact(nInputNum))
+
+print ("HP(" + str(nOrigInputNum) + ") = " + str(nInputNum))
+
diff --git a/challenge-168/pokgopun/go/ch-1.go b/challenge-168/pokgopun/go/ch-1.go
new file mode 100644
index 0000000000..39b69a4633
--- /dev/null
+++ b/challenge-168/pokgopun/go/ch-1.go
@@ -0,0 +1,42 @@
+package main
+
+import (
+ "fmt"
+ "math/big"
+ "os"
+ "sort"
+)
+
+func main() {
+ l := 13
+ if len(os.Args) > 1 {
+ fmt.Sscanf(os.Args[1], "%d", &l)
+ }
+ p := [3]uint{3, 0, 2}
+ pp := map[uint]struct{}{}
+ e := 0.25
+ i, n := 0, 1
+ for len(pp) < l && i < 1_000_000 {
+ i++
+ for float64(e) > 1/float64(p[0]) {
+ e *= 0.25
+ n++
+ }
+ //fmt.Printf("p0=%v,n=%v\n", p[0], n)
+ if big.NewInt(int64(p[0])).ProbablyPrime(n) {
+ pp[p[0]] = struct{}{}
+ }
+ p = [3]uint{p[1], p[2], p[0] + p[1]}
+ }
+ ppl := make([]uint, len(pp))
+ var j int
+ for k := range pp {
+ ppl[j] = k
+ j++
+ }
+ sort.SliceStable(ppl, func(i, j int) bool {
+ return ppl[i] < ppl[j]
+ })
+ fmt.Println(ppl)
+ //fmt.Println(len(pp))
+}
diff --git a/challenge-168/pokgopun/go/ch-2.go b/challenge-168/pokgopun/go/ch-2.go
new file mode 100644
index 0000000000..59d4413c81
--- /dev/null
+++ b/challenge-168/pokgopun/go/ch-2.go
@@ -0,0 +1,150 @@
+package main
+
+import (
+ "fmt"
+ "log"
+ "math"
+ "math/big"
+ "os"
+ "strconv"
+)
+
+func main() {
+ var hp homePrime
+ hp.buildPrime(5_000_000, 0)
+ //fmt.Println(hp.plist, len(hp.plist))
+ if len(os.Args) > 1 {
+ for _, v := range os.Args[1:] {
+ n, err := strconv.Atoi(v)
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Printf("HP(%d) = %d\n", n, hp.find(n))
+ }
+ } else {
+ for i := 1; i <= 47; i++ {
+ fmt.Printf("HP(%d) = %d\n", i, hp.find(i))
+ }
+ }
+}
+
+func (hp homePrime) find(n int) *big.Int {
+ bi := big.NewInt(int64(n))
+ if n == 1 {
+ return bi
+ }
+ i := 1
+ e := big.NewInt(4)
+ for e.Cmp(bi) == -1 {
+ e.Mul(e, big.NewInt(4))
+ i++
+ }
+ for !bi.ProbablyPrime(i) {
+ var str string
+ f := hp.factor(bi)
+ //fmt.Println(f)
+ for _, v := range f {
+ str += strconv.Itoa(int(v))
+ }
+ //fmt.Println(str)
+ _, ok := bi.SetString(str, 0)
+ if !ok {
+ //fmt.Println("Failed on SetString for", bi)
+ return big.NewInt(-1)
+ }
+ }
+ return bi
+}
+
+func (hp *homePrime) buildPrime(n int, o int) {
+ hp.pmap = make([]bool, int(n)+1)
+ //for i := 2; i <= n; i++ {
+ for i := 1; i <= n; i++ {
+ hp.pmap[i] = true
+ }
+ if o < 1 {
+ hp.pmap[1] = false
+ }
+ //for i := 2; float64(i) <= math.Sqrt(float64(n)); i++ {
+ for i := 2; float64(i) <= math.Sqrt(float64(n+o)); i++ {
+ j := i * i
+ /*
+ for j <= n {
+ hp.pmap[j] = false
+ j += i
+ }
+ */
+ for j <= n+o {
+ if j > o {
+ hp.pmap[j-o] = false
+ }
+ j += i
+ }
+ }
+ hp.plist = []int{}
+ /*
+ for i := 2; i < len(hp.pmap); i++ {
+ if hp.pmap[i] {
+ hp.plist = append(hp.plist, i)
+ }
+ }
+ */
+ for i := 1; i < len(hp.pmap); i++ {
+ if hp.pmap[i] {
+ hp.plist = append(hp.plist, i+o)
+ }
+ }
+}
+
+func (hp *homePrime) factor(n *big.Int) (s []int) {
+ if n.Cmp(big.NewInt(1)) == 1 {
+ j := 1
+ e := big.NewInt(4)
+ for e.Cmp(n) == -1 {
+ e.Mul(e, big.NewInt(4))
+ j++
+ //fmt.Println("In factor's e calculation => e=", e)
+ }
+ if n.ProbablyPrime(j) {
+ return []int{int(n.Int64())}
+ }
+ i := 0
+ m := new(big.Int)
+ nextPrime := big.NewInt(2)
+ if hp.plist[0] != 2 {
+ hp.buildPrime(5_000_000, 0)
+ }
+ o := 0
+ for {
+ if m.Mod(n, nextPrime).Cmp(big.NewInt(0)) != 0 {
+ i++
+ if i+1 > len(hp.plist) {
+ if o < 100_000_000_000 {
+ //hp.buildPrime(l * 1_000)
+ o += 5_000_000
+ hp.buildPrime(5_000_000, o)
+ i = 0
+ } else {
+ return []int{}
+ }
+ }
+ nextPrime = big.NewInt(int64(hp.plist[i]))
+ } else {
+ s = append(s, int(nextPrime.Int64()))
+ n.Div(n, nextPrime)
+ if n.Cmp(big.NewInt(1)) == 0 {
+ break
+ } else if n.ProbablyPrime(j) {
+ s = append(s, int(n.Int64()))
+ break
+ }
+ }
+ }
+ }
+ return s
+}
+
+type homePrime struct {
+ pmap []bool
+ plist []int
+}
diff --git a/challenge-168/robert-dicicco/julia/ch-1.jl b/challenge-168/robert-dicicco/julia/ch-1.jl
new file mode 100644
index 0000000000..45d1bbcd64
--- /dev/null
+++ b/challenge-168/robert-dicicco/julia/ch-1.jl
@@ -0,0 +1,37 @@
+#!julia.exe
+
+# AUTHOR: Robert DiCicco
+# DATE: 2022-06-06
+# Challenge 168 Perrin Primes ( Julia )
+
+using Primes
+
+perrin = [3,0,2]
+
+results = []
+
+PRIME_COUNT = 13
+
+i = 0
+
+while i <= PRIME_COUNT
+
+ slots = size(perrin,1)
+
+ calc_val = perrin[slots - 1] + perrin[slots - 2] # since julia arrays are option base 1
+
+ push!(perrin,calc_val)
+
+ if isprime(calc_val)
+
+ push!(results,calc_val)
+
+ global i += 1
+
+ end
+
+end
+
+results = unique!(sort(results))
+
+println(results)
diff --git a/challenge-168/robert-dicicco/julia/ch-2.jl b/challenge-168/robert-dicicco/julia/ch-2.jl
new file mode 100644
index 0000000000..e486810da1
--- /dev/null
+++ b/challenge-168/robert-dicicco/julia/ch-2.jl
@@ -0,0 +1,45 @@
+#!julia.exe
+
+# AUTHOR: Robert DiCicco
+# DATE: 2022-06-07
+# Challenge 168 Home Primes ( Julia )
+
+using Primes
+
+results = []
+
+function homeprime( hp )
+
+ temp = []
+
+ s = " "
+
+ temp = factor(Array, hp)
+
+ for i in 1:length(temp)
+
+ s = s * repr(temp[i])
+
+ end
+
+ return(parse(Int64, s))
+
+end
+
+hp = 8
+
+flag = 1
+
+push!(results,hp)
+
+while flag > 0
+
+ retval = homeprime(hp)
+
+ push!(results,retval)
+
+ isprime(retval) ? (global flag = 0) : (global hp = retval)
+
+end
+
+println(results)
diff --git a/challenge-168/robert-dicicco/perl/ch-1.pl b/challenge-168/robert-dicicco/perl/ch-1.pl
new file mode 100644
index 0000000000..b72ac33280
--- /dev/null
+++ b/challenge-168/robert-dicicco/perl/ch-1.pl
@@ -0,0 +1,47 @@
+#!perl.exe
+
+# AUTHOR: Robert DiCicco
+# DATE: 2022-06-06
+# Challenge 168 Perrin Primes ( Perl )
+
+use strict;
+use warnings;
+use feature qw/say/;
+use ntheory qw/is_prime/;
+use List::MoreUtils qw(uniq);
+
+my @perrin = qw(3 0 2 ); # working array
+
+my @results = ();
+
+my $i = 0;
+
+my $PRIME_COUNT = 13;
+
+while($i <= $PRIME_COUNT) {
+
+ my $slots = scalar(@perrin);
+
+ my $calc_val = $perrin[$slots - 2] + $perrin[$slots - 3];
+
+ push(@perrin, $calc_val);
+
+ if (is_prime($calc_val)) {
+
+ push(@results, $calc_val);
+
+ $i++;
+
+ }
+
+}
+
+@results = sort { $a <=> $b } uniq(@results);
+
+foreach(@results) {
+
+ print("$_ ");
+
+}
+
+print("\n");
diff --git a/challenge-168/robert-dicicco/perl/ch-2.pl b/challenge-168/robert-dicicco/perl/ch-2.pl
new file mode 100644
index 0000000000..8ecf170a47
--- /dev/null
+++ b/challenge-168/robert-dicicco/perl/ch-2.pl
@@ -0,0 +1,51 @@
+#!perl.exe
+
+# AUTHOR: Robert DiCicco
+# DATE: 2022-06-06
+# Challenge 168 Home Prime ( Perl )
+
+use strict;
+use warnings;
+use ntheory qw/is_prime factor divisors/;
+
+my $hp = 8;
+my @results;
+
+sub homeprime {
+ my $hp = shift;
+
+ my @factors = factor($hp);
+
+ my $hp_new = join('',@factors);
+
+ return($hp_new);
+
+}
+
+my $flag = 1;
+
+push(@results, $hp);
+
+while ( $flag > 0) {
+
+ my $retval = homeprime($hp);
+
+ if ( is_prime($retval) ){
+
+ push(@results, $retval);
+
+ $flag = 0;
+
+ } else {
+
+ push(@results, $retval);
+
+ $hp = $retval;
+
+ }
+
+}
+
+ print ("@results ");
+
+ print("\n");
diff --git a/challenge-168/robert-dicicco/raku/ch-1.raku b/challenge-168/robert-dicicco/raku/ch-1.raku
new file mode 100644
index 0000000000..acfda4039c
--- /dev/null
+++ b/challenge-168/robert-dicicco/raku/ch-1.raku
@@ -0,0 +1,41 @@
+use v6;
+
+# AUTHOR: Robert DiCicco
+# DATE: 2022-06-06
+# Challenge 168 Perrin Primes ( Raku )
+
+my @perrin = (3,0,2);
+
+my @results = ();
+
+my $PRIME_COUNT = 13;
+
+my $i = 0;
+
+while $i <= $PRIME_COUNT {
+
+ my $slots = @perrin.elems;
+
+ my $calc_val = @perrin[$slots - 2] + @perrin[$slots - 3];
+
+ @perrin.push: $calc_val;
+
+ if $calc_val.is-prime {
+
+ @results.push: $calc_val;
+
+ $i++;
+
+ }
+
+}
+
+@results = @results.sort.unique;
+
+for @results -> $val {
+
+ print "$val ";
+
+}
+
+say ' ';
diff --git a/challenge-168/robert-dicicco/raku/ch-2.raku b/challenge-168/robert-dicicco/raku/ch-2.raku
new file mode 100644
index 0000000000..1db7b563b2
--- /dev/null
+++ b/challenge-168/robert-dicicco/raku/ch-2.raku
@@ -0,0 +1,51 @@
+use v6;
+
+# AUTHOR: Robert DiCicco
+# DATE: 2022-06-06
+# Challenge 168 Home Primes ( Raku )
+
+use Prime::Factor;
+
+my @results;
+
+sub homeprime( $hp) {
+
+ my @factors = prime-factors($hp);
+
+ return(@factors.join);
+
+}
+
+my $hp = 8;
+
+my $flag = 1;
+
+@results.push: $hp;
+
+while $flag > 0 {
+
+ my $retval = homeprime($hp);
+
+ if $retval.is-prime {
+
+ @results.push: $retval;
+
+ $flag = 0;
+
+ } else {
+
+ @results.push: $retval;
+
+ $hp = $retval;
+
+ }
+
+}
+
+for @results -> $val {
+
+ print "$val ";
+
+}
+
+say ' ';
diff --git a/challenge-168/robert-dicicco/ruby/ch-1.rb b/challenge-168/robert-dicicco/ruby/ch-1.rb
new file mode 100644
index 0000000000..0a050d6120
--- /dev/null
+++ b/challenge-168/robert-dicicco/ruby/ch-1.rb
@@ -0,0 +1,37 @@
+#!ruby.exe
+
+# AUTHOR: Robert DiCicco
+# DATE: 2022-06-06
+# Challenge 168 Perrin Primes ( Ruby )
+
+require 'prime'
+
+perrin = Array[3,0,2]
+
+PRIME_COUNT = 14
+
+results = Array.new()
+
+i = 0
+
+while i < PRIME_COUNT
+
+ slots = perrin.length()
+
+ calc_val = perrin[slots - 2] + perrin[slots - 3]
+
+ perrin.push(calc_val)
+
+ if Prime.prime?(calc_val)
+
+ results.push(calc_val)
+
+ i += 1
+
+ end
+
+end
+
+results = results.sort.uniq
+
+puts "#{results }"
diff --git a/challenge-168/steve-g-lynn/README b/challenge-168/steve-g-lynn/README
new file mode 100644
index 0000000000..7c58cc8d8c
--- /dev/null
+++ b/challenge-168/steve-g-lynn/README
@@ -0,0 +1 @@
+Solution by Steve G Lynn
diff --git a/challenge-168/steve-g-lynn/perl/ch-1.pl b/challenge-168/steve-g-lynn/perl/ch-1.pl
new file mode 100755
index 0000000000..a8729418aa
--- /dev/null
+++ b/challenge-168/steve-g-lynn/perl/ch-1.pl
@@ -0,0 +1,59 @@
+#!/usr/bin/perl
+
+use Math::Prime::XS qw(is_prime);
+
+local %saveprimes=();
+for (0..150) {
+ local $chk=&perrin($_);
+ (is_prime($chk)) && ($saveprimes{$chk}=1);
+ @saveprimes==26 && last;
+}
+
+print "( ";
+foreach (sort{$a<=>$b} keys %saveprimes){
+ print "$_ ";
+}
+print ")\n";
+
+#-- subs
+
+
+sub perrin {
+ local ($n)=@_;
+
+ if ($n==0) { return 3 }
+ else { return &postmult_302(&matpow($n)) }
+}
+
+#-- subs for fast computation of perrin number using matrix formula
+#-- see wikipedia https://en.wikipedia.org/wiki/Perrin_number
+
+#-- [0 1 0; 0 0 1; 1 1 0]^n (only need 1st row)
+sub matpow {
+ local ($n)=@_;
+
+ if ($n==1) { return (0,1,0) }
+ else {return &postmult_010_001_110(&matpow($n-1))}
+}
+
+
+# 3x3 matrix * [0 1 0; 0 0 1; 1 1 0] (retain 1st row of product)
+sub postmult_010_001_110 {
+ # [a11 a12 a13; a21 a22 a23; a31 a32 a33]*[0 1 0; 0 0 1; 1 1 0]
+ local ($a11,$a12,$a13)=@_; #just need 1st row
+
+ local $b11=$a13;
+ local $b12=$a11+$a13;
+ local $b13=$a12;
+
+ return ($b11,$b12,$b13) #-- return just 1st row
+}
+
+# 3x3 matrix * [3;0;2] retain 1st element of product
+sub postmult_302 {
+ local ($a11,$a12,$a13)=@_; #-- just need 1st row
+ # [a11 a12 a13; a21 a22 a23; a31 a32 a33]*[3;0;2]
+ #
+ return $a11*3+$a13*2; #-- 1st element
+
+}
diff --git a/challenge-168/steve-g-lynn/raku/ch-1.p6 b/challenge-168/steve-g-lynn/raku/ch-1.p6
new file mode 100755
index 0000000000..ace5c647e1
--- /dev/null
+++ b/challenge-168/steve-g-lynn/raku/ch-1.p6
@@ -0,0 +1,45 @@
+#!/usr/bin/raku
+
+my %saveprimes=();
+for ^Inf {
+ my $chk=perrin($_);
+ (is-prime($chk)) && (%saveprimes{$chk}=1);
+ %saveprimes.elems==13 && last;
+}
+
+say %saveprimes.keys.sort({.Int});
+
+
+#-- subs
+
+multi sub perrin(0) {3}
+multi sub perrin(Int $n where ($n>0)){postmult_302(matpow($n))}
+
+#-- subs for fast computation of perrin number using matrix formula
+#-- see wikipedia https://en.wikipedia.org/wiki/Perrin_number
+
+#[0 1 0; 0 0 1; 1 1 0]^n (retain 1st row)
+multi sub matpow(1){ (0,1,0) }
+multi sub matpow(Int $n where ($n>1)) { postmult_010_001_110 (matpow($n-1)) }
+
+# 3x3 matrix * [0 1 0; 0 0 1; 1 1 0] (retain 1st row of product)
+sub postmult_010_001_110 (*@inmatrix){
+ # [a11 a12 a13; a21 a22 a23; a31 a32 a33]*[0 1 0; 0 0 1; 1 1 0]
+ my ($a11,$a12,$a13)=@inmatrix; #just need 1st row
+
+ my $b11=$a13;
+ my $b12=$a11+$a13;
+ my $b13=$a12;
+
+ return ($b11,$b12,$b13) #-- return just 1st row
+}
+
+# 3x3 matrix * [3;0;2] retain 1st element of product
+sub postmult_302 (*@inmatrix){
+ my ($a11,$a12,$a13)=@inmatrix; #-- just need 1st row
+ # [a11 a12 a13; a21 a22 a23; a31 a32 a33]*[3;0;2]
+ #
+ my $b1=$a11*3+$a13*2; #-- 1st element
+
+ return $b1;
+}
diff --git a/challenge-168/wlmb/perl/ch-2.pl b/challenge-168/wlmb/perl/ch-2.pl
index d30dc2ba47..f99ccad5b3 100755
--- a/challenge-168/wlmb/perl/ch-2.pl
+++ b/challenge-168/wlmb/perl/ch-2.pl
@@ -2,7 +2,7 @@
# Perl weekly challenge 168
# Task 2: Home prime
#
-# See https://wlmb.github.io/2022/06/06/PWC168/#task-1-perrin-prime
+# See https://wlmb.github.io/2022/06/06/PWC168/#task-2-home-prime
use v5.12;
use warnings;
use Math::Prime::Util qw(is_prime factor);
diff --git a/members.json b/members.json
index d709bcdbf7..6c041d848f 100644
--- a/members.json
+++ b/members.json
@@ -225,6 +225,7 @@
"southpawgeek" : "Jen Guerra",
"stephanie-stein" : "Stephanie Stein",
"steve-bresson" : "Steve Bresson",
+ "steve-g-lynn" : "Stephen G Lynn",
"steve-rogerson" : "Steve Rogerson",
"steven-lembark" : "Steven Lembark",
"steven-wilson" : "Steven Wilson",
diff --git a/stats/pwc-current.json b/stats/pwc-current.json
index b2d67ec0c8..36a2059226 100644
--- a/stats/pwc-current.json
+++ b/stats/pwc-current.json
@@ -4,42 +4,38 @@
"text" : "Total Solutions"
}
},
- "xAxis" : {
- "type" : "category"
- },
- "title" : {
- "text" : "The Weekly Challenge - 168"
- },
- "tooltip" : {
- "followPointer" : 1,
- "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>",
- "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>"
- },
- "chart" : {
- "type" : "column"
- },
- "legend" : {
- "enabled" : 0
- },
"series" : [
{
- "colorByPoint" : 1,
- "name" : "The Weekly Challenge - 168",
"data" : [
{
- "name" : "Luca Ferrari",
+ "y" : 3,
+ "drilldown" : "James Smith",
+ "name" : "James Smith"
+ },
+ {
"drilldown" : "Luca Ferrari",
+ "name" : "Luca Ferrari",
"y" : 8
},
{
- "name" : "Mark Anderson",
"drilldown" : "Mark Anderson",
+ "name" : "Mark Anderson",
"y" : 2
},
{
+ "y" : 2,
+ "name" : "Marton Polgar",
+ "drilldown" : "Marton Polgar"
+ },
+ {
+ "y" : 3,
"name" : "Peter Campbell Smith",
- "drilldown" : "Peter Campbell Smith",
- "y" : 3
+ "drilldown" : "Peter Campbell Smith"
+ },
+ {
+ "y" : 4,
+ "drilldown" : "Robert DiCicco",
+ "name" : "Robert DiCicco"
},
{
"name" : "Roger Bell_West",
@@ -47,17 +43,52 @@
"y" : 4
},
{
+ "drilldown" : "Ryan Thompson",
"name" : "Ryan Thompson",
- "y" : 6,
- "drilldown" : "Ryan Thompson"
+ "y" : 6
+ },
+ {
+ "drilldown" : "Stephen G Lynn",
+ "name" : "Stephen G Lynn",
+ "y" : 2
+ },
+ {
+ "drilldown" : "W. Luis Mochan",
+ "name" : "W. Luis Mochan",
+ "y" : 3
}
- ]
+ ],
+ "colorByPoint" : 1,
+ "name" : "The Weekly Challenge - 168"
}
],
+ "tooltip" : {
+ "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>",
+ "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>",
+ "followPointer" : 1
+ },
+ "subtitle" : {
+ "text" : "[Champions: 10] Last updated at 2022-06-07 17:05:44 GMT"
+ },
"drilldown" : {
"series" : [
{
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ],
+ "id" : "James Smith",
+ "name" : "James Smith"
+ },
+ {
"name" : "Luca Ferrari",
+ "id" : "Luca Ferrari",
"data" : [
[
"Raku",
@@ -67,12 +98,11 @@
"Blog",
6
]
- ],
- "id" : "Luca Ferrari"