diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2023-11-07 14:34:08 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-07 14:34:08 +0000 |
| commit | c460b52cbd7dec13e6d46311a151e6b128382b7d (patch) | |
| tree | 59a478afcd61ba512916e8f1fb9152bf1f7d24a3 | |
| parent | cea70f951c4896c9d7f965dd8742848ddfdeaf0e (diff) | |
| parent | bb1e59574570c807c144b5466c580f3dd0461abd (diff) | |
| download | perlweeklychallenge-club-c460b52cbd7dec13e6d46311a151e6b128382b7d.tar.gz perlweeklychallenge-club-c460b52cbd7dec13e6d46311a151e6b128382b7d.tar.bz2 perlweeklychallenge-club-c460b52cbd7dec13e6d46311a151e6b128382b7d.zip | |
Merge pull request #9012 from Scimon/master
Challenge 242 part 1
| -rw-r--r-- | challenge-242/simon-proctor/raku/ch-1.raku | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-242/simon-proctor/raku/ch-1.raku b/challenge-242/simon-proctor/raku/ch-1.raku new file mode 100644 index 0000000000..83e98a2b51 --- /dev/null +++ b/challenge-242/simon-proctor/raku/ch-1.raku @@ -0,0 +1,25 @@ +#!/usr/bin/env raku + +multi sub MAIN('test') is hidden-from-USAGE { + use Test; + is-deeply missing-values((1,2,3), (2,4,6)), [[1,3],[4,6]], 'Got expected missing values'; + is-deeply missing-values((2,4,6), (1,2,3)), [[4,6],[1,3]], 'Got expected missing values'; + is-deeply missing-values((1,2,3,3),(1,1,2,2)), [[3],[]], 'Second test'; + is-deeply missing-values((1,1,2,2),(1,2,3,3)), [[],[3]], 'Second test'; + done-testing; +} + +subset CSV of Str where { $_ ~~ m/^ (\d+) * %% ',' $/ }; + +#| Given two comma seperated lists of integers print the lists of items missing from each list +multi sub MAIN( + CSV $a, #= First list of ints + CSV $b #= Second list of ints +) { + missing-values($a.split(','),$b.split(',')).map( '(' ~ *.join(',') ~ ')' ).join( " " ).say; +} + +sub missing-values( @a, @b ) { + return [ (@a (-) @b).keys.sort.Array, (@b (-) @a).keys.sort.Array]; +} + |
