diff options
| author | Lubos Kolouch <lubos@kolouch.net> | 2022-03-05 13:34:12 +0100 |
|---|---|---|
| committer | Lubos Kolouch <lubos@kolouch.net> | 2022-03-05 13:34:12 +0100 |
| commit | aadb92f0f24e2401a37be7bc8baad57b7873b8b1 (patch) | |
| tree | 74b1d2c48350e4658ab01377b512811aee74dfcc /challenge-154 | |
| parent | 7770ebc3fa44412a814a2aaa5a8a81d57b52663f (diff) | |
| download | perlweeklychallenge-club-aadb92f0f24e2401a37be7bc8baad57b7873b8b1.tar.gz perlweeklychallenge-club-aadb92f0f24e2401a37be7bc8baad57b7873b8b1.tar.bz2 perlweeklychallenge-club-aadb92f0f24e2401a37be7bc8baad57b7873b8b1.zip | |
feat(challenge-154/lubos-kolouch/perl/ch-1.pl): Challenge 154 Task 1 LK Perl
Diffstat (limited to 'challenge-154')
| -rw-r--r-- | challenge-154/lubos-kolouch/perl/ch-1.pl | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/challenge-154/lubos-kolouch/perl/ch-1.pl b/challenge-154/lubos-kolouch/perl/ch-1.pl new file mode 100644 index 0000000000..9f23682a36 --- /dev/null +++ b/challenge-154/lubos-kolouch/perl/ch-1.pl @@ -0,0 +1,35 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use Algorithm::Permute; + +sub find_missing { + my $what = shift; + + my $all_perms = Algorithm::Permute->new( [ split //, 'PERL' ] ); + + my @output; + + while ( my @perm = $all_perms->next ) { + my $look_str = join '', @perm; + push @output, $look_str unless grep { /$look_str/ } @$what; + } + + return \@output; +} + +use Test::More; + +is_deeply( + find_missing( + [ + "PELR", "PREL", "PERL", "PRLE", "PLER", "PLRE", "EPRL", "EPLR", "ERPL", "ERLP", "ELPR", "ELRP", + "RPEL", "RPLE", "REPL", "RELP", "RLPE", "RLEP", "LPER", "LPRE", "LEPR", "LRPE", "LREP" + ] + ), + ['LERP'] +); + +done_testing; |
