Created
September 7, 2016 08:37
-
-
Save lizmat/b3fe91c5be759e5cdaaf7afdf2821cb4 to your computer and use it in GitHub Desktop.
Magic number solution: runs at 25 wallclock as opposed to 35
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my @numbers = 3 .. 11 ; | |
for @numbers.permutations { check_magic_box $_ } | |
sub check_magic_box(@a) { | |
say "@a[0], @a[1], @a[2]\n@a[3], @a[4], @a[5]\n@a[6], @a[7], @a[8]\n" | |
if 21 | |
== @a[0] + @a[1] + @a[2] | |
== @a[3] + @a[4] + @a[5] | |
== @a[6] + @a[7] + @a[8] | |
== @a[0] + @a[3] + @a[6] | |
== @a[1] + @a[4] + @a[7] | |
== @a[2] + @a[5] + @a[8] | |
== @a[0] + @a[4] + @a[8] | |
== @a[6] + @a[4] + @a[2] | |
} |
timo
commented
Sep 7, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment