blob: 0f3492dec638a5497feebbc973301d1e32ef29b2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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;
}
|