Last active
April 30, 2020 17:45
-
-
Save codekansas/70fd13a052c96404b0e4884720d1dcc2 to your computer and use it in GitHub Desktop.
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
/* | |
A combination for a lock has 3 wheels, X, Y, and Z, each of which | |
can be set to eight different positions. The lock is broken and when | |
any two wheels of the lock are in the correct position, the lock | |
will open. Thus, anyone can open the lock after 64 tries (let A and | |
B run through all possible permutations). However, the safe can be | |
opened in fewer tries! What is the minimum number of tries that can | |
be guaranteed to open the lock? | |
*/ | |
module dot(x, y, z) { | |
color([1, 1, 1, 0.4]) | |
translate([x, y, z]) | |
cube([1, 1, 1]); | |
echo(x, y, z); | |
} | |
module sol(N, X, Y, Z) { | |
color([0, 0, 1]) | |
translate([X, Y, 1]) | |
cube([1, 1, N]); | |
color([0, 1, 0]) | |
translate([X, 1, Z]) | |
cube([1, N, 1]); | |
color([1, 0, 0]) | |
translate([1, Y, Z]) | |
cube([N, 1, 1]); | |
M = floor(N / 2); | |
for (i = [1 : M]) | |
for (j = [1 : M]) | |
dot(i, j, (j + i - 1) % M + 1); | |
for (i = [1 : M]) | |
for (j = [1 : M]) | |
dot(M + i, M + j, M + (j + i - 1) % M + 1); | |
} | |
sol(16, 3, 5, 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Combinations for N = 8