-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrods.py
More file actions
55 lines (41 loc) · 1.23 KB
/
rods.py
File metadata and controls
55 lines (41 loc) · 1.23 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from math import ceil
def aliens (m, o):
def recFront(x, n, r, g):
if flat(x, g) is True:
x = x + 1
res = flat(x+1, g)
if res is True:
if (x+1) < m:
return recFront(int(ceil((n+x+1)/2)), n, x, g)
else:
return (x + 1)
else:
res = flat(x-1, g)
if res is True:
return (x-1)
else:
return recFront(int(((r+(x-1))/2)), r, x, g)
frontX = recFront(int((m+o[0])/2), m, o[0], "x")
frontY = recFront(int((m+o[1])/2), m, o[1], "y")
print(frontX)
print(frontY)
def recBack(x, n, g):
if flat(x, g) is True:
x = x - 1
res = flat(x-1, g)
if res is True:
if (x+1) < m:
return recBack(int(ceil(x/2)), x, g)
else:
return (x+1)
else:
res = flat(x+1, g)
if res is True:
return (x+1)
else:
return recBack(int(ceil((n+x+1)/2)), x, g)
backX = recBack(int((m+o[0]+1)/2), o[0], "x")
backY = recBack(int((m+o[1]+1)/2), o[1], "y")
mX = (backX + frontX)/2
mY = (backY + frontY)/2
return [mX, mY]