aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2023-10-31 17:28:13 +0000
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2023-10-31 17:28:13 +0000
commita3d346ab5447bac837bb2086fdaea12bd8fbe495 (patch)
treee4149cf4ca8c50565f4b812a7606c2ca5b43e2ba
parent84b1b95ae25c98483a94026a0bc510eb774ce39c (diff)
downloadperlweeklychallenge-club-a3d346ab5447bac837bb2086fdaea12bd8fbe495.tar.gz
perlweeklychallenge-club-a3d346ab5447bac837bb2086fdaea12bd8fbe495.tar.bz2
perlweeklychallenge-club-a3d346ab5447bac837bb2086fdaea12bd8fbe495.zip
- Added solutions by E. Choroba.
- Added solutions by Robbie Hatley. - Added solutions by rcmlz. - Added solutions by Mark Anderson. - Added solutions by Lubos Kolouch. - Added solutions by W. Luis Mochan. - Added solutions by David Ferrone. - Added solutions by Peter Campbell Smith. - Added solutions by Kjetil Skotheim. - Added solutions by Dave Jacoby. - Added solutions by Niels van Dijke. - Added solutions by Packy Anderson. - Added solutions by Luca Ferrari. - Added solutions by Thomas Kohler. - Added solutions by Ali Moradi. - Added solutions by Roger Bell_West.
-rwxr-xr-xchallenge-241/eric-cheung/python/ch-1.py28
-rwxr-xr-xchallenge-241/eric-cheung/python/ch-2.py40
-rwxr-xr-xchallenge-241/perlboy1967/perl/ch-1.pl (renamed from challenge-241/perlboy1967/perl/ch1.pl)0
-rwxr-xr-xchallenge-241/perlboy1967/perl/ch-2.pl (renamed from challenge-241/perlboy1967/perl/ch2.pl)0
-rw-r--r--challenge-241/rcmlz/raku/ch-1.raku29
-rw-r--r--challenge-241/rcmlz/raku/ch-2.raku18
-rwxr-xr-xchallenge-241/ulrich-rieke/cpp/ch-1.cpp44
-rwxr-xr-xchallenge-241/ulrich-rieke/cpp/ch-2.cpp63
-rwxr-xr-xchallenge-241/ulrich-rieke/haskell/ch-1.hs25
-rwxr-xr-xchallenge-241/ulrich-rieke/haskell/ch-2.hs32
-rwxr-xr-xchallenge-241/ulrich-rieke/perl/ch-1.pl24
-rwxr-xr-xchallenge-241/ulrich-rieke/perl/ch-2.pl35
-rwxr-xr-xchallenge-241/ulrich-rieke/raku/ch-1.raku17
-rwxr-xr-xchallenge-241/ulrich-rieke/raku/ch-2.raku41
-rwxr-xr-xchallenge-241/ulrich-rieke/rust/ch-1.rs30
-rwxr-xr-xchallenge-241/ulrich-rieke/rust/ch-2.rs46
-rw-r--r--stats/pwc-challenge-240.json715
-rw-r--r--stats/pwc-current.json631
-rw-r--r--stats/pwc-language-breakdown-summary.json56
-rw-r--r--stats/pwc-language-breakdown.json3363
-rw-r--r--stats/pwc-leaders.json504
-rw-r--r--stats/pwc-summary-1-30.json124
-rw-r--r--stats/pwc-summary-121-150.json96
-rw-r--r--stats/pwc-summary-151-180.json58
-rw-r--r--stats/pwc-summary-181-210.json122
-rw-r--r--stats/pwc-summary-211-240.json54
-rw-r--r--stats/pwc-summary-241-270.json46
-rw-r--r--stats/pwc-summary-271-300.json120
-rw-r--r--stats/pwc-summary-31-60.json42
-rw-r--r--stats/pwc-summary-61-90.json116
-rw-r--r--stats/pwc-summary-91-120.json106
-rw-r--r--stats/pwc-summary.json694
32 files changed, 4096 insertions, 3223 deletions
diff --git a/challenge-241/eric-cheung/python/ch-1.py b/challenge-241/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..6e19580d14
--- /dev/null
+++ b/challenge-241/eric-cheung/python/ch-1.py
@@ -0,0 +1,28 @@
+
+from itertools import combinations
+
+def IsAriTriplet (arrInput, nDiffInput):
+ if arrInput[1] - arrInput[0] != nDiffInput:
+ return False
+ if arrInput[2] - arrInput[1] != nDiffInput:
+ return False
+ return True
+
+
+## Example 1
+## arrNum = [0, 1, 4, 6, 7, 10]
+## nDiff = 3
+
+## Example 2
+arrNum = [4, 5, 6, 7, 8, 9]
+nDiff = 2
+
+
+arrCombList = combinations(arrNum, 3)
+arrOutputList = []
+
+for arrLoop in list(arrCombList):
+ if IsAriTriplet(arrLoop, nDiff):
+ arrOutputList.append(arrOutputList)
+
+print (len(arrOutputList))
diff --git a/challenge-241/eric-cheung/python/ch-2.py b/challenge-241/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..a1eb778bf5
--- /dev/null
+++ b/challenge-241/eric-cheung/python/ch-2.py
@@ -0,0 +1,40 @@
+
+from math import sqrt
+
+def GetPrimeFact(nInput):
+ if nInput < 2:
+ return []
+ if nInput == 2:
+ return [2]
+
+ ## ====== ##
+ nNum = nInput
+ arrOuput = []
+ while nNum % 2 == 0:
+ arrOuput.append(2)
+ nNum = int(nNum / 2)
+ ## ====== ##
+
+ ## ====== ##
+ nDiv = 3
+ nRoot = int(sqrt(nNum))
+ while nDiv < nRoot + 1:
+ if nNum % nDiv == 0:
+ arrOuput.append(nDiv)
+ nNum = int(nNum / nDiv)
+ else:
+ nDiv = nDiv + 2
+ ## ====== ##
+
+ return arrOuput
+
+arrInput = [11, 8, 27, 4]
+
+for nRowIndx in range(0, len(arrInput) - 1):
+ for nColIndx in range(nRowIndx + 1, len(arrInput)):
+ if len(GetPrimeFact(arrInput[nRowIndx])) > len(GetPrimeFact(arrInput[nColIndx])) or len(GetPrimeFact(arrInput[nRowIndx])) == len(GetPrimeFact(arrInput[nColIndx])) and arrInput[nRowIndx] > arrInput[nColIndx]:
+ nTemp = arrInput[nRowIndx]
+ arrInput[nRowIndx] = arrInput[nColIndx]
+ arrInput[nColIndx] = nTemp
+
+print (arrInput)
diff --git a/challenge-241/perlboy1967/perl/ch1.pl b/challenge-241/perlboy1967/perl/ch-1.pl
index dacf68a262..dacf68a262 100755
--- a/challenge-241/perlboy1967/perl/ch1.pl
+++ b/challenge-241/perlboy1967/perl/ch-1.pl
diff --git a/challenge-241/perlboy1967/perl/ch2.pl b/challenge-241/perlboy1967/perl/ch-2.pl
index 2d79bcd7ea..2d79bcd7ea 100755
--- a/challenge-241/perlboy1967/perl/ch2.pl
+++ b/challenge-241/perlboy1967/perl/ch-2.pl
diff --git a/challenge-241/rcmlz/raku/ch-1.raku b/challenge-241/rcmlz/raku/ch-1.raku
new file mode 100644
index 0000000000..e3ed5a9147
--- /dev/null
+++ b/challenge-241/rcmlz/raku/ch-1.raku
@@ -0,0 +1,29 @@
+unit module rcmlz::raku::task-one:ver<0.0.1>:auth<github:rcmlz>:api<1>;
+
+# run in terminal: raku --optimize=3 -I challenge-nr241/rcmlz/raku/ -- test/challenge-nr241/raku/task-one.rakutest
+# or raku --optimize=3 -I challenge-nr241 -- test/benchmark-scalability.raku --task=task-one --user=rcmlz --max-run-times=1,3,7 --max-problem=10 --v=True --test-before-benchmark=True --out-folder=/tmp nr241; cat /tmp/nr241_task-one.csv
+
+#|[
+You are given an array (3 or more members) of integers in increasing order and a positive integer.
+
+Write a script to find out the number of unique Arithmetic Triplets satisfying the following rules:
+
+a) i < j < k
+b) nums[j] - nums[i] == diff
+c) nums[k] - nums[j] == diff
+]
+our sub solution([$diff, *@input]) is export {
+ my UInt $counter = 0;
+ my UInt \n = @input.elems;
+
+ for ^n -> \i {
+ for i+1..^n -> \j {
+ if @input[j] - @input[i] == $diff {
+ for j+1..^n -> \k {
+ $counter++ if @input[k] - @input[j] == $diff
+ }
+ }
+ }
+ }
+ $counter
+} \ No newline at end of file
diff --git a/challenge-241/rcmlz/raku/ch-2.raku b/challenge-241/rcmlz/raku/ch-2.raku
new file mode 100644
index 0000000000..f871118a42
--- /dev/null
+++ b/challenge-241/rcmlz/raku/ch-2.raku
@@ -0,0 +1,18 @@
+unit module rcmlz::raku::task-two:ver<0.0.1>:auth<github:rcmlz>:api<1>;
+
+use Prime::Factor;
+
+# run in terminal: raku --optimize=3 -I challenge-nr241/rcmlz/raku/ -- test/challenge-nr241/raku/task-two.rakutest
+# or raku --optimize=3 -I challenge-nr241 -- test/benchmark-scalability.raku --task=task-two --user=rcmlz --max-run-times=1,3,7 --max-problem=10 --v=True --test-before-benchmark=True --out-folder=/tmp nr241; cat /tmp/nr241_task-two.csv
+
+#|[
+You are given an array of unique positive integers greater than 2.
+
+- Write a script to sort them in ascending order of the count of their prime factors, tie-breaking by ascending value.
+]
+our sub solution(@input) is export {
+ @input ==> map( -> $n { $n => prime-factors($n).elems } )
+ ==> sort( { my Order $o = $^a.value cmp $^b.value;
+ $o == Same ?? $^a.key cmp $^b.key !! $o } )
+ ==> map( *.key )
+} \ No newline at end of file
diff --git a/challenge-241/ulrich-rieke/cpp/ch-1.cpp b/challenge-241/ulrich-rieke/cpp/ch-1.cpp
new file mode 100755
index 0000000000..c446abe90c
--- /dev/null
+++ b/challenge-241/ulrich-rieke/cpp/ch-1.cpp
@@ -0,0 +1,44 @@
+#include <vector>
+#include <iostream>
+#include <string>
+#include <algorithm>
+
+std::vector<std::string> split( const std::string & startline ,
+ const std::string & sep ) {
+ std::vector<std::string> separated ;
+ std::string::size_type start { 0 } ;
+ std::string::size_type pos ;
+ do {
+ pos = startline.find_first_of( sep , start ) ;
+ separated.push_back( startline.substr(start , pos - start )) ;
+ start = pos + 1 ;
+ } while ( pos != std::string::npos ) ;
+ return separated ;
+}
+
+int main( ) {
+ std::cout << "Enter at least 3 positive integers in ascending order!\n" ;
+ std::string line ;
+ std::getline( std::cin , line ) ;
+ std::cout << "Enter a positive integer!\n" ;
+ int diff ;
+ std::cin >> diff ;
+ std::vector<std::string> numberstrings { split( line , " " ) } ;
+ std::vector<int> numbers ;
+ for ( auto s : numberstrings )
+ numbers.push_back( std::stoi( s ) ) ;
+ int result = 0 ;
+ int len = numbers.size( ) ;
+ for ( int i = 0 ; i < len - 2 ; i++ ) {
+ for ( int j = i + 1 ; j < len - 1 ; j++ ) {
+ for ( int k = j + 1 ; k < len ; k++ ) {
+ if ( numbers[ j ] - numbers[ i ] == diff
+ && numbers[ k ] - numbers[ j ] == diff )
+ result++ ;
+ }
+ }
+ }
+ std::cout << result << std::endl ;
+ return 0 ;
+}
+
diff --git a/challenge-241/ulrich-rieke/cpp/ch-2.cpp b/challenge-241/ulrich-rieke/cpp/ch-2.cpp
new file mode 100755
index 0000000000..d83be4832a
--- /dev/null
+++ b/challenge-241/ulrich-rieke/cpp/ch-2.cpp
@@ -0,0 +1,63 @@
+#include <iostream>
+#include <string>
+#include <vector>
+#include <algorithm>
+
+std::vector<std::string> split( const std::string & startline ,
+ const std::string & sep ) {
+ std::vector<std::string> separated ;
+ std::string::size_type start { 0 } ;
+ std::string::size_type pos ;
+ do {
+ pos = startline.find_first_of( sep , start ) ;
+ separated.push_back( startline.substr(start , pos - start )) ;
+ start = pos + 1 ;
+ } while ( pos != std::string::npos ) ;
+ return separated ;
+}
+
+int findSmallest( int number ) {
+ int divisor = 2 ;
+ while ( number % divisor != 0 ) {
+ divisor++ ;
+ }
+ return divisor ;
+}
+
+std::vector<int> primeDecompose( int number ) {
+ std::vector<int> primeFactors ;
+ while ( number != 1 ) {
+ int divisor = findSmallest( number ) ;
+ primeFactors.push_back( divisor ) ;
+ number /= divisor ;
+ }
+ return primeFactors ;
+}
+
+bool mySorter( int numA , int numB ) {
+ std::vector<int> factorsA { primeDecompose( numA ) } ;
+ std::vector<int> factorsB { primeDecompose( numB ) } ;
+ if ( factorsA.size( ) != factorsB.size( ) ) {
+ return factorsA.size( ) < factorsB.size( ) ;
+ }
+ else {
+ return numA < numB ;
+ }
+}
+
+int main( ) {
+ std::cout << "Enter some unique positive integers greater than 2!\n" ;
+ std::string line ;
+ std::getline( std::cin , line ) ;
+ std::vector<std::string> numberstrings( split( line , " " ) ) ;
+ std::vector<int> numbers ;
+ for ( auto s : numberstrings )
+ numbers.push_back( std::stoi( s ) ) ;
+ std::sort( numbers.begin( ) , numbers.end( ) , mySorter ) ;
+ std::cout << "( " ;
+ for ( int i : numbers )
+ std::cout << i << ' ' ;
+ std::cout << " )\n" ;
+ return 0 ;
+}
+
diff --git a/challenge-241/ulrich-rieke/haskell/ch-1.hs b/challenge-241/ulrich-rieke/haskell/ch-1.hs
new file mode 100755
index 0000000000..33cf551cf5
--- /dev/null
+++ b/challenge-241/ulrich-rieke/haskell/ch-1.hs
@@ -0,0 +1,25 @@
+module Challenge241
+ where
+import Data.List ( (!!) )
+
+combinations :: Int -> [a] -> [[a]]
+combinations 0 _ = [[]]
+combinations n xs = [ xs !! i : x | i <- [0..(length xs ) - 1 ] ,
+ x <- combinations (n - 1 ) ( drop ( i + 1 ) xs ) ]
+
+myCondition :: [Int] -> [Int] -> Int -> Bool
+myCondition indices list diff = ( (list !! ( indices !! 1 )) -
+ (list !! ( indices !! 0 )) == diff ) && ( ( list !! ( indices !! 2 )) -
+ ( list !! ( indices !! 1 ) ) == diff )
+
+main :: IO ( )
+main = do
+ putStrLn "Enter at least 3 positive integers in ascending order!"
+ numberstrings <- getLine
+ putStrLn "Enter a positive integer!"
+ diffstring <- getLine
+ let numbers = map read $ words numberstrings
+ diff = read diffstring
+ allCombis = combinations 3 [0..length numbers - 1]
+ selected = filter (\li -> myCondition li numbers diff ) allCombis
+ print $ length selected
diff --git a/challenge-241/ulrich-rieke/haskell/ch-2.hs b/challenge-241/ulrich-rieke/haskell/ch-2.hs
new file mode 100755
index 0000000000..1857b0125c
--- /dev/null
+++ b/challenge-241/ulrich-rieke/haskell/ch-2.hs
@@ -0,0 +1,32 @@
+module Challenge241_2
+ where
+import Data.List ( sortBy )
+
+--for every number, find the smallest divisor which must, by
+--definition of smallest and prime, be prime
+
+divisors :: Int -> [Int]
+divisors n = [d | d <- [2..n] , mod n d == 0 ]
+
+primeDecompose :: Int -> [Int]
+primeDecompose n = snd $ until ( ( == 1 ) . fst ) step ( n , [] )
+ where
+ step :: ( Int , [Int] ) -> ( Int , [Int] )
+ step ( num , list ) = ( div num smallest , smallest : list )
+ where
+ smallest = head $ divisors num
+
+mySorter :: Int -> Int -> Ordering
+mySorter a b
+ |la /= lb = compare la lb
+ |otherwise = compare a b
+ where
+ la = length $ primeDecompose a
+ lb = length $ primeDecompose b
+
+main :: IO ( )
+main = do
+ putStrLn "Please enter some unique positive integers greater than 2!"
+ numberstrings <- getLine
+ let numbers = map read $ words numberstrings
+ print $ sortBy mySorter numbers
diff --git a/challenge-241/ulrich-rieke/perl/ch-1.pl b/challenge-241/ulrich-rieke/perl/ch-1.pl
new file mode 100755
index 0000000000..152d0cf586
--- /dev/null
+++ b/challenge-241/ulrich-rieke/perl/ch-1.pl
@@ -0,0 +1,24 @@
+#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+use Algorithm::Combinatorics qw ( combinations ) ;
+
+say "Enter at least 3 integers in increasing order!" ;
+my $line = <STDIN> ;
+chomp $line ;
+my @numbers = split( /\s/ , $line ) ;
+say "Enter a positive number!" ;
+my $diff = <STDIN> ;
+chomp $diff ;
+my $result = 0 ;
+my @indices = (0..scalar( @numbers ) - 1) ;
+my $iter = combinations( \@indices , 3 ) ;
+while ( my $c = $iter->next ) {
+ if ( ($numbers[ $c->[1] ] - $numbers[ $c->[0] ] == $diff)
+ && ($numbers[ $c->[2] ] - $numbers[ $c->[1] ] == $diff ) ) {
+ $result++ ;
+ }
+}
+say $result ;
+
diff --git a/challenge-241/ulrich-rieke/perl/ch-2.pl b/challenge-241/ulrich-rieke/perl/ch-2.pl
new file mode 100755
index 0000000000..9e8b25e703
--- /dev/null
+++ b/challenge-241/ulrich-rieke/perl/ch-2.pl
@@ -0,0 +1,35 @@
+#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+
+#the smallest divisor always is a prime number. So we have to keep
+#finding the smallest divisors.
+
+sub findSmallest {
+ my $number = shift ;
+ my $divisor = 2 ;
+ while ( $number % $divisor != 0 ) {
+ $divisor++ ;
+ }
+ return $divisor ;
+}
+
+sub findPrimeFactors {
+ my $number = shift ;
+ my @primeFactors ;
+ while ( $number != 1 ) {
+ my $divisor = findSmallest( $number ) ;
+ push @primeFactors , $divisor ;
+ $number /= $divisor ;
+ }
+ return @primeFactors ;
+}
+
+say "Enter some unique positive integers greater than 2" ;
+my $line = <STDIN> ;
+chomp $line ;
+my @numbers = split( /\s/ , $line ) ;
+my @sorted = sort { scalar( findPrimeFactors( $a ) ) <=>
+ scalar( findPrimeFactors( $b ) ) || $a <=> $b } @numbers ;
+say "(" . join( ',' , @sorted ) . ")" ;
diff --git a/challenge-241/ulrich-rieke/raku/ch-1.raku b/challenge-241/ulrich-rieke/raku/ch-1.raku
new file mode 100755
index 0000000000..a7667fe135
--- /dev/null
+++ b/challenge-241/ulrich-rieke/raku/ch-1.raku
@@ -0,0 +1,17 @@
+use v6 ;
+
+say "Enter at least 3 integers in ascending order!" ;
+my $line = $*IN.get ;
+my @numbers = $line.words.map( {.Int} ) ;
+say "Enter a positive integer!" ;
+my $diff = $*IN.get ;
+my @indices = (0..@numbers.elems - 1 ) ;
+my $result = 0 ;
+my @combis = @indices.combinations( 3 ) ;
+for @combis -> $combi {
+ if ( @numbers[ $combi[ 1 ] ] - @numbers[ $combi[ 0 ] ] == $diff
+ && @numbers[ $combi[ 2 ] ] - @numbers[ $combi[ 1 ] ] == $diff ) {
+ $result++ ;
+ }
+}
+say $result ;
diff --git a/challenge-241/ulrich-rieke/raku/ch-2.raku b/challenge-241/ulrich-rieke/raku/ch-2.raku
new file mode 100755
index 0000000000..b6cb615c9a
--- /dev/null
+++ b/challenge-241/ulrich-rieke/raku/ch-2.raku
@@ -0,0 +1,41 @@
+use v6 ;
+
+#the smallest divisor of a number must be a prime number! So all it takes
+#is to keep finding the smallest divisor of a number until it equals 1
+
+sub findSmallest( $number is copy ) {
+ my $divisor = 2 ;
+ while ( not ( $number %% $divisor ) ) {
+ $divisor++ ;
+ }
+ return $divisor ;
+}
+
+sub prime_decompose( $number is copy ) {
+ my @primeFactors ;
+ while ( $number != 1 ) {
+ my $divisor = findSmallest( $number ) ;
+ @primeFactors.push( $divisor ) ;
+ $number div= $divisor ;
+ }
+ return @primeFactors ;
+}
+
+sub mySorter( $firstNum is copy , $secondNum is copy ) {
+ my @factorsA = prime_decompose( $firstNum ) ;
+ my @factorsB = prime_decompose( $secondNum ) ;
+ my $lenA = @factorsA.elems ;
+ my $lenB = @factorsB.elems ;
+ if ( $lenA != $lenB ) {
+ return $lenA <=> $lenB ;
+ }
+ else {
+ return $firstNum <=> $secondNum ;
+ }
+}
+
+say "Enter some unique positive integers greater than 2!" ;
+my $line = $*IN.get ;
+my @numbers = $line.words.map( {.Int} ) ;
+my @sorted = @numbers.sort( {&mySorter( $^a , $^b ) } ) ;
+say "(" ~ @sorted.join( ',' ) ~ ")" ;
diff --git a/challenge-241/ulrich-rieke/rust/ch-1.rs b/challenge-241/ulrich-rieke/rust/ch-1.rs
new file mode 100755
index 0000000000..6fe364f226
--- /dev/null
+++ b/challenge-241/ulrich-rieke/rust/ch-1.rs
@@ -0,0 +1,30 @@
+use std::io ;
+use itertools::Itertools ;
+
+fn main() {
+ println!("Enter at least 3 integers in increasing order!");
+ let mut inline : String = String::new( ) ;
+ io::stdin( ).read_line( &mut inline ).unwrap( ) ;
+ let entered_line : &str = &*inline ;
+ println!("Enter a positive integer!" ) ;
+ let mut secondline : String = String::new( ) ;
+ io::stdin( ).read_line( &mut secondline ).unwrap( ) ;
+ let another_line : &str = &*secondline ;
+ let numbers : Vec<i32> = entered_line.split_whitespace( ).map(
+ | s | s.trim( ).parse::<i32>( ).unwrap( ) ).collect( ) ;
+ let numline = another_line.trim( ) ;
+ let diff : i32 = numline.parse::<i32>( ).unwrap( ) ;
+ let it = (0..numbers.len( )).combinations( 3 ) ;
+ let mut result : u32 = 0 ;
+ for a_combi in it {
+ let mut selected : Vec<i32> = Vec::new( ) ;
+ for i in a_combi {
+ selected.push( numbers[ i ] ) ;
+ }
+ if selected[ 1 ] - selected[ 0 ] == diff &&
+ selected[ 2 ] - selected[ 1 ] == diff {
+ result += 1 ;
+ }
+ }
+ println!("{}" , result ) ;
+}
diff --git a/challenge-241/ulrich-rieke/rust/ch-2.rs b/challenge-241/ulrich-rieke/rust/ch-2.rs
new file mode 100755
index 0000000000..601e84e0ff
--- /dev/null
+++ b/challenge-241/ulrich-rieke/rust/ch-2.rs
@@ -0,0 +1,46 @@
+use std::io ;
+
+//for theoretical reasons, the smallest divisor of a number must be
+//prime! It either is the smallest divisor, then it can't be subdivided
+//further and therefore is prime, or it isn't the smallest
+
+fn smallest_divisor( number : u32 ) -> u32 {
+ let mut divisor : u32 = 2 ;
+ while number % divisor != 0 {
+ divisor += 1 ;
+ }
+ divisor
+}
+
+fn prime_decompose( mut number : u32 ) -> Vec<u32> {
+ let mut prime_factors : Vec<u32> = Vec::new( ) ;
+ while number != 1 {
+ let divisor : u32 = smallest_divisor( number ) ;
+ prime_factors.push( divisor ) ;
+ number /= divisor ;
+ }
+ prime_factors
+}
+
+fn main() {
+ println!("Enter some unique positive integers greater than 2!");
+ let mut inline : String = String::new( ) ;
+ io::stdin( ).read_line( &mut inline ).unwrap( ) ;
+ let entered_line : &str = &*inline ;
+ let mut numbers : Vec<u32> = entered_line.split_whitespace( ).map(
+ | s | s.trim( ).parse::<u32>( ).unwrap( ) ).collect( ) ;
+ let nums = numbers.as_mut_slice( ) ;
+ nums.sort_unstable_by( |a , b| {
+ let factors_a : Vec<u32> = prime_decompose( *a ) ;
+ let factors_b : Vec<u32> = prime_decompose( *b ) ;
+ let len_a = factors_a.len( ) ;
+ let len_b = factors_b.len( ) ;
+ if len_a != len_b {
+ len_a.cmp( &len_b )
+ }
+ else {
+ a.cmp( &b )
+ }
+ }) ;
+ println!("{:?}" , nums ) ;
+}
diff --git a/stats/pwc-challenge-240.json b/stats/pwc-challenge-240.json
new file mode 100644
index 0000000000..6b8d4a8ffa
--- /dev/null
+++ b/stats/pwc-challenge-240.json
@@ -0,0 +1,715 @@
+{
+ "yAxis" : {
+ "title" : {
+ "text" : "Total Solutions"
+ }
+ },
+ "series" : [
+ {
+ "colorByPoint" : 1,
+ "data" : [
+ {
+ "drilldown" : "Adam Russell",
+ "name" : "Adam Russell",
+ "y" : 4
+ },
+ {
+ "drilldown" : "Ali Moradi",
+ "y" : 5,
+ "name" : "Ali Moradi"
+ },
+ {
+ "drilldown" : "Arne Sommer",
+ "name" : "Arne Sommer",
+ "y" : 5
+ },
+ {
+ "name" : "Athanasius",
+ "y" : 4,
+ "drilldown" : "Athanasius"
+ },
+ {
+ "drilldown" : "Augie De Blieck Jr.",
+ "y" : 3,
+ "name" : "Augie De Blieck Jr."
+ },
+ {
+ "name" : "BarrOff",
+ "y" : 4,
+ "drilldown" : "BarrOff"
+ },
+ {
+ "name" : "Bob Lied",
+ "y" : 3,
+ "drilldown" : "Bob Lied"
+ },
+ {
+ "y" : 2,
+ "name" : "Bruce Gray",
+ "drilldown" : "Bruce Gray"
+ },
+ {
+ "drilldown" : "Cheok-Yin Fung",
+ "name" : "Cheok-Yin Fung",
+ "y" : 2
+ },
+ {
+ "drilldown" : "Clifton Wood",
+ "name" : "Clifton Wood",
+ "y" : 2
+ },
+ {
+ "drilldown" : "Dave Jacoby",
+ "y" : 2,
+ "name" : "Dave Jacoby"
+ },
+ {
+ "drilldown" : "David Ferrone",
+ "name" : "David Ferrone",
+ "y" : 2
+ },
+ {
+ "drilldown" : "E. Choroba",
+ "y" : 2,
+ "name" : "E. Choroba"
+ },
+ {
+ "drilldown" : "Ian Rifkin",
+ "name" : "Ian Rifkin",
+ "y" : 5
+ },
+ {
+ "drilldown" : "Jaldhar H. Vyas",
+ "name" : "Jaldhar H. Vyas",
+ "y" : 5
+ },
+ {
+ "y" : 2,
+ "name" : "Jan Krnavek",
+ "drilldown" : "Jan Krnavek"
+ },
+ {
+ "drilldown" : "Jorg Sommrey",
+ "name" : "Jorg Sommrey",
+ "y" : 2
+ },
+ {
+ "drilldown" : "Kjetil Skotheim",
+ "y" : 2,
+ "name" : "Kjetil Skotheim"
+ },
+ {
+ "drilldown" : "Lubos Kolouch",
+ "y" : 5,
+ "name" : "Lubos Kolouch"
+ },
+ {
+ "drilldown" : "Luca Ferrari",
+ "name" : "Luca Ferrari",
+ "y" : 10
+ },
+ {
+ "drilldown" : "Mariano Spadaccini",
+ "name" : "Mariano Spadaccini",
+ "y" : 2
+ },
+ {
+ "y" : 2,
+ "name" : "Mark Anderson",
+ "drilldown" : "Mark Anderson"
+ },
+ {
+ "y" : 2,
+ "name" : "Matthew Neleigh",
+ "drilldown" : "Matthew Neleigh"
+ },
+ {
+ "name" : "Matthias Muth",
+ "y" : 3,
+ "drilldown" : "Matthias Muth"
+ },
+ {
+ "name" : "Niels van Dijke",
+ "y" : 2,
+ "drilldown" : "Niels van Dijke"
+ },
+ {
+ "drilldown" : "Packy Anderson",
+ "y" : 5,
+ "name" : "Packy Anderson"
+ },
+ {
+ "drilldown" : "Peter Campbell Smith",
+ "y" : 3,
+ "name" : "Peter Campbell Smith"
+ },
+ {
+ "drilldown" : "Peter Meszaros",
+ "y" : 2,
+ "name" : "Peter Meszaros"
+ },
+ {
+ "drilldown" : "Raghu R",
+ "y" : 2,
+ "name" : "Raghu R"
+ },
+ {
+ "drilldown" : "rcmlz",
+ "y" : 2,
+ "name" : "rcmlz"
+ },
+ {
+ "name" : "Robbie Hatley",
+ "y" : 3,
+ "drilldown" : "Robbie Hatley"
+ },
+ {
+ "y" : 4,
+ "name" : "Robert DiCicco",
+ "drilldown" : "Robert DiCicco"
+ },
+ {
+ "name" : "Roger Bell_West",
+ "y" : 5,
+ "drilldown" : "Roger Bell_West"
+ },
+ {
+ "y" : 3,
+ "name" : "Simon Green",
+ "drilldown" : "Simon Green"
+ },
+ {
+ "drilldown" : "Thomas Kohler",
+ "name" : "Thomas Kohler",
+ "y" : 4
+ },
+ {
+ "y" : 4,
+ "name" : "Ulrich Rieke",
+ "drilldown" : "Ulrich Rieke"
+ },
+ {
+ "drilldown" : "W. Luis Mochan",
+ "y" : 3,
+ "name" : "W. Luis Mochan"
+ }
+ ],
+ "name" : "The Weekly Challenge - 240"
+ }
+ ],
+ "tooltip" : {
+ "followPointer" : 1,
+ "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>",
+ "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>"
+ },
+ "plotOptions" : {
+ "series" : {
+ "borderWidth" : 0,
+ "dataLabels" : {
+ "format" : "{point.y}",
+ "enabled" : 1
+ }
+ }
+ },
+ "subtitle" : {
+ "text" : "[Champions: 37] Last updated at 2023-10-31 17:04:22 GMT"
+ },
+ "title" : {
+ "text" : "Th