aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <mohammad.anwar@yahoo.com>2025-04-22 16:52:26 +0100
committerMohammad Sajid Anwar <mohammad.anwar@yahoo.com>2025-04-22 16:52:26 +0100
commit01bbee2ef271e9c612e746dec11a48ff37c782fb (patch)
tree8322bacb56eb68fc37652dd8143da91c435cf6b8
parentd6eb79f9e37490af474da54261d924145be7bf37 (diff)
downloadperlweeklychallenge-club-01bbee2ef271e9c612e746dec11a48ff37c782fb.tar.gz
perlweeklychallenge-club-01bbee2ef271e9c612e746dec11a48ff37c782fb.tar.bz2
perlweeklychallenge-club-01bbee2ef271e9c612e746dec11a48ff37c782fb.zip
- Added solutions by Eric Cheung.
- Added solutions by Ulrich Rieke. - Added solutions by Feng Chang. - Added solutions by PokGoPun. - Added solutions by Bob Lied. - Added solutions by Niels van Dijke. - Added solutions by Conor Hoekstra. - Added solutions by David Ferrone. - Added solutions by W. Luis Mochan. - Added solutions by Jan Krnavek. - Added solutions by Wanderdoc. - Added solutions by Mark Anderson. - Added solutions by Peter Campbell Smith. - Added solutions by E. Choroba. - Added solutions by Vinod Kumar K. - Added solutions by Steven Wilson. - Added solutions by Roger Bell_West.
-rw-r--r--challenge-318/conor-hoekstra/bqn/ch-1.bqn (renamed from challenge-318/conor-hoekstra/ch-1.bqn)0
-rw-r--r--challenge-318/conor-hoekstra/bqn/ch-2.bqn (renamed from challenge-318/conor-hoekstra/ch-2.bqn)0
-rwxr-xr-xchallenge-318/eric-cheung/python/ch-1.py22
-rwxr-xr-xchallenge-318/eric-cheung/python/ch-2.py31
-rwxr-xr-xchallenge-318/perlboy1967/perl/ch-1.pl (renamed from challenge-318/perlboy1967/perl/ch1.pl)0
-rwxr-xr-xchallenge-318/perlboy1967/perl/ch-2.pl (renamed from challenge-318/perlboy1967/perl/ch2.pl)0
-rwxr-xr-xchallenge-318/ulrich-rieke/cpp/ch-1.cpp48
-rwxr-xr-xchallenge-318/ulrich-rieke/cpp/ch-2.cpp75
-rwxr-xr-xchallenge-318/ulrich-rieke/haskell/ch-1.hs12
-rwxr-xr-xchallenge-318/ulrich-rieke/haskell/ch-2.hs29
-rwxr-xr-xchallenge-318/ulrich-rieke/perl/ch-1.pl42
-rwxr-xr-xchallenge-318/ulrich-rieke/perl/ch-2.pl56
-rwxr-xr-xchallenge-318/ulrich-rieke/raku/ch-1.raku35
-rwxr-xr-xchallenge-318/ulrich-rieke/raku/ch-2.raku48
-rwxr-xr-xchallenge-318/ulrich-rieke/rust/ch-1.rs46
-rwxr-xr-xchallenge-318/ulrich-rieke/rust/ch-2.rs50
-rw-r--r--stats/pwc-challenge-317.json600
-rw-r--r--stats/pwc-current.json564
-rw-r--r--stats/pwc-language-breakdown-2019.json266
-rw-r--r--stats/pwc-language-breakdown-2020.json736
-rw-r--r--stats/pwc-language-breakdown-2021.json682
-rw-r--r--stats/pwc-language-breakdown-2022.json384
-rw-r--r--stats/pwc-language-breakdown-2023.json738
-rw-r--r--stats/pwc-language-breakdown-2024.json338
-rw-r--r--stats/pwc-language-breakdown-2025.json263
-rw-r--r--stats/pwc-language-breakdown-summary.json68
-rw-r--r--stats/pwc-leaders.json740
-rw-r--r--stats/pwc-summary-1-30.json108
-rw-r--r--stats/pwc-summary-121-150.json98
-rw-r--r--stats/pwc-summary-151-180.json112
-rw-r--r--stats/pwc-summary-181-210.json96
-rw-r--r--stats/pwc-summary-211-240.json48
-rw-r--r--stats/pwc-summary-241-270.json48
-rw-r--r--stats/pwc-summary-271-300.json118
-rw-r--r--stats/pwc-summary-301-330.json56
-rw-r--r--stats/pwc-summary-31-60.json98
-rw-r--r--stats/pwc-summary-61-90.json58
-rw-r--r--stats/pwc-summary-91-120.json108
-rw-r--r--stats/pwc-summary.json88
-rw-r--r--stats/pwc-yearly-language-summary.json88
40 files changed, 3894 insertions, 3103 deletions
diff --git a/challenge-318/conor-hoekstra/ch-1.bqn b/challenge-318/conor-hoekstra/bqn/ch-1.bqn
index 3716715e0b..3716715e0b 100644
--- a/challenge-318/conor-hoekstra/ch-1.bqn
+++ b/challenge-318/conor-hoekstra/bqn/ch-1.bqn
diff --git a/challenge-318/conor-hoekstra/ch-2.bqn b/challenge-318/conor-hoekstra/bqn/ch-2.bqn
index c28b98440f..c28b98440f 100644
--- a/challenge-318/conor-hoekstra/ch-2.bqn
+++ b/challenge-318/conor-hoekstra/bqn/ch-2.bqn
diff --git a/challenge-318/eric-cheung/python/ch-1.py b/challenge-318/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..f725ab5315
--- /dev/null
+++ b/challenge-318/eric-cheung/python/ch-1.py
@@ -0,0 +1,22 @@
+
+## strInput = "abccccd" ## Example 1
+## strInput = "aaabcddddeefff" ## Example 2
+strInput = "abcdd" ## Example 3
+
+arrOutput = []
+strTemp = ""
+
+for charLoop in strInput:
+ if not strTemp:
+ strTemp = charLoop
+ elif strTemp[-1] == charLoop:
+ strTemp = strTemp + charLoop
+ else:
+ if len(strTemp) >= 3:
+ arrOutput.append(strTemp)
+ strTemp = charLoop
+
+if len(strTemp) >= 3:
+ arrOutput.append(strTemp)
+
+print (arrOutput)
diff --git a/challenge-318/eric-cheung/python/ch-2.py b/challenge-318/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..7f9b1ab0d4
--- /dev/null
+++ b/challenge-318/eric-cheung/python/ch-2.py
@@ -0,0 +1,31 @@
+
+import sys
+
+## Example 1
+## arrSource = [3, 2, 1, 4]
+## arrTarget = [1, 2, 3, 4]
+
+## Example 2
+## arrSource = [1, 3, 4]
+## arrTarget = [4, 1, 3]
+
+## Example 3
+arrSource = [2]
+arrTarget = [2]
+
+if len(arrSource) == 1:
+ print (True)
+ sys.exit()
+
+for nRowIndx in range(len(arrSource) - 1):
+ for nColIndx in range(nRowIndx + 1, len(arrSource)):
+ ## print (nRowIndx, nColIndx)
+ arrRevTemp = arrSource[nRowIndx : nColIndx + 1][::-1]
+ arrTemp = arrSource[:nRowIndx] + arrRevTemp + arrSource[nColIndx + 1:]
+
+ if arrTarget == arrTemp:
+ print (True)
+ sys.exit()
+
+print (False)
+sys.exit()
diff --git a/challenge-318/perlboy1967/perl/ch1.pl b/challenge-318/perlboy1967/perl/ch-1.pl
index d299e84f48..d299e84f48 100755
--- a/challenge-318/perlboy1967/perl/ch1.pl
+++ b/challenge-318/perlboy1967/perl/ch-1.pl
diff --git a/challenge-318/perlboy1967/perl/ch2.pl b/challenge-318/perlboy1967/perl/ch-2.pl
index 261c227bd2..261c227bd2 100755
--- a/challenge-318/perlboy1967/perl/ch2.pl
+++ b/challenge-318/perlboy1967/perl/ch-2.pl
diff --git a/challenge-318/ulrich-rieke/cpp/ch-1.cpp b/challenge-318/ulrich-rieke/cpp/ch-1.cpp
new file mode 100755
index 0000000000..628dfd75b5
--- /dev/null
+++ b/challenge-318/ulrich-rieke/cpp/ch-1.cpp
@@ -0,0 +1,48 @@
+#include <iostream>
+#include <string>
+#include <map>
+#include <vector>
+#include <algorithm>
+
+bool isAscending( const std::vector<int> & numbers ) {
+ int len = numbers.size( ) ;
+ for ( int i = 0 ; i < len - 1 ; i++ ) {
+ if ( numbers[i + 1] - numbers[i] != 1 )
+ return false ;
+ }
+ return true ;
+}
+
+int main( ) {
+ std::cout << "Enter a word!\n" ;
+ std::string word ;
+ std::cin >> word ;
+ std::map<char , std::vector<int>> positions ;
+ for ( int i = 0 ; i < word.length( ) ; i++ ) {
+ positions[word[i]].push_back( i ) ;
+ }
+ std::vector<std::string> solution ;
+ for ( int i = 0 ; i < word.length( ) ; i++ ) {
+ auto it = positions.find( word[i] ) ;
+ int len = (it->second).size( ) ;
+ if ( len >= 3 && isAscending( it->second )) {
+ std::string current ;
+ for ( int i = 0 ; i < len ; i++ )
+ current.push_back( it->first ) ;
+ if ( std::find( solution.begin( ) , solution.end( ) , current ) ==
+ solution.end( ) ) {
+ solution.push_back( current ) ;
+ }
+ }
+ }
+ if ( solution.size( ) > 0 ) {
+ for ( auto s : solution )
+ std::cout << s << ' ' ;
+ std::cout << '\n' ;
+ }
+ else {
+ std::cout << "\"\"" ;
+ std::cout << '\n' ;
+ }
+ return 0 ;
+}
diff --git a/challenge-318/ulrich-rieke/cpp/ch-2.cpp b/challenge-318/ulrich-rieke/cpp/ch-2.cpp
new file mode 100755
index 0000000000..7908049b03
--- /dev/null
+++ b/challenge-318/ulrich-rieke/cpp/ch-2.cpp
@@ -0,0 +1,75 @@
+#include <vector>
+#include <utility>
+#include <map>
+#include <sstream>
+#include <vector>
+#include <iostream>
+#include <algorithm>
+
+std::vector<std::string> split( const std::string & text , char delimiter ) {
+ std::vector<std::string> tokens ;
+ std::istringstream istr { text } ;
+ std::string word ;
+ while ( std::getline( istr , word , delimiter ) )
+ tokens.push_back( word ) ;
+ return tokens ;
+}
+
+bool isAscending( const std::vector<int> &numbers ) {
+ int len = numbers.size( ) ;
+ for ( int i = 0 ; i < len - 1 ; i++ ) {
+ if ( numbers[ i + 1 ] - numbers[ i ] != 1 ) {
+ return false ;
+ }
+ }
+ return true ;
+}
+
+int main( ) {
+ std::cout << "Enter some integers separated by blanks!\n" ;
+ std::string line ;
+ std::getline( std::cin , line ) ;
+ std::vector<int> firstnums , secondnums ;
+ auto firsttokens { split( line , ' ' ) } ;
+ for ( auto s : firsttokens )
+ firstnums.push_back( std::stoi( s ) ) ;
+ std::cout << "Enter the same integers in a different order!\n" ;
+ line.clear( ) ;
+ std::getline( std::cin , line ) ;
+ auto secondtokens { split( line , ' ' ) } ;
+ for ( auto s : secondtokens )
+ secondnums.push_back( std::stoi( s ) ) ;
+ if ( firstnums.size( ) == 1 && secondnums.size( ) == 1 ) {
+ std::cout << "true\n" ;
+ }
+ else {
+ std::vector<std::pair<int , int>> positions ;
+ for ( int i = 0 ; i < firstnums.size( ) ; i++ ) {
+ positions.push_back( std::make_pair( i , i + static_cast<int>(
+ std::distance( secondnums.begin( ) , std::find( secondnums.begin( ) ,
+ secondnums.end( ) , firstnums[i] ) )))) ;
+ }
+ std::map<int , std::vector<int>> sums ;
+ for ( auto p : positions ) {
+ sums[p.second].push_back( p.first ) ;
+ }
+ std::vector<std::pair<int , std::vector<int>>> sumpositions { sums.begin( ) ,
+ sums.end( ) } ;
+ std::cout << std::boolalpha << ( std::count_if ( sumpositions.begin( ) ,
+ sumpositions.end( ) , []( const auto & p ) { return p.second.size( )
+ > 1 && isAscending( p.second ) ; } ) == 1 ) << '\n' ;
+ }
+ return 0 ;
+}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/challenge-318/ulrich-rieke/haskell/ch-1.hs b/challenge-318/ulrich-rieke/haskell/ch-1.hs
new file mode 100755
index 0000000000..94300aeac4
--- /dev/null
+++ b/challenge-318/ulrich-rieke/haskell/ch-1.hs
@@ -0,0 +1,12 @@
+module Challenge318
+ where
+import Data.List ( group )
+
+solution :: String -> [String]
+solution word = filter( (>= 3) . length ) $ group word
+
+main :: IO ( )
+main = do
+ putStrLn "Enter a word!"
+ word <- getLine
+ print $ solution word
diff --git a/challenge-318/ulrich-rieke/haskell/ch-2.hs b/challenge-318/ulrich-rieke/haskell/ch-2.hs
new file mode 100755
index 0000000000..6f86f2cfe1
--- /dev/null
+++ b/challenge-318/ulrich-rieke/haskell/ch-2.hs
@@ -0,0 +1,29 @@
+module Challenge318_2
+ where
+import Data.List ( groupBy )
+import Data.List.Split ( divvy )
+import Data.Maybe ( fromJust )
+
+solution :: [Int] -> [Int] -> Bool
+solution firstlist secondlist =
+ let
+ firstzipped = zip [0 , 1 .. ] firstlist
+ secondzipped = zip secondlist [0 , 1 .. ]
+ newPairs = map (\p -> ( fst p , fst p + ( fromJust $ lookup ( snd p )
+ secondzipped ))) firstzipped
+ grouped = groupBy(\ p1 p2 -> snd p1 == snd p2 ) newPairs
+ moreThanOne = filter ( (> 1 ) . length ) grouped
+ in ( length $ filter ( isAscending . map fst ) moreThanOne ) == 1
+
+isAscending :: [Int] -> Bool
+isAscending list = all (\subli -> (last subli - head subli) == 1 ) $
+ divvy 2 1 list
+
+main :: IO ( )
+main = do
+ putStrLn "Enter a first list of integers!"
+ line <- getLine
+ putStrLn "Enter a second list of integers with the same numbers!"
+ secondline <- getLine
+ if length line == 1 && length secondline == 1 then print "True" else
+ print $ solution ( map read $ words line ) ( map read $ words secondline)
diff --git a/challenge-318/ulrich-rieke/perl/ch-1.pl b/challenge-318/ulrich-rieke/perl/ch-1.pl
new file mode 100755
index 0000000000..9d809f7589
--- /dev/null
+++ b/challenge-318/ulrich-rieke/perl/ch-1.pl
@@ -0,0 +1,42 @@
+#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+
+sub isAscending {
+ my $array = shift ;
+ my $len = scalar( @$array ) ;
+ for my $i (0..$len - 2 ) {
+ if ( $array->[$i + 1] - $array->[$i] != 1 ) {
+ return 0 ;
+ }
+ }
+ return 1 ;
+}
+
+say "Enter a word!" ;
+my $word = <STDIN> ;
+chomp $word ;
+my %wordpos ;
+for my $pos ( 0..length( $word ) - 1 ) {
+ push( @{$wordpos{substr( $word , $pos , 1 ) }} , $pos ) ;
+}
+my @solution ;
+my %found ;
+for my $pos( 0..length( $word ) - 1 ) {
+ my @positions ;
+ map { push( @positions, $_ ) } @{$wordpos{substr( $word , $pos , 1 )}} ;
+ if ( scalar( @positions ) >= 3 && isAscending(\@positions)) {
+ my $string = substr( $word , $pos , 1 ) x (scalar( @positions ) ) ;
+ if ( not exists( $found{$string} )) {
+ push( @solution , $string ) ;
+ $found{$string}++ ;
+ }
+ }
+}
+if ( @solution ) {
+ say join( ',' , @solution ) ;
+}
+else {
+ say "\"\"" ;
+}
diff --git a/challenge-318/ulrich-rieke/perl/ch-2.pl b/challenge-318/ulrich-rieke/perl/ch-2.pl
new file mode 100755
index 0000000000..eb35b4b499
--- /dev/null
+++ b/challenge-318/ulrich-rieke/perl/ch-2.pl
@@ -0,0 +1,56 @@
+#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+
+sub find {
+ my $array = shift ;
+ my $elt = shift ;
+ my $pos = 0 ;
+ while ( $array->[$pos] != $elt ) {
+ $pos++ ;
+ }
+ return $pos ;
+}
+
+say "Enter a list of integers!" ;
+my $line = <STDIN> ;
+chomp $line ;
+my @firstnums = split( /\s+/ , $line ) ;
+say "Enter a list of the same integers as above!" ;
+$line = <STDIN> ;
+chomp $line ;
+my @secondnums = split( /\s+/ , $line ) ;
+if ( scalar( @firstnums ) == 1 && scalar( @secondnums ) == 1 ) {
+ say "true" ;
+}
+else {
+ my @sumpositions ;
+ for my $pos (0..scalar( @firstnums) - 1 ) {
+ push( @sumpositions , [$pos , $pos +
+ find( \@secondnums, $firstnums[$pos] )] ) ;
+ }
+ my %sums ;
+ for my $elt ( @sumpositions ) {
+ push( @{$sums{$elt->[1]}} , $elt->[0] ) ;
+ }
+ my @selected = grep { scalar( @$_ ) > 1 && isAscending( $_ ) } values
+ %sums ;
+ if ( scalar( @selected ) == 1 ) {
+ say "true" ;
+ }
+ else {
+ say "false" ;
+ }
+}
+
+sub isAscending {
+ my $array = shift ;
+ my $len = scalar( @$array ) ;
+ for my $pos (0..$len - 2 ) {
+ if ( $array->[$pos + 1] - $array->[$pos] != 1 ) {
+ return 0 ;
+ }
+ }
+ return 1 ;
+}
diff --git a/challenge-318/ulrich-rieke/raku/ch-1.raku b/challenge-318/ulrich-rieke/raku/ch-1.raku
new file mode 100755
index 0000000000..f4ace36f56
--- /dev/null
+++ b/challenge-318/ulrich-rieke/raku/ch-1.raku
@@ -0,0 +1,35 @@
+use v6 ;
+
+say "Enter a word!" ;
+my $word = $*IN.get ;
+my %wordpos ;
+my $len = $word.chars ;
+for (0..$len - 1) -> $pos {
+ %wordpos{$word.substr( $pos , 1 ) }.push( $pos ) ;
+}
+my @solution ;
+for ( 0..$len - 1) -> $pos {
+ my $part = $word.substr( $pos , 1 ) ;
+ my @positions ;
+ %wordpos{$part}.map( {@positions.push( $_ )} ) ;
+ if ( @positions.elems >= 3 && isAscending( @positions )) {
+ my $string = $part x @positions.elems ;
+ @solution.push( $string ) ;
+ }
+}
+if ( @solution ) {
+ say @solution.unique.join( ',' ) ;
+}
+else {
+ say "\"\"" ;
+}
+
+sub isAscending( @array ) {
+ my $len = @array.elems ;
+ for ( 0..$len - 2 ) -> $pos {
+ if ( @array[$pos + 1] - @array[$pos] != 1 ) {
+ return False ;
+ }
+ }
+ return True ;
+}
diff --git a/challenge-318/ulrich-rieke/raku/ch-2.raku b/challenge-318/ulrich-rieke/raku/ch-2.raku
new file mode 100755
index 0000000000..81817a9358
--- /dev/null
+++ b/challenge-318/ulrich-rieke/raku/ch-2.raku
@@ -0,0 +1,48 @@
+use v6 ;
+
+sub find ( @array , $element ) {
+ my $pos = 0 ;
+ while ( @array[$pos] != $element ) {
+ $pos++ ;
+ }
+ return $pos ;
+}
+
+sub isAscending( $array ) {
+ my $len = $array.elems ;
+ for (0..$len - 2) -> $pos {
+ if ( $array[$pos + 1 ] - $array[$pos] != 1 ) {
+ return False ;
+ }
+ }
+ return True ;
+}
+#we create a list of the position of every integer in the first array
+#and of the sum of the positions in the first and in the second array
+#if part of the array is reversed the sum of the positions in the 2
+#arrays must be the same. We make these sums the keys of a hash and
+#associate the positions in the first array with it
+#output must be true if there is exactly one sum that is associated
+#to an ascending list of length > 1
+say "Enter a list of integers!" ;
+my $line = $*IN.get ;
+my @firstnums = $line.words.map( {.Int} ) ;
+say "Enter another list with the same integers!" ;
+$line = $*IN.get ;
+my @secondnums = $line.words.map( {.Int} ) ;
+if ( @firstnums.elems == 1 && @secondnums.elems == 1 ) {
+ say "True" ;
+}
+else {
+ my @positionsums ;
+ for (0..@firstnums.elems - 1) -> $pos {
+ @positionsums.push( ($pos , $pos + find( @secondnums ,
+ @firstnums[$pos]))) ;
+ }
+ my %sums ;
+ for @positionsums -> @elt {
+ %sums{@elt[1]}.push( @elt[0] ) ;
+ }
+ my @selected = %sums.values.grep( {$_.elems > 1 && isAscending( $_ )} ) ;
+ say ( @selected.elems == 1 ) ;
+}
diff --git a/challenge-318/ulrich-rieke/rust/ch-1.rs b/challenge-318/ulrich-rieke/rust/ch-1.rs
new file mode 100755
index 0000000000..738f2a921b
--- /dev/null
+++ b/challenge-318/ulrich-rieke/rust/ch-1.rs
@@ -0,0 +1,46 @@
+use std::io ;
+use std::collections::HashMap ;
+
+fn is_ascending( positions : &Vec<usize> ) -> bool {
+ let mut result : bool = true ;
+ let len = positions.len( ) ;
+ for i in 0..len - 1 {
+ if positions[i + 1] - positions[i] != 1 {
+ result = false ;
+ break ;
+ }
+ }
+ result
+}
+
+fn main() {
+ println!("Enter a word!");
+ let mut inline : String = String::new( ) ;
+ io::stdin( ).read_line( &mut inline ).unwrap( ) ;
+ let word : &str = inline.trim( ) ;
+ let pairs : Vec<(usize, char)> = word.chars( ).enumerate( ).collect( ) ;
+ let mut positions : HashMap<char, Vec<usize>> = HashMap::new( ) ;
+ for ( n , c ) in pairs {
+ positions.entry( c ).and_modify( |v| v.push(n) ).or_insert(
+ vec![n] ) ;
+ }
+ let mut solution : Vec<String> = Vec::new( ) ;
+ let mut all_keys : Vec<&char> = positions.keys( ).collect( ) ;
+ all_keys.sort( ) ;
+ for k in all_keys {
+ let v = positions.get( &*k ).unwrap( ) ;
+ if v.len( ) >= 3 && is_ascending( &v ) {
+ let mut a_word : String = String::new( ) ;
+ for _ in 0..v.len( ) {
+ a_word.push( *k ) ;
+ }
+ solution.push( a_word.clone( ) ) ;
+ }
+ }
+ if solution.len( ) > 0 {
+ println!("{:?}" , solution ) ;
+ }
+ else {
+ println!("\"\"") ;
+ }
+}
diff --git a/challenge-318/ulrich-rieke/rust/ch-2.rs b/challenge-318/ulrich-rieke/rust/ch-2.rs
new file mode 100755
index 0000000000..9e9f03d969
--- /dev/null
+++ b/challenge-318/ulrich-rieke/rust/ch-2.rs
@@ -0,0 +1,50 @@
+use std::io ;
+use std::collections::HashMap ;
+
+fn is_ascending( list : &Vec<usize> ) -> bool {
+ let mut result : bool = true ;
+ let len : usize = list.len( ) ;
+ for pos in 0..len - 1 {
+ if list[ pos + 1 ] - list[pos] != 1 {
+ result = false ;
+ break ;
+ }
+ }
+ result
+}
+
+fn main() {
+ println!("Enter some integers separated by blanks!");
+ let mut inline : String = String::new( ) ;
+ io::stdin( ).read_line( &mut inline ).unwrap( ) ;
+ println!("Enter another array which contains the same numbers!") ;
+ let mut secondline : String = String::new( ) ;
+ io::stdin( ).read_line( &mut secondline ).unwrap( ) ;
+ let firstnums : Vec<i32> = inline.trim( ).split_whitespace( ).map( |s|
+ s.parse::<i32>( ).unwrap( ) ).collect( ) ;
+ let secondnums : Vec<i32> = secondline.trim( ).split_whitespace( ).map(
+ |s| s.parse::<i32>( ).unwrap( ) ). collect( ) ;
+ if firstnums.len( ) == 1 && secondnums.len( ) == 1 {
+ println!("true") ;
+ }
+ else {
+ //we add up the positions of the numbers in the 2 arrays. If parts
+ //of the lists are reversed the sum of their positions is identical.
+ //We hash every sum with a list of their occurrences and see
+ //whether these lists are ascending
+ let positions_found : Vec<(usize , usize)> = firstnums.into_iter( ).
+ enumerate( ).map( |p| {
+ let found = secondnums.iter( ).position( |n| *n == p.1 )
+ .unwrap() ;
+ (p.0 , p.0 + found)
+ }).collect( ) ;
+ let mut sum_positions : HashMap<usize , Vec<usize>> = HashMap::new( ) ;
+ for ( a , b ) in positions_found {
+ sum_positions.entry( b ).and_modify( |v| v.push( a )).or_insert(
+ vec![a] ) ;
+ }
+ println!("{}" , sum_positions.values( ).into_iter().filter( |v| {
+ v.len( ) > 1 && is_ascending( &v )
+ }).count( ) == 1 ) ;
+ }
+}
diff --git a/stats/pwc-challenge-317.json b/stats/pwc-challenge-317.json
new file mode 100644
index 0000000000..e7504adde8
--- /dev/null
+++ b/stats/pwc-challenge-317.json
@@ -0,0 +1,600 @@
+{
+ "xAxis" : {
+ "type" : "category"
+ },
+ "drilldown" : {
+ "series" : [
+ {
+ "name" : "Adam Russell",
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Blog",
+ 2
+ ]
+ ],
+ "id" : "Adam Russell"
+ },
+ {
+ "name" : "Ali Moradi",
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ],
+ "id" : "Ali Moradi"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ]
+ ],
+ "name" : "Andreas Mahnke",
+ "id" : "Andreas Mahnke"
+ },
+ {
+ "name" : "Arne Sommer",
+ "data" : [
+ [
+ "Raku",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ],
+ "id" : "Arne Sommer"
+ },
+ {
+ "name" : "Athanasius",
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Raku",
+ 2
+ ]
+ ],
+ "id" : "Athanasius"
+ },
+ {
+ "data" : [
+ [
+ "Raku",
+ 1
+ ]
+ ],
+ "name" : "BarrOff",
+ "id" : "BarrOff"
+ },
+ {
+ "name" : "Bob Lied",
+ "data" : [
+ [
+ "Perl",
+ 2
+ ]
+ ],
+ "id" : "Bob Lied"
+ },
+ {
+ "id" : "Dave Jacoby",
+ "name" : "Dave Jacoby",
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ]
+ },
+ {
+ "id" : "David Ferrone",
+ "data" : [
+ [
+ "Perl",
+ 2
+ ]
+ ],
+ "name" : "David Ferrone"
+ },
+ {
+ "id" : "E. Choroba",
+ "name" : "E. Choroba",
+ "data" : [
+ [
+ "Perl",
+ 2
+ ]
+ ]
+ },
+ {
+ "id" : "Feng Chang",
+ "data" : [
+ [
+ "Raku",
+ 2
+ ]
+ ],
+ "name" : "Feng Chang"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Raku",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ],
+ "name" : "Jaldhar H. Vyas",
+ "id" : "Jaldhar H. Vyas"
+ },
+ {
+ "data" : [
+ [