diff options
| author | Jörg Sommrey <28217714+jo-37@users.noreply.github.com> | 2023-03-20 15:03:55 +0100 |
|---|---|---|
| committer | Jörg Sommrey <28217714+jo-37@users.noreply.github.com> | 2023-03-20 15:03:55 +0100 |
| commit | c0adff21554f50a2bca22668bf25a60c9ec93de0 (patch) | |
| tree | 1b3fddfd7ad4c0b267779de90dc9cf3991982062 | |
| parent | 9c5cd2108a8f6cf8b793c28051fdf8d767a4c8a9 (diff) | |
| download | perlweeklychallenge-club-c0adff21554f50a2bca22668bf25a60c9ec93de0.tar.gz perlweeklychallenge-club-c0adff21554f50a2bca22668bf25a60c9ec93de0.tar.bz2 perlweeklychallenge-club-c0adff21554f50a2bca22668bf25a60c9ec93de0.zip | |
Solution to task 1
| -rwxr-xr-x | challenge-209/jo-37/perl/ch-1.pl | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/challenge-209/jo-37/perl/ch-1.pl b/challenge-209/jo-37/perl/ch-1.pl new file mode 100755 index 0000000000..0f3492dec6 --- /dev/null +++ b/challenge-209/jo-37/perl/ch-1.pl @@ -0,0 +1,53 @@ +#!/usr/bin/perl -s + +use v5.16; +use Test2::V0; + +our ($tests, $examples); + +run_tests() if $tests || $examples; # does not return + +die <<EOS unless @ARGV == 1; +usage: $0 [-examples] [-tests] [BITS] + +-examples + run the examples from the challenge + +-tests + run some tests + +BITS + test if BITS form a "special bit sequence" + +EOS + + +### Input and Output + +say 0 + bit_sequence(shift); + + +### Implementation + +sub bit_sequence { + shift =~ /^(11|10|0)*0$/; +} + + +### Examples and tests + +sub run_tests { + SKIP: { + skip "examples" unless $examples; + + ok bit_sequence('100'), 'example 1'; + ok !bit_sequence('1110'), 'example 2'; + } + + SKIP: { + skip "tests" unless $tests; + } + + done_testing; + exit; +} |
