-
-
Save masak/0779367baae65e9ac26b to your computer and use it in GitHub Desktop.
Script to classify symmetries in 4x4 mazes
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
# 00 01 02 | |
# 12 13 14 15 | |
# 03 04 05 | |
# 16 17 18 19 | |
# 06 07 08 | |
# 20 21 22 23 | |
# 09 10 11 | |
my %symmetries = | |
rot1 => +«<15 19 23 14 18 22 13 17 21 12 16 20 2 5 8 11 1 4 7 10 0 3 6 9>, | |
rot2 => +«<11 10 9 8 7 6 5 4 3 2 1 0 23 22 21 20 19 18 17 16 15 14 13 12>, | |
horz => +«<2 1 0 5 4 3 8 7 6 11 10 9 15 14 13 12 19 18 17 16 23 22 21 20>, | |
vert => +«<9 10 11 6 7 8 3 4 5 0 1 2 20 21 22 23 16 17 18 19 12 13 14 15>, | |
; | |
for lines() -> $line { | |
my @w = $line.comb; | |
my @symm; | |
for %symmetries.keys -> $s { | |
if @w[%symmetries{$s}.list].join eq $line { | |
@symm.push: $s; | |
} | |
} | |
say "$line\t@symm.join(' ')"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You might be interested in http://oeis.org/A007341
They give Maple code that computes 1x1, 2x2, up to 20x20, all in under a second. Doesn't track symmetries, though.
I would have preferred to comment on your blog post, or send an email, but I can't figure out how to do either of those.
-Vadim Ponomarenko