diff options
| -rwxr-xr-x | challenge-242/feng-chang/raku/ch-1.raku | 8 | ||||
| -rwxr-xr-x | challenge-242/feng-chang/raku/ch-2.raku | 11 | ||||
| -rw-r--r-- | challenge-242/feng-chang/raku/data-1-1.txt | 2 | ||||
| -rw-r--r-- | challenge-242/feng-chang/raku/data-1-2.txt | 2 | ||||
| -rw-r--r-- | challenge-242/feng-chang/raku/data-2-1.txt | 3 | ||||
| -rw-r--r-- | challenge-242/feng-chang/raku/data-2-2.txt | 4 | ||||
| -rwxr-xr-x | challenge-242/feng-chang/raku/test.raku | 33 |
7 files changed, 63 insertions, 0 deletions
diff --git a/challenge-242/feng-chang/raku/ch-1.raku b/challenge-242/feng-chang/raku/ch-1.raku new file mode 100755 index 0000000000..e3cffb6752 --- /dev/null +++ b/challenge-242/feng-chang/raku/ch-1.raku @@ -0,0 +1,8 @@ +#!/bin/env raku + +unit sub MAIN(); + +my @arr1 = +«(prompt 'Array One: ').words; +my @arr2 = +«(prompt 'Array Two: ').words; + +put (@arr1 (-) @arr2).keys.sort.Array.gist, ' ', (@arr2 (-) @arr1).keys.sort.Array.gist; diff --git a/challenge-242/feng-chang/raku/ch-2.raku b/challenge-242/feng-chang/raku/ch-2.raku new file mode 100755 index 0000000000..791c75f9e0 --- /dev/null +++ b/challenge-242/feng-chang/raku/ch-2.raku @@ -0,0 +1,11 @@ +#!/bin/env raku + +unit sub MAIN(); + +my (@M, $line-num); + +for $*IN.lines -> $line { + last unless $line; + @M[$line-num++] = (+«$line.words).map(1-*).reverse.Array; +} +put @M.gist; diff --git a/challenge-242/feng-chang/raku/data-1-1.txt b/challenge-242/feng-chang/raku/data-1-1.txt new file mode 100644 index 0000000000..7a192424a1 --- /dev/null +++ b/challenge-242/feng-chang/raku/data-1-1.txt @@ -0,0 +1,2 @@ +1 2 3 +2 4 6 diff --git a/challenge-242/feng-chang/raku/data-1-2.txt b/challenge-242/feng-chang/raku/data-1-2.txt new file mode 100644 index 0000000000..08e8253ace --- /dev/null +++ b/challenge-242/feng-chang/raku/data-1-2.txt @@ -0,0 +1,2 @@ +1 2 3 3 +1 1 2 2 diff --git a/challenge-242/feng-chang/raku/data-2-1.txt b/challenge-242/feng-chang/raku/data-2-1.txt new file mode 100644 index 0000000000..2bc6d2c8f5 --- /dev/null +++ b/challenge-242/feng-chang/raku/data-2-1.txt @@ -0,0 +1,3 @@ +1 1 0 +1 0 1 +0 0 0 diff --git a/challenge-242/feng-chang/raku/data-2-2.txt b/challenge-242/feng-chang/raku/data-2-2.txt new file mode 100644 index 0000000000..0b1909171d --- /dev/null +++ b/challenge-242/feng-chang/raku/data-2-2.txt @@ -0,0 +1,4 @@ +1 1 0 0 +1 0 0 1 +0 1 1 1 +1 0 1 0 diff --git a/challenge-242/feng-chang/raku/test.raku b/challenge-242/feng-chang/raku/test.raku new file mode 100755 index 0000000000..d3b52624cb --- /dev/null +++ b/challenge-242/feng-chang/raku/test.raku @@ -0,0 +1,33 @@ +#!/bin/env raku + +# The Weekly Challenge 242 +use Test; + +sub pwc-in-test(Str:D $script, Str:D $f where *.IO.e, $expect, $assertion, Bool :$deeply? = False) { + my $p = run $script, :in, :out; + $p.in.put($f.IO.slurp); + $p.in.close; + if $deeply { + is-deeply $p.out.slurp(:close).chomp.words.Bag, $expect, $assertion; + } else { + is $p.out.slurp(:close).chomp, $expect, $assertion; + } +} + +# Task 1, Missing Members +pwc-in-test './ch-1.raku', 'data-1-1.txt', + 'Array One: Array Two: [1 3] [4 6]', + 'Missing Members: @arr1 = (1, 2, 3), @arr2 = (2, 4, 6) => [1 3] [4 6]'; +pwc-in-test './ch-1.raku', 'data-1-2.txt', + 'Array One: Array Two: [3] []', + 'Missing Members: @arr1 = (1, 2, 3, 3), @arr2 = (1, 1, 2, 2) => [3] []'; + +# Task 2, Flip Matrix +pwc-in-test './ch-2.raku', 'data-2-1.txt', + '[[1 0 0] [0 1 0] [1 1 1]]', + 'Flip Matrix: [[1 1 0] [1 0 1] [0 0 0]] => [[1 0 0] [0 1 0] [1 1 1]]'; +pwc-in-test './ch-2.raku', 'data-2-2.txt', + '[[1 1 0 0] [0 1 1 0] [0 0 0 1] [1 0 1 0]]', + 'Flip Matrix: [[1 1 0 0] [1 0 0 1] [0 1 1 1] [1 0 1 0]] => [[1 1 0 0] [0 1 1 0] [0 0 0 1] [1 0 1 0]]'; + +done-testing; |
