diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2019-04-21 17:09:07 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2019-04-21 17:09:07 +0100 |
| commit | ee04a2badc792f0da4f3d816cc01ad793cd60e62 (patch) | |
| tree | e162314bc7e714a3691c83b274b7486b89330e1b /challenge-004 | |
| parent | 2f716cce5f407eada620e679838f54ab8fe618a5 (diff) | |
| download | perlweeklychallenge-club-ee04a2badc792f0da4f3d816cc01ad793cd60e62.tar.gz perlweeklychallenge-club-ee04a2badc792f0da4f3d816cc01ad793cd60e62.tar.bz2 perlweeklychallenge-club-ee04a2badc792f0da4f3d816cc01ad793cd60e62.zip | |
- Added solutions by Yary H.
Diffstat (limited to 'challenge-004')
| -rwxr-xr-x | challenge-004/yary-h/perl5/ch-2.pl | 16 | ||||
| -rw-r--r-- | challenge-004/yary-h/perl5/words.txt | 5 | ||||
| -rwxr-xr-x | challenge-004/yary-h/perl6/ch-2.p6 | 14 | ||||
| -rwxr-xr-x | challenge-004/yary-h/perl6/ch-2a.p6 | 16 | ||||
| -rw-r--r-- | challenge-004/yary-h/perl6/words.txt | 5 |
5 files changed, 56 insertions, 0 deletions
diff --git a/challenge-004/yary-h/perl5/ch-2.pl b/challenge-004/yary-h/perl5/ch-2.pl new file mode 100755 index 0000000000..3f8885f218 --- /dev/null +++ b/challenge-004/yary-h/perl5/ch-2.pl @@ -0,0 +1,16 @@ +#!/usr/bin/env perl -n + +# run as "wordy.pl words.txt" + +use strict; +use warnings; +use feature 'state','say'; + +state $letters = [split '', 'nnaaabpepl']; # letter bag, in any order + +chomp; +my $orig = $_; +for my $letter (@$letters) { + next unless s/$letter//; + say $orig unless $_; +} diff --git a/challenge-004/yary-h/perl5/words.txt b/challenge-004/yary-h/perl5/words.txt new file mode 100644 index 0000000000..cf66a00143 --- /dev/null +++ b/challenge-004/yary-h/perl5/words.txt @@ -0,0 +1,5 @@ +apple +pineapple +banana +nab +applebanana diff --git a/challenge-004/yary-h/perl6/ch-2.p6 b/challenge-004/yary-h/perl6/ch-2.p6 new file mode 100755 index 0000000000..7b34e15fca --- /dev/null +++ b/challenge-004/yary-h/perl6/ch-2.p6 @@ -0,0 +1,14 @@ +#!/usr/bin/env perl6 + +# run as "ch-2.p6 words.txt" + +my %letters = bag <n n a a a b p e p l>; + +WORD: +for $*ARGFILES.words -> $word { + my %counter = %letters; + next WORD unless %counter{$_}-- for $word.comb; + say $word; +} + + diff --git a/challenge-004/yary-h/perl6/ch-2a.p6 b/challenge-004/yary-h/perl6/ch-2a.p6 new file mode 100755 index 0000000000..2e3b74f541 --- /dev/null +++ b/challenge-004/yary-h/perl6/ch-2a.p6 @@ -0,0 +1,16 @@ +#!/usr/bin/env perl6 -n + +# run as "ch-2a.p6 words.txt" + +my %letters = bag <n n a a a b p e p l>; + +my %counter = %letters; +goto NextWord unless %counter{$_}-- for .comb; +.say; + +NextWord: +# goto not yet implemented +# I'd like to "next" up to the -n next line. + + + diff --git a/challenge-004/yary-h/perl6/words.txt b/challenge-004/yary-h/perl6/words.txt new file mode 100644 index 0000000000..cf66a00143 --- /dev/null +++ b/challenge-004/yary-h/perl6/words.txt @@ -0,0 +1,5 @@ +apple +pineapple +banana +nab +applebanana |
