Skip to content

Instantly share code, notes, and snippets.

@bluebear94
Created February 3, 2016 19:57
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 bluebear94/ac81a41691024a068779 to your computer and use it in GitHub Desktop.
Save bluebear94/ac81a41691024a068779 to your computer and use it in GitHub Desktop.
use v6;
my @adjacentVertices =
0, 1,
0, 2,
1, 3,
2, 3,
4, 5,
4, 6,
5, 7,
6, 7,
0, 4,
1, 5,
2, 6,
3, 7;
sub checkCube(@vertices) {
for @adjacentVertices -> $v1, $v2 {
my $diff = (@vertices[$v1] - @vertices[$v2]) % 8;
return False if $diff == 1 || $diff == 7;
}
return True;
}
my $c = 0;
for permutations(8) -> @vertices {
if checkCube(@vertices) {
++$c;
say " {@vertices[2]}---{@vertices[3]}";
say " /| /|";
say "{@vertices[0]}-+-{@vertices[1]}";
say "| | | |";
say "| {@vertices[6]}-+-{@vertices[7]}";
say "|/ |/";
say "{@vertices[4]}---{@vertices[5]}";
say "";
say "";
}
}
say "Total: $c (p = {$c / 40320})";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment