diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-05-19 18:22:50 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-05-19 18:22:50 +0100 |
| commit | 8f3c330dd70d0b1478cb79d063509a12d1d5581b (patch) | |
| tree | 08651782feea22b3b53212817b5505299e0b8cfc /challenge-061 | |
| parent | 4850c5a417f8fb887af897bd517efccc71b238ca (diff) | |
| download | perlweeklychallenge-club-8f3c330dd70d0b1478cb79d063509a12d1d5581b.tar.gz perlweeklychallenge-club-8f3c330dd70d0b1478cb79d063509a12d1d5581b.tar.bz2 perlweeklychallenge-club-8f3c330dd70d0b1478cb79d063509a12d1d5581b.zip | |
- Added solutions by Donald Hunter.
Diffstat (limited to 'challenge-061')
| -rw-r--r-- | challenge-061/donald-hunter/blog.txt | 1 | ||||
| -rw-r--r-- | challenge-061/donald-hunter/raku/ch-2.p6 | 19 |
2 files changed, 20 insertions, 0 deletions
diff --git a/challenge-061/donald-hunter/blog.txt b/challenge-061/donald-hunter/blog.txt new file mode 100644 index 0000000000..f2a395115e --- /dev/null +++ b/challenge-061/donald-hunter/blog.txt @@ -0,0 +1 @@ +https://donaldh.wtf/2020/05/ipv4-partition/ diff --git a/challenge-061/donald-hunter/raku/ch-2.p6 b/challenge-061/donald-hunter/raku/ch-2.p6 new file mode 100644 index 0000000000..20f8fe00fb --- /dev/null +++ b/challenge-061/donald-hunter/raku/ch-2.p6 @@ -0,0 +1,19 @@ +multi find-ips(Str $input where / \d ** 4..12 /) { + gather { + take .list.flat.join('.') + for $input ~~ m:exhaustive + / ^ ( <[1..9]> ** 0..2 \d <?{ $/.Int < 256 }> ) ** 4 $ / + } +} + +multi find-ips(Str $input) { + die "{$input} is not a valid input, it should be 4 to 12 digits."; +} + +sub MAIN(Str $input) { + CATCH { default { .say } } + + my @ips = find-ips($input); + say "Found {+@ips} potential IP address{+@ips == 1 ?? '' !! 'es'} in {$input}:"; + say @ips.join("\n").indent(4); +} |
