forked from hkociemba/Rubiks2x2x2-OptimalSolver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmisc.py
26 lines (20 loc) · 820 Bytes
/
misc.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
# ######################################## Miscellaneous functions ####################################################
from os import path, mkdir
def rotate_right(arr, l, r):
""""Rotates array arr right between l and r. r is included."""
temp = arr[r]
for i in range(r, l, -1):
arr[i] = arr[i-1]
arr[l] = temp
def rotate_left(arr, l, r):
""""Rotates array arr left between l and r. r is included."""
temp = arr[l]
for i in range(l, r):
arr[i] = arr[i+1]
arr[r] = temp
def get_pruning_table_path(table_name):
"""Returns the path corresponding to the given pruning table"""
pruning_dir = path.join(path.dirname(path.realpath(__file__)), 'pruning')
if not path.exists(pruning_dir):
mkdir(pruning_dir)
return path.join(pruning_dir, table_name)