aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-086/pkmnx/raku/ch-1.raku33
1 files changed, 33 insertions, 0 deletions
diff --git a/challenge-086/pkmnx/raku/ch-1.raku b/challenge-086/pkmnx/raku/ch-1.raku
new file mode 100755
index 0000000000..bbbc99e5dc
--- /dev/null
+++ b/challenge-086/pkmnx/raku/ch-1.raku
@@ -0,0 +1,33 @@
+#!/usr/bin/env rakudo
+
+sub MAIN( *@args where @args.all ~~ Int ) {
+
+ my $A = @args.pop();
+ my @N = @args;
+
+ my @res = (gather {
+ my %h;
+ for @N.permutations {
+ %h{ $_[0] }{ $_[1] }++;
+ }
+ for %h.keys -> $k {
+ for %h{$k}.keys -> $kk {
+ take [ $k, $kk ] if $k - $kk == $A;
+ }
+ }
+ });
+
+ ( "Input: @N = (" ~ @N ~ ') and $A = ' ~ $A ).say;
+
+ if ( @res.elems > 0 ) {
+ "Output: 1 as".say;
+ for (@res) -> ($f, $s) {
+ " $f - $s = $A".say;
+ }
+ exit(0);
+ } else {
+ "Output: 0".say;
+ exit(1);
+ }
+
+}