Skip to content

Instantly share code, notes, and snippets.

@masak
Created February 10, 2015 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masak/0779367baae65e9ac26b to your computer and use it in GitHub Desktop.
Save masak/0779367baae65e9ac26b to your computer and use it in GitHub Desktop.
Script to classify symmetries in 4x4 mazes
# 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(' ')";
}
@vponomarenko
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment