aboutsummaryrefslogtreecommitdiff
path: root/challenge-203
diff options
context:
space:
mode:
author冯昶 <fengchang@novel-supertv.com>2023-02-13 17:22:18 +0800
committer冯昶 <fengchang@novel-supertv.com>2023-02-13 17:22:18 +0800
commit245a9bb01d688eac1ecefefb51300ffd9642df1a (patch)
tree4c51c5419246b6ca893267e879e942953cea057a /challenge-203
parent1d7da338f23a3842739e903bfd4e06a04f341c11 (diff)
parentbb462577d3227fa25ed53ee261528d6543a8aad0 (diff)
downloadperlweeklychallenge-club-245a9bb01d688eac1ecefefb51300ffd9642df1a.tar.gz
perlweeklychallenge-club-245a9bb01d688eac1ecefefb51300ffd9642df1a.tar.bz2
perlweeklychallenge-club-245a9bb01d688eac1ecefefb51300ffd9642df1a.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-203')
-rwxr-xr-xchallenge-203/colin-crain/perl/ch-1.pl141
-rwxr-xr-xchallenge-203/colin-crain/perl/ch-2.pl114
-rwxr-xr-xchallenge-203/eric-cheung/python/ch-1.py27
-rwxr-xr-xchallenge-203/eric-cheung/python/ch-2.py19
-rw-r--r--challenge-203/laurent-rosenfeld/blog.txt1
-rw-r--r--challenge-203/laurent-rosenfeld/perl/ch-1.pl24
-rw-r--r--challenge-203/laurent-rosenfeld/perl/ch-2.pl28
-rw-r--r--challenge-203/laurent-rosenfeld/raku/ch-1.raku19
-rw-r--r--challenge-203/laurent-rosenfeld/raku/ch-2.raku28
-rw-r--r--challenge-203/robert-dicicco/julia/ch-2.jl141
-rw-r--r--challenge-203/robert-dicicco/perl/ch-2.pl137
-rw-r--r--challenge-203/robert-dicicco/raku/ch-2.raku131
-rw-r--r--challenge-203/robert-dicicco/ruby/ch-2.rb129
-rw-r--r--challenge-203/ulrich-rieke/haskell/ch-1.hs29
-rw-r--r--challenge-203/ulrich-rieke/perl/ch-1.pl23
-rw-r--r--challenge-203/ulrich-rieke/raku/ch-1.raku18
-rw-r--r--challenge-203/ulrich-rieke/rust/ch-1.rs23
17 files changed, 1032 insertions, 0 deletions
diff --git a/challenge-203/colin-crain/perl/ch-1.pl b/challenge-203/colin-crain/perl/ch-1.pl
new file mode 100755
index 0000000000..f0591e2e34
--- /dev/null
+++ b/challenge-203/colin-crain/perl/ch-1.pl
@@ -0,0 +1,141 @@
+#!/Users/colincrain/perl5/perlbrew/perls/perl-5.32.0/bin/perl
+#
+# quads.pl
+#
+# Special Quadruplets
+# Submitted by: Mohammad S Anwar
+# You are given an array of integers.
+#
+# Write a script to find out the total special quadruplets for the
+# given array.
+#
+# Special Quadruplets are such that satisfies the following 2
+# rules.
+# 1) nums[a] + nums[b] + nums[c] == nums[d]
+# 2) a < b < c < d
+#
+# Example 1
+# Input: @nums = (1,2,3,6)
+# Output: 1
+#
+# Since the only special quadruplets found is
+# $nums[0] + $nums[1] + $nums[2] == $nums[3].
+#
+# Example 2
+# Input: @nums = (1,1,1,3,5)
+# Output: 4
+#
+# $nums[0] + $nums[1] + $nums[2] == $nums[3]
+# $nums[0] + $nums[1] + $nums[3] == $nums[4]
+# $nums[0] + $nums[2] + $nums[3] == $nums[4]
+# $nums[1] + $nums[2] + $nums[3] == $nums[4]
+#
+# Example 3
+# Input: @nums = (3,3,6,4,5)
+# Output: 0
+#
+# analysis
+#
+# Because the arrays are defined only to be integers, and not
+# ordered, a combination of index values that satisfy the
+# conditions may be present at any position. The only restriction
+# is applies is that the selected indexes must be ascending, so
+# that the first position cannot be greater than the index for the
+# end of the array minus 3: there must be space to complete the
+# selection.
+
+# Futhermore as we are beholden to chosing indexes in an ascending
+# sequence we are constrained from sdorting — mostly. Actually as
+# long as the three summands preced the final sum we can reassrange
+# them in any required order. So we could perhaps make a list of
+# sorted arrays, starting with the leftmost three items sorted, ten
+# four items, then five. As long as a single possible sum remains
+# it theory we could find a sucessful solution. Although any value
+# in the unsorted portion of a list could match the sum for a given
+# subsequence pattern we have an inverse tradeoff at work: fewer
+# sorted items yield fewer This is curious design pattern that
+# reminds me of dynamic programming. Not sure if it could be useful
+# in this case but it's really intereting.
+#
+# A series of nested loops would do the job, checking all
+# combinations. Algorithmically this is effective yet problematic,
+# but there is little to be done.
+#
+# The actual number of combinations is tricky to compute but
+# ultimately rises factorially. Even though our permissible
+# starting positions are reduced by 3 from the length of the array,
+# we still get 1 less possibility for the next position and one
+# more less for the next, and one more less for the sum to follow.
+# Given a long enough array we will still see factorial growth. the
+# actual rate is supressed at the start but this initial adjustment
+# will become less influential as the size increases.
+#
+# However some strategies can be employed to try and short-circuit
+# out of the search if possible and maybe we should try some to
+# make this more interesting.
+#
+# We could, for instance, scan the array once and get the maximum
+# value. Then, when summing a combination if two positiona already
+# sum to greater than the maximum we can stop that selection and
+# move on immediately. But wait. Neagative numbers are allowed.
+# Looks like were just stuck in the grind.
+#
+# Let's just implement a naive solution and see if anything comes
+# to mind later.
+#
+
+#
+# © 2022 colin crain
+## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
+
+
+
+use warnings;
+use strict;
+use utf8;
+use feature ":5.26";
+use feature qw(signatures);
+no warnings 'experimental::signatures';
+
+
+
+
+my @arr = (1,1,1,3,5);
+
+say count_quads( @arr );
+
+
+
+sub count_quads( @arr ) {
+ my ($i, $j, $k, $l);
+ my $count = 0;
+
+ for $i (0..$#arr-3) {
+ for $j ($i+1..$#arr-2) {
+ for $k ($j+1..$#arr-1) {
+ for $l ($k+1..$#arr) {
+ $count++ if $arr[$i] + $arr[$j] + $arr[$k] == $arr[$l];
+ }
+ }
+ }
+ }
+
+ return $count;
+
+}
+
+
+
+
+
+
+
+
+
+use Test::More;
+
+is count_quads(1,2,3,6), 1, 'ex-1';
+is count_quads(1,1,1,3,5), 4, 'ex-2';
+is count_quads(3,3,6,4,5), 0, 'ex-3';
+
+done_testing();
diff --git a/challenge-203/colin-crain/perl/ch-2.pl b/challenge-203/colin-crain/perl/ch-2.pl
new file mode 100755
index 0000000000..6d023bc460
--- /dev/null
+++ b/challenge-203/colin-crain/perl/ch-2.pl
@@ -0,0 +1,114 @@
+#!/Users/colincrain/perl5/perlbrew/perls/perl-5.32.0/bin/perl
+#
+# copy.pl
+#
+# Copy Directory
+# Submitted by: Julien Fiegehenn
+# You are given path to two folders, $source and $target.
+#
+# Write a script that recursively copy the directory from $source
+# to $target except any files.
+#
+#
+# Example
+# Input: $source = '/a/b/c' and $target = '/x/y'
+#
+# Source directory structure:
+#
+# ├── a
+# │ └── b
+# │ └── c
+# │ ├── 1
+# │ │ └── 1.txt
+# │ ├── 2
+# │ │ └── 2.txt
+# │ ├── 3
+# │ │ └── 3.txt
+# │ ├── 4
+# │ └── 5
+# │ └── 5.txt
+#
+# Target directory structure:
+#
+# ├── x
+# │ └── y
+#
+# Expected Result:
+#
+# ├── x
+# │ └── y
+# | ├── 1
+# │ ├── 2
+# │ ├── 3
+# │ ├── 4
+# │ └── 5
+#
+# method
+#
+# Any complexities in either the source or target directory
+# trees is inconsequntial and misdirectiion. The real trick
+# here is the recursion, which is not demonstrated in the
+# example.
+#
+# As understand, if we were given the source '/a/b', then we
+# would start copying into 'x/y' from there, but entering any
+# directories found and creating whatever directories required,
+# and following those too, until the tree branch is exhausted.
+# The result, using the same notation, would be:
+#
+# ├── x
+# │ └── y
+# │ └── c
+# │ ├── 1
+# │ ├── 2
+# │ ├── 3
+# │ ├── 4
+# │ └── 5
+#
+# As you can see we have entered /c/ and found the five further directories
+# named with the numbers: /c/1/, /c/2/, /c/3/, etc.
+#
+# Because we have no idea how far we need to go, a recursive
+# routine is a natural fit. Because we will be altering the existing filesystem
+# environment, there is no need to return anything, only to
+# keep track of our two entry points: that of the structure we are
+# duplicating, and the place we are affixing the structure we
+# find.
+#
+
+# © 2022 colin crain
+## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
+
+
+
+use warnings;
+use strict;
+use utf8;
+use feature ":5.26";
+use feature qw(signatures);
+no warnings 'experimental::signatures';
+
+my $source = q(/a/b/c);
+my $target = q(/x/y);
+
+duplicate_dirs ( $source, $target ) ;
+
+
+sub duplicate_dirs ( $source, $target ) {
+## scan the $source directory and make and directories found there in the $target
+## directory
+ return if not -d $source;
+
+ opendir(my $dh, $source) || die "Cannot opendir $source: $!";
+ my @dirs = grep { -d "$source/$_" && ! /^\.$|^..$/ } readdir($dh);
+ closedir $dh;
+
+ for my $dir ( @dirs ) {
+ mkdir "$target/$dir";
+ duplicate_dirs( "$source/$dir", "$target/$dir" );
+ }
+}
+
+
+
+
diff --git a/challenge-203/eric-cheung/python/ch-1.py b/challenge-203/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..87d2020cff
--- /dev/null
+++ b/challenge-203/eric-cheung/python/ch-1.py
@@ -0,0 +1,27 @@
+
+from itertools import combinations
+
+## arrInputList = [1, 2, 3, 6] ## Example 1
+## arrInputList = [1, 1, 1, 3, 5] ## Example 2
+arrInputList = [3, 3, 6, 4, 5] ## Example 2
+
+
+def IsSpecialQuadruplets(arrInput):
+
+ n_a = arrInput[0]
+ n_b = arrInput[1]
+ n_c = arrInput[2]
+ n_d = arrInput[3]
+
+ return (arrInputList[n_a] + arrInputList[n_b] + arrInputList[n_c] == arrInputList[n_d])
+
+
+arrIndxList = list(range(0, len(arrInputList)))
+arrCombList = combinations(arrIndxList, 4)
+arrOutputList = []
+
+for loopComb in list(arrCombList):
+ if IsSpecialQuadruplets(loopComb):
+ arrOutputList.append(loopComb)
+
+print (len(arrOutputList))
diff --git a/challenge-203/eric-cheung/python/ch-2.py b/challenge-203/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..fedcb744a3
--- /dev/null
+++ b/challenge-203/eric-cheung/python/ch-2.py
@@ -0,0 +1,19 @@
+
+## Remarks
+## https://www.geeksforgeeks.org/python-copy-directory-structure-without-files/
+
+import shutil
+import os
+
+
+## Define the Function to Ignore the Files If Present in Any Folder
+def GetIgnoreFiles(strDir, strFiles):
+ return [strFileLoop for strFileLoop in strFiles if os.path.isfile(os.path.join(strDir, strFileLoop))]
+
+
+strSourceFolderPath = "/a/b/c"
+strTargetFolderPath = "/x/y"
+
+
+## Calli the shutil.copytree() method and Pass the strSourceFolderPath, strTargetFolderPath and Ignore Parameter
+shutil.copytree(strSourceFolderPath, strTargetFolderPath, ignore = GetIgnoreFiles)
diff --git a/challenge-203/laurent-rosenfeld/blog.txt b/challenge-203/laurent-rosenfeld/blog.txt
new file mode 100644
index 0000000000..677e275bd4
--- /dev/null
+++ b/challenge-203/laurent-rosenfeld/blog.txt
@@ -0,0 +1 @@
+https://blogs.perl.org/users/laurent_r/2023/02/perl-weekly-challenge-203-special-quadruplets-and-copy-directory.html
diff --git a/challenge-203/laurent-rosenfeld/perl/ch-1.pl b/challenge-203/laurent-rosenfeld/perl/ch-1.pl
new file mode 100644
index 0000000000..9770d58fd8
--- /dev/null
+++ b/challenge-203/laurent-rosenfeld/perl/ch-1.pl
@@ -0,0 +1,24 @@
+use strict;
+use warnings;
+use feature "say";
+
+sub find_quadruplets {
+ my $count = 0;
+ my $last = $#_;
+ for my $i (0..$last-3) {
+ for my $j ($i+1..$last-2) {
+ for my $k ($j+1..$last-1) {
+ my $target = $_[$i] + $_[$j] + $_[$k];
+ $count += grep { $_ == $target }
+ @_[$k+1..$last];
+
+ }
+ }
+ }
+ return $count;
+}
+
+for my $test ([<1 2 3 6>], [<1 1 1 3 5>], [<1 1 1 3 5 5>],
+ [<3 3 6 4 5>], [<3 3 6 12 21>], [<1 1 1 3 5 9>]) {
+ printf "%-15s -> %d\n", "@$test", find_quadruplets @$test;
+}
diff --git a/challenge-203/laurent-rosenfeld/perl/ch-2.pl b/challenge-203/laurent-rosenfeld/perl/ch-2.pl
new file mode 100644
index 0000000000..62cc023a63
--- /dev/null
+++ b/challenge-203/laurent-rosenfeld/perl/ch-2.pl
@@ -0,0 +1,28 @@
+use strict;
+use warnings;
+use feature "say";
+
+sub traverse_dir {
+ my ($code_f, $code_d, $path) = @_;
+ my @dir_entries = glob("$path/*");
+ for my $entry (@dir_entries) {
+ $code_f->($entry) if -f $entry;
+ $code_d->($entry) and
+ traverse_dir($code_f, $code_d, $entry)
+ if -d $entry;
+ }
+}
+
+sub create_size_code_ref {
+ my $total_size = 0;
+ return (sub {
+ my $file = shift;
+ my $size = -s $file;
+ $total_size += $size;
+ printf "%-15s -> %d\n", $file, $size,;
+ }, sub {return $total_size;});
+}
+my $dir = shift;
+my ($code_ref, $glob_size) = create_size_code_ref();
+traverse_dir ($code_ref, sub {1}, $dir);
+say "Total size = ", $glob_size->();
diff --git a/challenge-203/laurent-rosenfeld/raku/ch-1.raku b/challenge-203/laurent-rosenfeld/raku/ch-1.raku
new file mode 100644
index 0000000000..52df7b4dd5
--- /dev/null
+++ b/challenge-203/laurent-rosenfeld/raku/ch-1.raku
@@ -0,0 +1,19 @@
+sub find-quadruplets (@in) {
+ my $count = 0;
+ my $last = @in.end;
+ for 0..$last-3 -> $i {
+ for $i^..$last-2 -> $j {
+ for $j^..$last-1 -> $k {
+ my $target = [+] @in[$i, $j, $k];
+ for $k^..$last -> $m {
+ $count++ if @in[$m] == $target;
+ }
+ }
+ }
+ }
+ return $count;
+}
+for <1 2 3 6>, <1 1 1 3 5>, <1 1 1 3 5 5>, <3 3 6 4 5>,
+ <3 3 6 12 21> -> @test {
+ say "@test[]".fmt("%-15s -> "), find-quadruplets @test;
+}
diff --git a/challenge-203/laurent-rosenfeld/raku/ch-2.raku b/challenge-203/laurent-rosenfeld/raku/ch-2.raku
new file mode 100644
index 0000000000..d0be0b64df
--- /dev/null
+++ b/challenge-203/laurent-rosenfeld/raku/ch-2.raku
@@ -0,0 +1,28 @@
+sub traverse_dir (&code_f, &code_d, $path) {
+ # my @dir_entries = dir("$path");
+ for dir "$path" -> $entry {
+ next if $entry.l; # exclude symlinks
+ &code_f($entry) and next if $entry.f;
+ &code_d($entry) and
+ traverse_dir(&code_f, &code_d, $entry)
+ if $entry.d;
+ }
+}
+sub create_dir_code_ref ($target_path) {
+ return sub ($dir) {
+ my $dir_name = $dir.IO.basename;
+ my $new_dir = "$target_path/$dir_name";
+ if $new_dir.IO.e {
+ note "Path $new_dir already exists. Omitted";
+ return True;
+ }
+ mkdir $new_dir or die "Unable to create $new_dir $!";
+ say "Created $new_dir from $dir.";
+ }
+}
+my ($source, $target) = './a/b/c', './x/y';
+die "No such directory." unless $source.IO.d;
+mkdir ($target, 0o777) unless $target.IO.d;
+my &code_ref_d = create_dir_code_ref $target;
+my &code_ref_f = {True};
+traverse_dir &code_ref_f, &code_ref_d, $source;
diff --git a/challenge-203/robert-dicicco/julia/ch-2.jl b/challenge-203/robert-dicicco/julia/ch-2.jl
new file mode 100644
index 0000000000..db34323c1e
--- /dev/null
+++ b/challenge-203/robert-dicicco/julia/ch-2.jl
@@ -0,0 +1,141 @@
+#!/usr/bin/env julia
+
+#=
+
+_________________________________________
+
+AUTHOR: Robert DiCicco
+
+DATE : 2023-02-09
+
+Challenge 203 Copy Directory ( Julia )
+
+_________________________________________
+
+=#
+
+using Printf
+
+
+
+startdir = pwd()
+
+
+
+@printf("startdir = %s\n",startdir)
+
+dirs = "a/b/c"
+
+target = "x/y"
+
+println("Creating source directory structure")
+
+
+
+for numdir in 1:5
+
+ dpath = dirs * "/" * ('0' + numdir)
+
+ mkpath(dpath)
+
+ println("\tcreated a/b/c")
+
+end
+
+
+
+cd(dirs)
+
+
+
+println("Creating source files")
+
+files = ["1/1.txt","2/2.txt","3/3.txt","5/5.txt"]
+
+
+
+for f in files
+
+ @printf("\t%s/%s\n",dirs,f)
+
+ outfile = open(f,"w")
+
+ close(outfile)
+
+end
+
+
+
+println("Creating target directory structure")
+
+
+
+cd(startdir)
+
+
+
+fulldirpaths=filter(isdir,readdir(startdir * '/' * dirs,join=true))
+
+dirnames=basename.(fulldirpaths)
+
+
+
+for outdir in dirnames
+
+ dpath = target * '/' * outdir
+
+ mkpath(dpath)
+
+ @printf("\tcreating %s/%s\n",target,outdir)
+
+end
+
+
+
+#=
+
+_________________________________________
+
+SAMPLE OUTPUT
+
+julia .\CopyDirectory.jl
+
+startdir = G:\Projects\Perl\Challenges
+
+Creating source directory structure
+
+ created a/b/c
+
+ created a/b/c
+
+ created a/b/c
+
+ created a/b/c
+
+ created a/b/c
+
+Creating source files
+
+ a/b/c/1/1.txt
+
+ a/b/c/2/2.txt
+
+ a/b/c/3/3.txt
+
+ a/b/c/5/5.txt
+
+Creating target directory structure
+
+ creating x/y/1
+
+ creating x/y/2
+
+ creating x/y/3
+
+ creating x/y/4
+
+ creating x/y/5
+
+_________________________________________
+
+=#
diff --git a/challenge-203/robert-dicicco/perl/ch-2.pl b/challenge-203/robert-dicicco/perl/ch-2.pl
new file mode 100644
index 0000000000..6863811b09
--- /dev/null
+++ b/challenge-203/robert-dicicco/perl/ch-2.pl
@@ -0,0 +1,137 @@
+# /usr/bin/env perl
+
+# AUTHOR: Robert DiCicco
+
+# DATE: 2023-02-08
+
+# Challenge 203 Copy Directory ( Perl )
+
+use strict;
+
+use warnings;
+
+use Path::Class;
+
+use File::Basename;
+
+use Cwd qw(cwd);
+
+use File::Path qw(make_path);
+
+
+
+my $startdir = cwd; # record our start point
+
+print "startdir = $startdir\n";
+
+
+
+my $dirs = "a/b/c"; # source directory structure
+
+my $target = "x/y"; # target directory structure
+
+
+
+print "Creating source directory structure\n";
+
+
+
+# creating directories 1..5 undex a/b/c/
+
+make_path("$dirs/1","$dirs/2", "$dirs/3", "$dirs/4", "$dirs/5");
+
+print "\tcreated a/b/c\n";
+
+
+
+chdir $dirs; #"a/b/c/";
+
+
+
+# creating source files
+
+print "Creating source files\n";
+
+my @files = ("1/1.txt","2/2.txt","3/3.txt","5/5.txt");
+
+
+
+for (@files) {
+
+ open(F, ">>$_")||die("Cannot create file:".$!);
+
+ print "\tcreated $_\n";
+
+ close(F);
+
+}
+
+
+
+chdir $startdir;
+
+
+
+my $dd = dir("a","b","c");
+
+my @list = $dd->children; # get a list of all child dirs of a/b/c/
+
+
+
+ # and copy them to x/y/
+
+print "Creating target directory structure\n";
+
+for my $d (@list) {
+
+ my $bn = basename($d);
+
+ print "\tcreating $target/$bn\n";
+
+ mkdir("$target/$bn");
+
+}
+
+print "complete";
+
+
+
+
+
+=begin pod
+
+SAMPLE OUTPUT
+
+perl .\CopyDirectory.pl
+
+startdir = G:/Projects/Perl/Challenges
+
+Creating source directory structure
+
+ created a/b/c
+
+Creating source files
+
+ created 1/1.txt
+
+ created 2/2.txt
+
+ created 3/3.txt
+
+ created 5/5.txt
+
+Creating target directory structure
+
+ creating x/y/1
+
+ creating x/y/2
+
+ creating x/y/3
+
+ creating x/y/4
+
+ creating x/y/5
+
+complete
+
+=cut
diff --git a/challenge-203/robert-dicicco/raku/ch-2.raku b/challenge-203/robert-dicicco/raku/ch-2.raku
new file mode 100644
index 0000000000..1cab731f07
--- /dev/null
+++ b/challenge-203/robert-dicicco/raku/ch-2.raku
@@ -0,0 +1,131 @@
+#/usr/bin/env perl
+
+#`{
+
+AUTHOR: Robert DiCicco
+
+DATE : 2023-02-08
+
+Challenge 203 Copy Directory ( Raku )
+
+}
+
+
+
+use File::Find;
+
+#use IO::Spec::Unix;
+
+
+
+my $startdir = $*CWD;
+
+"startdir = $startdir".say;
+
+my $dirs = "a/b/c"; # source directory structure
+
+my $target = "x/y"; # target directory structure
+
+
+
+"Creating source directory structure".say;
+
+
+
+for (1..5) -> $numdir {
+
+ mkdir ("$dirs/$numdir");
+
+}
+
+
+
+"\tcreated a/b/c".say;
+
+
+
+chdir $dirs;
+
+
+
+"Creating source files".say;
+
+my @files = ("1/1.txt","2/2.txt","3/3.txt","5/5.txt");
+
+
+
+for (@files) {
+
+ my $fh = open "$_", :w;
+
+ "\tcreated $_".say;
+
+ close $fh;
+
+}
+
+
+
+chdir $startdir;
+
+
+
+"Creating target directory structure".say;
+
+
+
+my @list = find(dir => $dirs, type => 'dir');
+
+for (@list) -> $dl {
+
+ #my $test= $dl.basename;
+
+ #mkdir "$target/$test";
+
+ mkdir "$target/" ~ $dl.basename;
+
+ print "\tcreating $target/" ~ $dl.basename ~ "\n";
+
+}
+
+"complete".say;
+
+
+
+#`{
+
+SAMPLE OUTPUT
+
+raku .\CopyDirectory.rk
+
+startdir = G:\Projects\Perl\Challenges
+
+Creating source directory structure
+
+ created a/b/c
+
+Creating source files
+
+ created 1/1.txt
+
+ created 2/2.txt
+
+ created 3/3.txt
+
+ created 5/5.txt
+
+Creating target directory structure
+
+ creating x/y/1
+
+ creating x/y/2
+
+ creating x/y/3
+
+ creating x/y/4
+
+ creating x/y/5
+
+complete
+
+}
diff --git a/challenge-203/robert-dicicco/ruby/ch-2.rb b/challenge-203/robert-dicicco/ruby/ch-2.rb
new file mode 100644
index 0000000000..c67c83391a
--- /dev/null
+++ b/challenge-203/robert-dicicco/ruby/ch-2.rb
@@ -0,0 +1,129 @@
+#!/usr/bin/env ruby
+
+=begin
+
+_________________________________________
+
+AUTHOR: Robert DiCicco
+
+DATE : 2023-02-09
+
+Challenge 203 Copy Directory ( Ruby )
+
+_________________________________________
+
+=end
+
+
+
+require 'fileutils'
+
+require 'find'
+
+
+
+startdir = Dir.pwd
+
+puts("startdir = #{startdir}")
+
+dirs = "a/b/c"
+
+target = "x/y"
+
+puts("Creating source directory structure")
+
+
+
+for numdir in 1..5 do
+
+ FileUtils.mkdir_p "#{dirs}/#{numdir}"
+
+end
+
+
+
+puts("\tcreated a/b/c")
+
+Dir.chdir(dirs)
+
+
+
+puts("Creating source files")
+
+files = ["1/1.txt","2/2.txt","3/3.txt","5/5.txt"]
+
+
+
+files.each do |f|
+
+ puts("\t#{dirs}/#{f}")
+
+ out_file = File.new("#{f}", "w")
+
+ out_file.close
+
+end
+
+
+
+puts("Creating target directory structure")
+
+Dir.chdir("#{startdir}/#{dirs}")
+
+Find.find(".") do |path|
+
+ next unless File.directory?(path)
+
+ reg_x = /1|2|3|4|5|6|7|8|9/
+
+ outdir = "#{reg_x.match(File.basename(path))}"
+
+ FileUtils.mkdir_p "#{startdir}/#{target}/#{outdir}"
+
+ puts("\tcreating #{target}/#{outdir}")
+
+end
+
+
+
+=begin
+
+_________________________________________
+
+SAMPLE OUTPUT
+
+ruby .\CopyDirectory.rb
+
+startdir = G:/Projects/Perl/Challenges
+
+Creating source directory structure
+
+ created a/b/c
+
+Creating source files
+
+ a/b/c/1/1.txt
+
+ a/b/c/2/2.txt
+
+ a/b/c/3/3.txt
+
+ a/b/c/5/5.txt
+
+Creating target directory structure
+
+ creating x/y/
+
+ creating x/y/1
+
+ creating x/y/2
+
+ creating x/y/3
+
+ creating x/y/4
+
+ creating x/y/5
+
+_________________________________________
+
+=end
diff --git a/challenge-203/ulrich-rieke/haskell/ch-1.hs b/challenge-203/ulrich-rieke/haskell/ch-1.hs
new file mode 100644
index 0000000000..ffa413f9d1
--- /dev/null
+++ b/challenge-203/ulrich-rieke/haskell/ch-1.hs
@@ -0,0 +1,29 @@
+module Challenge203
+ where
+
+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] -> Bool
+myCondition list = (sum $ init list ) == last list
+
+solution :: [Int] -> Int
+solution = length . filter myCondition . combinations 4
+
+keepAskingForInput :: IO [Int]
+keepAskingForInput = do
+ putStrLn "Enter at least 4 integers, separated by blanks!"
+ numberstrings <- getLine
+ let strings = words numberstrings
+ if length strings >= 4
+ then do
+ return $ map read strings
+ else do
+ keepAskingForInput
+
+main :: IO ( )
+main = do
+ numbers <- keepAskingForInput
+ print $ solution numbers
diff --git a/challenge-203/ulrich-rieke/perl/ch-1.pl b/challenge-203/ulrich-rieke/perl/ch-1.pl
new file mode 100644
index 0000000000..527a4d9caf
--- /dev/null
+++ b/challenge-203/ulrich-rieke/perl/ch-1.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/perl ;
+use strict ;
+use warnings ;
+use feature 'say' ;
+use Algorithm::Combinatorics qw ( combinations ) ;
+
+say "Please enter at least 4 integers , separated by blanks!" ;
+my $line = <STDIN> ;
+chomp $line ;
+my @numbers = split( /\s/ , $line ) ;
+my $specials = 0 ;
+if ( scalar ( @numbers ) >= 4 ) {
+ my $iter = combinations( \@numbers , 4 ) ;
+ while ( my $p = $iter->next ) {
+ if ( $p->[0] + $p->[1] + $p->[2] == $p->[3] ) {
+ $specials++ ;
+ }
+ }
+ say $specials ;
+}
+else {
+ say "Enter at least 4 integers!" ;
+}
diff --git a/challenge-203/ulrich-rieke/raku/ch-1.raku b/challenge-203/ulrich-rieke/raku/ch-1.raku
new file mode 100644
index 0000000000..90ca3de4e5
--- /dev/null
+++ b/challenge-203/ulrich-rieke/raku/ch-1.raku
@