-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjects.py
51 lines (39 loc) · 1.33 KB
/
objects.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
39
40
41
42
43
44
45
46
47
48
49
50
51
class GeneralInfo:
def __init__(self, R:int, C:int, F:int, N:int, B:int, T:int):
self.row = R
self.column = C
self.float = F
self.rides = N
self.bonus = B
self.steps = T
class Ride:
def __init__(self, i:int, a:int, b:int, x:int, y:int, s:int, f:int):
self.i = i
self.startrow = a
self.startcolumn = b
self.finishrow = x
self.finishcolumn = y
self.earlystart = s
self.latestfinish = f
def calculate_distance(self):
return abs(self.startrow - self.startcolumn) + abs(self.finishrow - self.finishcolumn)
def weight(self):
first = self.earlystart
second = self.calculate_distance()
third = self.calculate_distance() / (self.latestfinish - self.earlystart)
return (first/third - (first/third) * second)
def startpos(self):
return (self.startrow, self.startcolumn)
def finishpos(self):
return (self.finishrow, self.finishcolumn)
class Vehicle:
def __init__(self, i:int, pos_x:int, pos_y:int):
self.i = i
self.pos_x = pos_x
self.pos_y = pos_y
self.fulluntil = 0
self.rides = []
def pos(self):
return (self.pos_x,self.pos_y)
def to_export(self):
return str(len(self.rides)) + " " + " ".join(self.rides)