diff options
| -rw-r--r-- | challenge-124/simon-proctor/raku/ch-2.raku | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/challenge-124/simon-proctor/raku/ch-2.raku b/challenge-124/simon-proctor/raku/ch-2.raku new file mode 100644 index 0000000000..7f6e57d0b8 --- /dev/null +++ b/challenge-124/simon-proctor/raku/ch-2.raku @@ -0,0 +1,15 @@ +#!/usr/bin/env raku + +#| Given a list of up to 20 elements find the division of items that has the smallest difference +sub MAIN( *@N where @N.elems <= 20 ) { + my $len = @N.elems div 2; + + my @res = @N.combinations($len).map( -> @a { ( @a, (@N (-) @a).keys ) } ) + .sort(-> (@a,@b) {abs( ([+] @a) - ([+] @b)) } ) + .first; + + "{@res[0].join(',')} <=> {@res[1].join(',')}".say; + + +} + |
