From 8d9cfd8d2ac39bb5d0b0f7452bf57d200bbdd62f Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Sat, 4 Feb 2023 14:04:38 +0000 Subject: - Added solutions by james Smith. - Added solutions by Luca Ferrari. - Added solutions by Aut0exec. - Added solutions by W. Luis Mochan. - Added solutions by Bob Lied. - Added solutions by David Ferrone. - Added solutions by E. Choroba. - Added solutions by Mark Anderson. - Added solutions by Robbie Hatley. - Added solutions by Dave Jacoby. - Added solutions by Thomas Kohler. - Added solutions by Jaldhar H. Vyas. - Added solutions by Peter Campbell Smith. - Added solutions by Mariano Spadaccini. - Added solutions by Jorg Sommrey. - Added solutions by Pip Stuart. - Added solutions by Simon Green. - Added solutions by Laurent Rosenfeld. - Added solutions by Ulrich Rieke. - Added solutions by Robert DiCicco. --- challenge-202/ulrich-rieke/cpp/ch-1.cpp | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 challenge-202/ulrich-rieke/cpp/ch-1.cpp (limited to 'challenge-202/ulrich-rieke/cpp/ch-1.cpp') diff --git a/challenge-202/ulrich-rieke/cpp/ch-1.cpp b/challenge-202/ulrich-rieke/cpp/ch-1.cpp new file mode 100644 index 0000000000..be9c6968c1 --- /dev/null +++ b/challenge-202/ulrich-rieke/cpp/ch-1.cpp @@ -0,0 +1,37 @@ +#include +#include +#include +#include +#include + +int main( int argc , char* argv[] ) { + if ( argc < 4 ) { + std::cout << "Enter a least 3 integers, separated by a blank!\n" ; + return 1 ; + } + else { + std::vector numbers ; + for ( int i = 1 ; i < argc ; i++ ) { + numbers.push_back( std::atoi( argv[ i ] ) ) ; + } + int result = 0 ; + int len = numbers.size( ) ; + for ( int i = 0 ; i < len - 2 ; i++ ) { + if ( std::all_of( numbers.begin( ) + i , numbers.begin( ) + i + 3 , + [ ]( int n ) { return n % 2 == 1 ; } ) ) + result = 1 ; + } + std::cout << result << std::endl ; + return 0 ; + } +} +------------------------------------------------------------------------------------ + task 1, in Haskell +------------------------------------------------------------------------------------ + +module Challenge202 + where +import Data.List.Split ( divvy ) + +solution :: [Int] -> Int +solution list = if any (\li -> all odd li ) $ divvy 3 1 list then 1 else 0 -- cgit