aboutsummaryrefslogtreecommitdiff
path: root/challenge-099
diff options
context:
space:
mode:
authorNiels van Dijke <perlboy@cpan.org>2021-02-14 17:05:12 +0000
committerNiels van Dijke <perlboy@cpan.org>2021-02-14 17:05:12 +0000
commita7f4067873ad8219ed54aef76b9927a159fc66cc (patch)
tree2bc39115d56abc42c203e575059292df72fabdc4 /challenge-099
parent32a8602525fd96a8260a3c907410cfdae3d5b7af (diff)
downloadperlweeklychallenge-club-a7f4067873ad8219ed54aef76b9927a159fc66cc.tar.gz
perlweeklychallenge-club-a7f4067873ad8219ed54aef76b9927a159fc66cc.tar.bz2
perlweeklychallenge-club-a7f4067873ad8219ed54aef76b9927a159fc66cc.zip
Deleted because of incomplete task 2
Diffstat (limited to 'challenge-099')
-rwxr-xr-xchallenge-099/perlboy1967/perl/ch-1.pl26
-rwxr-xr-xchallenge-099/perlboy1967/perl/ch-2.pl69
2 files changed, 0 insertions, 95 deletions
diff --git a/challenge-099/perlboy1967/perl/ch-1.pl b/challenge-099/perlboy1967/perl/ch-1.pl
deleted file mode 100755
index bfda6727bf..0000000000
--- a/challenge-099/perlboy1967/perl/ch-1.pl
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/perl
-
-# Perl Weekly Challenge - 099
-# - https://perlweeklychallenge.org/blog/perl-weekly-challenge-099/
-#
-# Task 1 - Pattern Match
-#
-# Author: Niels 'PerlBoy' van Dijke
-
-use v5.16;
-use strict;
-use warnings;
-
-# Unbuffered STDOUT
-$|++;
-
-@ARGV = ('abcde', 'a*c?e')
- unless (scalar(@ARGV) == 2);
-
-my ($S, $P) = @ARGV;
-
-my $RE = $P;
-$RE =~ s#([\*\?])#.$1#g;
-
-printf "Input: \$S = '%s', \$P = '%s'\n", $S, $P;
-printf "Output: %d\n", ($S =~ m#^($RE)$# ? 1 : 0);
diff --git a/challenge-099/perlboy1967/perl/ch-2.pl b/challenge-099/perlboy1967/perl/ch-2.pl
deleted file mode 100755
index 6d0b4716eb..0000000000
--- a/challenge-099/perlboy1967/perl/ch-2.pl
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/usr/bin/perl
-
-# Perl Weekly Challenge - 099
-# - https://perlweeklychallenge.org/blog/perl-weekly-challenge-099/
-#
-# Task 2 - Unique Subsequence
-#
-# Author: Niels 'PerlBoy' van Dijke
-
-use v5.16;
-use strict;
-use warnings;
-
-use Algorithm::Combinatorics qw(variations_with_repetition);
-use List::Util qw(sum);
-use Data::Printer;
-
-# Unbuffered STDOUT
-$|++;
-
-@ARGV = ('this is a challenge', 'hisen')
- unless (scalar(@ARGV) == 2);
-
-my ($S, $T) = @ARGV;
-
-my $l = length($T);
-my @L = (1 .. $l);
-
-my @U;
-
-# I admit... difficult way to find substrings of '$T'
-# I think it pays off when '$T' becomes longer
-foreach my $cCount (1 .. $l) {
- my $v = variations_with_repetition(\@L,$cCount);
-
- while (my $a = $v->next) {
- next unless sum(@$a) == $l;
-
- my $re1 = sprintf('^(%s)$', join(')(', map { ".{$_}" } @$a));
- $T =~ m#$re1#;
-
- my @substrings = map {substr($T, $-[$_], $+[$_]-$-[$_]) } (1 .. scalar(@+) - 1);
-
- my $i = 0;
- my $re2 = sprintf("%s(?<s%d>.*?)",
- join('', map { sprintf("(?<s%d>.*?)(?<t%d>$_)", $i++, $i++) } @substrings),
- $i);
-
- # Find all matching combinations
- while ($S =~ m#$re2#g) {
- my %m = %+;
- my ($pre,$post) = ($`, $');
-
- # Build the 'evidence' string
- my @s;
- foreach my $k (keys %+) {
- if ($k =~ m#^(.)(\d+)#) {
- $s[$2] = ($1 eq 's' ? $m{$k} : sprintf("[%s]",$m{$k}));
- }
- }
-
- push(@U, join('', $pre // '', @s, $post // ''));
- }
- }
-
-}
-printf "Input: \$S = '%s', \$T = '%s'\n", $S, $T;
-printf "Output: %d\n", scalar(@U);
-p @U;