aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2024-02-20 15:56:30 +0000
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2024-02-20 15:56:30 +0000
commitddd42e0db3017a5ec3108d09efba477f19e7f04b (patch)
tree91b2b3f8b0052f0de4f236cb723ab802820f2e94
parent43ba87df5e3aaa950fcf8ef55152105fe311276f (diff)
downloadperlweeklychallenge-club-ddd42e0db3017a5ec3108d09efba477f19e7f04b.tar.gz
perlweeklychallenge-club-ddd42e0db3017a5ec3108d09efba477f19e7f04b.tar.bz2
perlweeklychallenge-club-ddd42e0db3017a5ec3108d09efba477f19e7f04b.zip
- Added solutions by Ulrich Rieke.
-rwxr-xr-xchallenge-257/ulrich-rieke/cpp/ch-1.cpp21
-rwxr-xr-xchallenge-257/ulrich-rieke/cpp/ch-2.cpp138
-rwxr-xr-xchallenge-257/ulrich-rieke/haskell/ch-1.hs11
-rwxr-xr-xchallenge-257/ulrich-rieke/haskell/ch-2.hs74
-rwxr-xr-xchallenge-257/ulrich-rieke/perl/ch-1.pl11
-rwxr-xr-xchallenge-257/ulrich-rieke/perl/ch-2.pl160
-rwxr-xr-xchallenge-257/ulrich-rieke/raku/ch-1.raku10
-rwxr-xr-xchallenge-257/ulrich-rieke/rust/ch-1.rs16
-rwxr-xr-xchallenge-257/ulrich-rieke/rust/ch-2.rs122
-rw-r--r--stats/pwc-current.json107
-rw-r--r--stats/pwc-language-breakdown-summary.json60
-rw-r--r--stats/pwc-language-breakdown.json1728
-rw-r--r--stats/pwc-leaders.json382
-rw-r--r--stats/pwc-summary-1-30.json40
-rw-r--r--stats/pwc-summary-121-150.json52
-rw-r--r--stats/pwc-summary-151-180.json48
-rw-r--r--stats/pwc-summary-181-210.json130
-rw-r--r--stats/pwc-summary-211-240.json34
-rw-r--r--stats/pwc-summary-241-270.json40
-rw-r--r--stats/pwc-summary-271-300.json50
-rw-r--r--stats/pwc-summary-301-330.json62
-rw-r--r--stats/pwc-summary-31-60.json34
-rw-r--r--stats/pwc-summary-61-90.json38
-rw-r--r--stats/pwc-summary-91-120.json106
-rw-r--r--stats/pwc-summary.json26
25 files changed, 2041 insertions, 1459 deletions
diff --git a/challenge-257/ulrich-rieke/cpp/ch-1.cpp b/challenge-257/ulrich-rieke/cpp/ch-1.cpp
new file mode 100755
index 0000000000..292959c14a
--- /dev/null
+++ b/challenge-257/ulrich-rieke/cpp/ch-1.cpp
@@ -0,0 +1,21 @@
+#include <iostream>
+#include <vector>
+#include <iterator>
+#include <algorithm>
+
+int main( ) {
+ std::cout << "Enter some integers, separated by blanks!\n" ;
+ std::cout << "Enter e to end entry!\n" ;
+ std::vector<int> numbers { std::istream_iterator<int>{ std::cin } ,
+ std::istream_iterator<int>{} } ;
+ std::vector<int> result ;
+ for ( int i : numbers ) {
+ result.push_back( std::count_if( numbers.begin( ) , numbers.end( ) ,
+ [i]( int n ) { return n < i ; } ) ) ;
+ }
+ std::cout << "( " ;
+ std::copy( result.begin( ) , result.end( ) ,
+ std::ostream_iterator<int>( std::cout , " " )) ;
+ std::cout << ")\n" ;
+ return 0 ;
+}
diff --git a/challenge-257/ulrich-rieke/cpp/ch-2.cpp b/challenge-257/ulrich-rieke/cpp/ch-2.cpp
new file mode 100755
index 0000000000..b365f93c0b
--- /dev/null
+++ b/challenge-257/ulrich-rieke/cpp/ch-2.cpp
@@ -0,0 +1,138 @@
+#include <iostream>
+#include <string>
+#include <vector>
+#include <algorithm>
+#include <iterator>
+#include <utility>
+typedef std::vector<std::vector<int>> matrix ;
+
+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 ;
+}
+
+bool hasLeadingOne( const matrix & numbers ) {
+ for ( auto & row : numbers ) {
+ auto found = std::find_if( row.begin( ) , row.end( ) , []( int n ) {
+ return n != 0 ; } ) ;
+ if ( found != row.end( ) ) {
+ if (*found != 1) {
+ return false ;
+ }
+ }
+ }
+ return true ;
+}
+
+bool zeroesAtBottom( const matrix & numbers ) {
+ std::vector<int> zeroIndices ;
+ std::vector<int> theRest ;
+ int count = 0 ;
+ for ( auto & row : numbers ) {
+ auto found = std::find_if( row.begin( ) , row.end( ) , []( int n ) {
+ return n != 0 ; } ) ;
+ if ( found != row.end( ) ) { //row does not only contain 0
+ theRest.push_back( count ) ;
+ }
+ else { //row contains only 0
+ zeroIndices.push_back( count ) ;
+ }
+ count++ ;
+ }
+ //the maximum row number of all lines not containing 0's only must be
+ //smaller than any of the line numbers of lines containing only 0's
+ int maximum = *std::max_element( theRest.begin( ) , theRest.end( ) ) ;
+ return std::all_of( zeroIndices.begin( ) , zeroIndices.end( ) ,
+ [maximum]( int n ) { return n > maximum ; } ) ;
+}
+
+//are all leading ones staggered from left to right ?
+bool staggeredOnes( const matrix & numbers ) {
+ std::vector<int> leadingOnes ; //the positions of all leading 1's
+ for ( auto & row : numbers ) {
+ auto found = std::find_if( row.begin( ) , row.end( ) , []( int n ) {
+ return n != 0 ; } ) ;
+ if ( found != row.end( ) ) {
+ if ( *found == 1 ) {
+ leadingOnes.push_back( static_cast<int>(std::distance( row.begin( ),
+ found ))) ;
+ }
+ }
+ }
+ int len = leadingOnes.size( ) ;
+ if ( len == 0 || len == 1 ) {
+ return true ;
+ }
+ if ( len == 2 ) {
+ return leadingOnes[1] > leadingOnes[0] ;
+ }
+ if ( len > 2 ) {
+ for ( int i = 0 ; i < len - 1 ; i++ ) {
+ if ( leadingOnes[ i + 1 ] < leadingOnes[ i ] ) {
+ return false ;
+ }
+ }
+ }
+ return true ;
+}
+
+bool allZeroesInLeadingOneColumn( const matrix & numbers ) {
+ std::vector<std::pair<int, int>> leadingOnePositions ;
+ int len = numbers.size( ) ;
+ for ( int i = 0 ; i < len ; i++ ) {
+ std::vector<int> row { numbers[ i ] } ;
+ auto found = std::find_if( row.begin( ) , row.end( ) , []( int n ) {
+ return n != 0 ; } ) ;
+ if ( found != row.end( ) ) {
+ if ( *found == 1 ) {
+ int pos = static_cast<int>(std::distance( row.begin( ) , found ) ) ;
+ leadingOnePositions.push_back( std::make_pair( i , pos ) ) ;
+ }
+ }
+ }
+ for ( auto & p : leadingOnePositions ) {
+ for ( int i = 0 ; i < len ; i++ ) {
+ if ( i != p.first ) {
+ if ( numbers[i][p.second] != 0 ) {
+ return false ;
+ }
+ }
+ }
+ }
+ return true ;
+}
+
+int main( ) {
+ std::cout << "Enter some integers, separated by blanks!\n" ;
+ std::cout << "Enter <return> to stop entry!\n" ;
+ std::string line ;
+ matrix numbers ;
+ std::getline( std::cin , line ) ;
+ while ( line.length( ) != 0 ) {
+ std::vector<std::string> row { split( line , " " ) } ;
+ std::vector<int> numberrow ;
+ for ( auto & s : row ) {
+ numberrow.push_back( std::stoi( s ) ) ;
+ }
+ numbers.push_back( numberrow ) ;
+ line.clear( ) ;
+ std::getline( std::cin , line ) ;
+ }
+ if ( hasLeadingOne( numbers ) && zeroesAtBottom( numbers ) &&
+ staggeredOnes( numbers ) && allZeroesInLeadingOneColumn( numbers )) {
+ std::cout << 1 << '\n' ;
+ }
+ else {
+ std::cout << 0 << '\n' ;
+ }
+ return 0 ;
+}
+
diff --git a/challenge-257/ulrich-rieke/haskell/ch-1.hs b/challenge-257/ulrich-rieke/haskell/ch-1.hs
new file mode 100755
index 0000000000..c3b5b5daa4
--- /dev/null
+++ b/challenge-257/ulrich-rieke/haskell/ch-1.hs
@@ -0,0 +1,11 @@
+module Challenge257
+ where
+
+solution :: [Int] -> [Int]
+solution list = map (\i -> length $ filter ( < i ) list ) list
+
+main :: IO ( )
+main = do
+ putStrLn "Enter some integers, separated by blanks!"
+ numbers <- getLine
+ print $ solution $ map read $ words numbers
diff --git a/challenge-257/ulrich-rieke/haskell/ch-2.hs b/challenge-257/ulrich-rieke/haskell/ch-2.hs
new file mode 100755
index 0000000000..5b45b72d45
--- /dev/null
+++ b/challenge-257/ulrich-rieke/haskell/ch-2.hs
@@ -0,0 +1,74 @@
+module Challenge257_2
+ where
+import Data.List ( transpose , sortOn , findIndices , (!!))
+import Data.List.Split ( divvy )
+
+findLeadingNonNull :: [[Int]] -> [(Int , [Int] )]
+findLeadingNonNull block = map (\p -> (fst p , findIndices (/= 0 ) $ block !! (
+ fst p ) )) $ zip [0, 1 ..] block
+
+hasLeadingOne :: [[Int]] -> Bool
+hasLeadingOne block = null pairs || all (\p -> ( block !! ( fst p )
+ !! ( head $ snd p )) == 1 ) pairs
+ where
+ pairs = filter ( not . null . snd ) $ findLeadingNonNull block
+
+zeroesAtBottom :: [[Int]] -> Bool
+zeroesAtBottom block = null nulls || maximum_nonNulls < minimum_nulls
+ where
+ allNull :: [Int] -> Bool
+ allNull row = all ( == 0 ) row
+ pairs :: [(Int , [Int])]
+ pairs = zip [0,1..] block
+ nonNulls :: [(Int , [Int])]
+ nonNulls = sortOn fst $ filter ( not. allNull . snd ) pairs
+ nulls :: [(Int , [Int] )]
+ nulls = sortOn fst $ filter ( allNull . snd ) pairs
+ maximum_nonNulls :: Int
+ maximum_nonNulls = fst $ last $ nonNulls
+ minimum_nulls ::Int
+ minimum_nulls = fst $ head $ nulls
+
+hasStackedOnes :: [[Int]] -> Bool
+hasStackedOnes matrix =
+ let pairs = filter ( not . null . snd ) $ findLeadingNonNull matrix
+ leadingOnes = filter (\p -> (matrix !! ( fst p ) !! ( head $ snd p )) == 1 )
+ pairs
+ positions = map ( head . snd ) leadingOnes
+ myP = length positions
+ in null pairs || myP == 1 || ( if myP == 2 then ( positions !! 1 )
+ > ( positions !! 0 ) else all (\subli -> last subli > head subli ) $ divvy
+ 2 1 positions )
+
+leadingOnesAllNullCol :: [[Int]] -> Bool
+leadingOnesAllNullCol matrix =
+ let pairs = filter ( not . null . snd ) $ findLeadingNonNull matrix
+ leadingOnes = filter (\p -> (matrix !! ( fst p ) !! ( head $ snd p )) == 1 )
+ pairs
+ positions = map ( head . snd ) leadingOnes
+ transposed = transpose matrix
+ l = length matrix
+ in null pairs || all (\col -> (length $ findIndices (== 0) (transposed !! col))
+ == l - 1 ) positions
+
+condition :: [[Int]] -> Bool
+condition matrix = leadingOnesAllNullCol matrix && hasStackedOnes matrix
+ && zeroesAtBottom matrix && hasLeadingOne matrix
+
+getMatrix :: IO [String]
+getMatrix = do
+ line <- getLine
+ if not $ null line then do
+ restOfLines <- getMatrix
+ return ( line : restOfLines )
+ else do
+ return []
+
+main :: IO ( )
+main = do
+ putStrLn "Enter some integers, separated by blanks!"
+ putStrLn "Enter <return> to end entry!"
+ matrix <- getMatrix
+ let numbers = map ( map read . words ) matrix
+ --print $ leadingOnesAllNullCol numbers
+ if condition numbers then print 1 else print 0
diff --git a/challenge-257/ulrich-rieke/perl/ch-1.pl b/challenge-257/ulrich-rieke/perl/ch-1.pl
new file mode 100755
index 0000000000..2540512dc7
--- /dev/null
+++ b/challenge-257/ulrich-rieke/perl/ch-1.pl
@@ -0,0 +1,11 @@
+use v5.36.0 ;
+
+say "Enter some integers, separated by blanks!" ;
+my $line = <STDIN> ;
+chomp $line ;
+my @numbers = split( /\s+/ , $line ) ;
+my @result ;
+for my $num( @numbers ) {
+ push @result , scalar( grep { $_ < $num } @numbers ) ;
+}
+say "(" . join( ',' , @result ) . ")" ;
diff --git a/challenge-257/ulrich-rieke/perl/ch-2.pl b/challenge-257/ulrich-rieke/perl/ch-2.pl
new file mode 100755
index 0000000000..c2c453d3a0
--- /dev/null
+++ b/challenge-257/ulrich-rieke/perl/ch-2.pl
@@ -0,0 +1,160 @@
+#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+use List::Util qw ( any all max) ;
+
+sub findOnePos { #find the first position of a 1 if there is one
+ my $row = shift ;
+ my $len = scalar( @$row ) ;
+ my $pos = 0 ;
+ while ( $row->[$pos] == 0 ) {
+ $pos++ ;
+ if ( $pos == $len ) {
+ last ;
+ }
+ }
+ if ( $pos < $len ) {
+ if ( $row->[$pos] == 1 ) {
+ return $pos ;
+ }
+ else {
+ return -1 ;
+ }
+ }
+ else {
+ return -1 ;
+ }
+}
+
+#determine whether a possible non-0 entry in a row is a 1
+sub hasLeadingOne {
+ my $matrix = shift ;
+ for my $row ( @$matrix ) {
+ if ( any { $_ != 0 } @$row ) {
+ my $pos = 0 ;
+ while ( $row->[$pos] == 0 ) {
+ $pos++ ;
+ }
+ if ( $row->[$pos] != 1 ) {#it not a 1
+ return 0 ; #return false
+ }
+ }
+ }
+ return 1 ;
+}
+
+sub zeroesAtBottom {
+ my $matrix = shift ;
+ my @rownum ;#create an array of row number and row content
+ my $count = 0 ;
+ for my $row( @$matrix ) {
+ my @currentrow = @$row ;#it's better to dereference...!
+ push( @rownum, [$count , join( '' , @currentrow ) ] ) ;
+ $count++ ;
+ }
+ my @allZeroIndices ;#indices of lines consisting of 0's only
+ my @theRest ; #the other lines
+ for my $pair( @rownum ) {
+ my @r = split( // , $pair->[1] ) ; #split the line content
+ if ( all { $_ eq '0' } @r ) {#if it only contains '0'
+ push @allZeroIndices , $pair->[0] ;#grab the line index
+ }
+ else {
+ push @theRest , $pair->[0] ;
+ }
+ }
+ my $maximum = max( @theRest ) ;
+#the maximum of the line indices of lines containing not only 0 must be
+#smaller than all indices of lines containing only 0
+ if ( all { $_ > $maximum } @allZeroIndices ) {
+ return 1 ;
+ }
+ else {
+ return 0 ;
+ }
+}
+
+#do leading ones follow through from left to right ?
+sub staggeredOnes {
+ my $matrix = shift ;
+ my @leadingOnes ;#positions of leading ones
+ for my $row( @$matrix ) {
+ if ( any { $_ != 0 } @$row ) {
+ my $num = findOnePos( $row ) ;
+ if ( $num != -1 ) { #we found a leading one, see function above
+ push @leadingOnes , $num ;
+ }
+ }
+ }
+ my $len = scalar( @leadingOnes ) ;
+ if ( $len == 0 || $len == 1 ) { #staggered criterion does not apply
+ return 1 ;
+ }
+ else {
+ if ( $len == 2 ) {
+ if ( $leadingOnes[1] > $leadingOnes[0] ) {
+ return 1 ;
+ }
+ else {
+ return 0 ;
+ }
+ }
+ if ( $len > 2 ) {
+ for my $i (0..$len - 2 ) {
+ if ( $leadingOnes[ $i + 1 ] < $leadingOnes[ $i ] ) {
+ return 0 ;
+ }
+ }
+ return 1 ;
+ }
+ }
+}
+
+#do all leading ones live in a column of 0's only ?
+sub allZeroesInLeadingOneColumn {
+ my $matrix = shift ;
+ my $len = scalar( @$matrix ) ;
+ my @leadingOnePositions ;#contains arrays of rows and columns of leading 1's
+ for my $r( 0..$len - 1 ) {
+ my $row = $matrix->[$r] ;#current row
+ if ( any { $_ != 0 } @$row ) {
+ my $num = findOnePos( $row ) ;
+ if ( $num != -1 ) { #we found a leading 1 position
+ push @leadingOnePositions , [$r , $num] ;
+ }
+ }
+ }
+ for my $pair( @leadingOnePositions ) {
+ for my $i (0..$len - 1 ) {#for all rows in the matrix
+ if ( $pair->[0] != $i ) {#if the current row is not equal to the row
+#number of a leading 1
+ if ( $matrix->[$i]->[$pair->[1]] != 0 ) {#it must be unequal zero
+ return 0 ; #short circuiting if the matrix entry above or below
+#is not 0
+ }
+ }
+ }
+ }
+ return 1 ;
+}
+
+say "Enter some integers, separated by blanks!" ;
+say "Enter <return> to end entry!" ;
+my @matrix ;
+my $line = <STDIN> ;
+chomp $line ;
+while ( $line ) {
+ my @row = split( /\s+/ , $line ) ;
+ push @matrix, \@row ;
+ $line = <STDIN> ;
+ chomp $line ;
+}
+#test all conditions
+if ( hasLeadingOne( \@matrix ) && zeroesAtBottom( \@matrix ) && staggeredOnes(
+ \@matrix ) && allZeroesInLeadingOneColumn( \@matrix ) ) {
+ say 1 ;
+}
+else {
+ say 0 ;
+}
diff --git a/challenge-257/ulrich-rieke/raku/ch-1.raku b/challenge-257/ulrich-rieke/raku/ch-1.raku
new file mode 100755
index 0000000000..43bcf61b3d
--- /dev/null
+++ b/challenge-257/ulrich-rieke/raku/ch-1.raku
@@ -0,0 +1,10 @@
+use v6 ;
+
+say "Enter some integers, separated by blanks!" ;
+my $line = $*IN.get ;
+my @numbers = $line.words.map( {.Int} ) ;
+my @result ;
+for @numbers -> $num {
+ @result.push( @numbers.grep( { $_ < $num } ).elems ) ;
+}
+say "(" ~ @result.join( ',' ) ~ ")" ;
diff --git a/challenge-257/ulrich-rieke/rust/ch-1.rs b/challenge-257/ulrich-rieke/rust/ch-1.rs
new file mode 100755
index 0000000000..372ad67cc7
--- /dev/null
+++ b/challenge-257/ulrich-rieke/rust/ch-1.rs
@@ -0,0 +1,16 @@
+use std::io ;
+
+fn main() {
+ println!("Enter some integers, separated by blanks!");
+ let mut inline : String = String::new( ) ;
+ io::stdin( ).read_line( &mut inline ).unwrap( ) ;
+ let entered_line : &str = &*inline ;
+ let numbers : Vec<i32> = entered_line.split_whitespace( ).map( | s |
+ s.trim( ).parse::<i32>().unwrap( ) ).collect( ) ;
+ let mut result : Vec<usize> = Vec::new( ) ;
+ for i in &numbers {
+ let num = numbers.iter( ).filter( |&x| *x < *i ).count( ) ;
+ result.push( num ) ;
+ }
+ println!("{:?}" , result ) ;
+}
diff --git a/challenge-257/ulrich-rieke/rust/ch-2.rs b/challenge-257/ulrich-rieke/rust/ch-2.rs
new file mode 100755
index 0000000000..eb9a0d1aa2
--- /dev/null
+++ b/challenge-257/ulrich-rieke/rust/ch-2.rs
@@ -0,0 +1,122 @@
+use std::io ;
+use std::io::BufRead ;
+
+fn has_leading_one( matrix : &Vec<Vec<i32>> ) -> bool {
+ for row in matrix {
+ let found : Option<i32> = row.iter( ).find( | x | **x != 0 ).copied( ) ;
+ if found.is_some( ) {
+ let num = found.unwrap( ) ;
+ if num != 1 {
+ return false ;
+ }
+ }
+ }
+ true
+}
+
+fn zeros_at_bottom( matrix : &Vec<Vec<i32>> ) -> bool {
+ let enumerated_rows : Vec<(usize, &Vec<i32>)> = matrix.iter( ).
+ enumerate( ).collect( ) ;
+ let mut all_zero_indices : Vec<usize> = Vec::new( ) ;
+ let mut the_rest : Vec<usize> = Vec::new( ) ;
+ for p in &enumerated_rows {
+ if p.1.iter( ).all( | x | *x == 0 ) {
+ all_zero_indices.push( p.0 ) ;
+ }
+ else {
+ the_rest.push( p.0 ) ;
+ }
+ }
+ let maximum = the_rest.iter( ).max().unwrap( ) ;
+ all_zero_indices.iter( ).all( | d | *d > *maximum )
+}
+
+fn staggered_ones( matrix : &Vec<Vec<i32>> ) -> bool {
+ let mut leading_ones : Vec<usize> = Vec::new( ) ;
+ for row in matrix {
+ let found : Option<i32> = row.iter( ).find( | x | **x != 0 ).copied( ) ;
+ if found.is_some( ) {
+ let num = found.unwrap( ) ;
+ if num == 1 {
+ let pos = row.iter( ).position( | &x | x == 1 ).unwrap( ) ;
+ leading_ones.push( pos ) ;
+ }
+ }
+ }
+ let len = leading_ones.len( ) ;
+ if len == 0 || len == 1 {
+ true
+ }
+ else {
+ if len == 2 {
+ leading_ones[1] > leading_ones[0]
+ }
+ else {
+ for i in 0..len - 1 {
+ if leading_ones[ i + 1 ] < leading_ones[ i ] {
+ return false ;
+ }
+ }
+ return true ;
+ }
+ }
+}
+
+fn all_zeroes_in_leading_one_column( matrix : &Vec<Vec<i32>> ) -> bool {
+ let mut leading_one_positions : Vec<(usize, usize)> = Vec::new( ) ;
+ let len = matrix.len( ) ;
+ for i in 0..len {
+ let row = &matrix[ i ] ;
+ let found : Option<i32> = row.iter( ).find( |x| **x != 0 ).copied( ) ;
+ if found.is_some( ) {
+ let num = found.unwrap( ) ;
+ if num == 1 {
+ let pos = row.iter( ).position( | x | *x == 1 ).unwrap( ) ;
+ leading_one_positions.push( (i , pos) ) ;
+ }
+ }
+ }
+ leading_one_positions.iter( ).all( |(r , col)| {
+ for i in 0..len {
+ if i != *r {
+ return matrix[i][*col] == 0 ;
+ }
+ }
+ false
+ })
+}
+
+fn main() -> io::Result<()> {
+ println!("Enter some integers, separated by blanks!");
+ println!( "Enter <return> to end entry!" ) ;
+ let mut lines = io::stdin( ).lock( ).lines( ) ;
+ let mut all_input : String = String::new( ) ;
+ while let Some( line ) = lines.next( ) {
+ let last_input = line.unwrap( ) ;
+ if last_input.len( ) == 0 {
+ break ;
+ }
+ else {
+ all_input.push_str( &last_input ) ;
+ all_input.push_str( "\n" ) ;
+ }
+ }
+ let mut matrix : Vec<Vec<i32>> = Vec::new( ) ;
+ let rows : Vec<&str> = all_input.split( "\n" ).collect( ) ;
+ for r in &rows {
+ if r.len( ) != 0 {
+ let numbers : Vec<i32> = r.split_whitespace( ).map( | s |
+ s.trim( ).parse::<i32>( ).unwrap( )).collect( ) ;
+ matrix.push( numbers ) ;
+ }
+ }
+ if has_leading_one( &matrix ) && zeros_at_bottom( &matrix ) &&
+ staggered_ones( &matrix ) && all_zeroes_in_leading_one_column(
+ &matrix ) {
+ println!("1") ;
+ }
+ else {
+ println!("0") ;
+ }
+ Ok(())
+}
diff --git a/stats/pwc-current.json b/stats/pwc-current.json
index 1e5121f495..ff1e449c49 100644
--- a/stats/pwc-current.json
+++ b/stats/pwc-current.json
@@ -1,21 +1,22 @@
{
- "yAxis" : {
- "title" : {
- "text" : "Total Solutions"
- }
- },
- "subtitle" : {
- "text" : "[Champions: 8] Last updated at 2024-02-20 14:16:52 GMT"
+ "legend" : {
+ "enabled" : 0
},
"plotOptions" : {
"series" : {
"dataLabels" : {
- "enabled" : 1,
- "format" : "{point.y}"
+ "format" : "{point.y}",
+ "enabled" : 1
},
"borderWidth" : 0
}
},
+ "xAxis" : {
+ "type" : "category"
+ },
+ "title" : {
+ "text" : "The Weekly Challenge - 257"
+ },
"drilldown" : {
"series" : [
{
@@ -29,7 +30,6 @@
"id" : "Bob Lied"
},
{
- "id" : "Dave Jacoby",
"data" : [
[
"Perl",
@@ -40,17 +40,18 @@
1
]
],
+ "id" : "Dave Jacoby",
"name" : "Dave Jacoby"
},
{
- "name" : "David Ferrone",
+ "id" : "David Ferrone",
"data" : [
[
"Perl",
2
]
],
- "id" : "David Ferrone"
+ "name" : "David Ferrone"
},
{
"id" : "Luca Ferrari",
@@ -77,13 +78,13 @@
"id" : "Mariano Spadaccini"
},
{
- "id" : "Mark Anderson",
"data" : [
[
"Raku",
2
]
],
+ "id" : "Mark Anderson",
"name" : "Mark Anderson"
},
{
@@ -101,7 +102,6 @@
"id" : "Roger Bell_West"
},
{
- "id" : "Thomas Kohler",
"name" : "Thomas Kohler",
"data" : [
[
@@ -112,43 +112,70 @@
"Blog",
2
]
+ ],
+ "id" : "Thomas Kohler"
+ },
+ {
+ "name" : "Ulrich Rieke",
+ "id" : "Ulrich Rieke",
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Raku",
+ 1
+ ]
]
}
]
},
- "xAxis" : {
- "type" : "category"
+ "yAxis" : {
+ "title" : {
+ "text" : "Total Solutions"
+ }
+ },
+ "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: 9] Last updated at 2024-02-20 15:51:01 GMT"
},
"chart" : {
"type" : "column"
},
"series" : [
{
+ "name" : "The Weekly Challenge - 257",
+ "colorByPoint" : 1,
"data" : [
{
+ "name" : "Bob Lied",
"drilldown" : "Bob Lied",
- "y" : 2,
- "name" : "Bob Lied"
+ "y" : 2
},
{
+ "name" : "Dave Jacoby",
"drilldown" : "Dave Jacoby",
- "y" : 3,
- "name" : "Dave Jacoby"
+ "y" : 3
},
{
- "y" : 2,
"drilldown" : "David Ferrone",
- "name" : "David Ferrone"
+ "name" : "David Ferrone",
+ "y" : 2
},
{
"name" : "Luca Ferrari",
- "y" : 11,
- "drilldown" : "Luca Ferrari"
+ "drilldown" : "Luca Ferrari",
+ "y" : 11
},
{
- "drilldown" : "Mariano Spadaccini",
"y" : 1,
- "name" : "Mariano Spadaccini"
+ "name" : "Mariano Spadaccini",
+ "drilldown" : "Mariano Spadaccini"
},
{
"name" : "Mark Anderson",
@@ -156,29 +183,21 @@
"y" : 2
},
{
+ "drilldown" : "Roger Bell_West",
"name" : "Roger Bell_West",
- "y" : 4,
- "drilldown" : "Roger Bell_West"
+ "y" : 4
},
{
- "name" : "Thomas Kohler",
"drilldown" : "Thomas Kohler",
+ "name" : "Thomas Kohler",
"y" : 4
+ },
+ {
+ "drilldown" : "Ulrich Rieke",
+ "name" : "Ulrich Rieke",
+ "y" : 3
}
- ],
- "name" : "The Weekly Challenge - 257",
- "colorByPoint" : 1
+ ]
}
- ],
- "title" : {
- "text" : "The Weekly Challenge - 257"
- },
- "legend" : {
- "enabled" : 0
- },
- "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/>"
- }
+ ]
}
diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json
index 47bb95c7d4..b3fa9312de 100644
--- a/stats/pwc-language-breakdown-summary.json
+++ b/stats/pwc-language-breakdown-summary.json
@@ -1,21 +1,13 @@
{
+ "subtitle" : {
+ "text" : "Last updated at 2024-02-20 15:51:01 GMT"
+ },
"chart" : {
"type" : "column"
},
"series" : [
{
- "dataLabels" : {
- "color" : "#FFFFFF",
- "enabled" : "true",
- "rotation" : -90,
- "y" : 10,
- "style" : {
- "fontSize" : "13px",
- "fontFamily" : "Verdana, sans-serif"
- },
- "align" : "right",
- "format" : "{point.y:.0f}"
- },
+ "name" : "Contributions",
"data" : [
[
"Blog",
@@ -23,41 +15,49 @@
],
[
"Perl",
- 13259
+ 13261
],
[
"Raku",
- 7652
+ 7653
]
],
- "name" : "Contributions"
+ "dataLabels" : {
+ "y" : 10,
+ "align" : "right",
+ "color" : "#FFFFFF",
+ "style" : {
+ "fontFamily" : "Verdana, sans-serif",
+ "fontSize" : "13px"
+ },
+ "format" : "{point.y:.0f}",
+ "rotation" : -90,
+ "enabled" : "true"
+ }
}
],
- "title" : {
- "text" : "The Weekly Challenge Contributions [2019 - 2024]"
- },
- "legend" : {
- "enabled" : "false"
- },
- "tooltip" : {
- "pointFormat" : "<b>{point.y:.0f}</b>"
- },
"yAxis" : {
+ "min" : 0,
"title" : {
"text" :