-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsolve.py
38 lines (29 loc) · 851 Bytes
/
solve.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/python3
import sys
import time
from mixupcube import MixupCube, CubieMismatchError
def solve(cube, solve_type=None):
print("Solving {}".format(cube))
start_time = time.time()
if solve_type is None:
solution = cube.solve()
elif solve_type == "to_cube":
solution = cube.solve_to_cube_shape()
else:
raise ValueError("Huh, this shouldn't ever happen")
end_time = time.time()
if solution:
print("Solution:", solution)
else:
print("Cube already solved")
print("Solve took {}s".format(end_time - start_time))
def main():
cube_str = ''.join(sys.argv[1:]).strip()
if cube_str.startswith('['):
cube = MixupCube.from_str(cube_str)
else:
cube = MixupCube()
cube.turn(cube_str)
solve(cube)
if __name__ == "__main__":
main()