diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-12-28 21:30:48 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-12-28 21:30:48 +0000 |
| commit | 80dd2ab239aecd016700c06fffaf45a8d1250ec4 (patch) | |
| tree | 08aedd50838479a5dbca458c547b4967d8f493ce /challenge-249/james-smith | |
| parent | d803efd4f920857866ac7ea4866f849a259f7ed9 (diff) | |
| download | perlweeklychallenge-club-80dd2ab239aecd016700c06fffaf45a8d1250ec4.tar.gz perlweeklychallenge-club-80dd2ab239aecd016700c06fffaf45a8d1250ec4.tar.bz2 perlweeklychallenge-club-80dd2ab239aecd016700c06fffaf45a8d1250ec4.zip | |
- Added solutions by James Smith.
Diffstat (limited to 'challenge-249/james-smith')
| -rw-r--r-- | challenge-249/james-smith/blog.txt | 1 | ||||
| -rw-r--r-- | challenge-249/james-smith/perl/ch-1.pl | 9 | ||||
| -rw-r--r-- | challenge-249/james-smith/perl/ch-2.pl | 4 |
3 files changed, 14 insertions, 0 deletions
diff --git a/challenge-249/james-smith/blog.txt b/challenge-249/james-smith/blog.txt new file mode 100644 index 0000000000..2958d8ff12 --- /dev/null +++ b/challenge-249/james-smith/blog.txt @@ -0,0 +1 @@ +https://challenges.jamessmith.me.uk/weekly/weekly-challenge-249/ diff --git a/challenge-249/james-smith/perl/ch-1.pl b/challenge-249/james-smith/perl/ch-1.pl new file mode 100644 index 0000000000..32e251479c --- /dev/null +++ b/challenge-249/james-smith/perl/ch-1.pl @@ -0,0 +1,9 @@ +sub equal_pairs { + my(%C,$t); + $C{$_}++ for @_; ## Collect counts + (grep { $_%2 } values %C) ## Are all counts event...! + ? () ## No return nothing... + : [map { $t=$_; ## Make "n/2" copies of [X,X] + map { [$t,$t] } 1..$C{$t}/2 + } keys %C ] +} diff --git a/challenge-249/james-smith/perl/ch-2.pl b/challenge-249/james-smith/perl/ch-2.pl new file mode 100644 index 0000000000..57f8e70f3a --- /dev/null +++ b/challenge-249/james-smith/perl/ch-2.pl @@ -0,0 +1,4 @@ +sub DI_string_match { + my( $n, $x ) = ( 0, length $_[0] ); + map( { 'I' eq $_ ? $n++ : $x-- } split //, $_[0] ), $n +} |
