-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
366 lines (326 loc) · 10.9 KB
/
main.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
'''
Created on March 20, 2013
@author: Boris Jurosevic
Trip through Germany
CS 2430
'''
from __future__ import print_function
from shortest_path import *
from data_manager import Data_Manager
from city import City
from connection import Connection
import math
def main():
informacije = Data_Manager()
savPut = []
puteljak = pocniOdArray(savPut)
allTogether = []
svaKupovina = 0
svoVrijeme = 0
svaDaljina = 0
array = {}
najkraci = najkraciPut(puteljak)
x = najkraci
sveIspisi(x)
allOfIt = svaKupovina, svoVrijeme, svaDaljina
kupilac = 21
svaKupovina, svoVrijeme, svaDaljina = uSuprotnomStanju(x, kupilac)
divideBySec = svoVrijeme / 60
print()
print(""" Few important things we have come up with:
- When it comes to efficient route on time and cost it is Petrol.
- Train time where we came up from raileurope website
- Car time where we came up from around 130 kmh
- We could not find all the routes with train so that gave petrol the advantage
- After coming up with results from the class it was clear that for a group of people having a petrol car was the most efficient price
- Petrol might not be faster but it will be the cheapest """)
print()
print("Now we will look at the costs ")
print(str.format("This is the Traveling Cost: ${0:.6}, This is the Time Traveled: {1:.4} hours, This is the Distance Traveled: {2:.6} km ({3:.6} miles)", svaKupovina, divideBySec, svaDaljina, svaDaljina * .621371))
sveDodatno(12.00, "Oma/Opa want to drive under the river - a taxi can do this as well)")
pomnoziZaMjesec = svaKupovina + 12
svaKupovina = pomnoziZaMjesec
sveDodatno(1169.80, "purchasing iPad's at 180 Euros ($233.96) each")
svaKup = svaKupovina + 1169.8
svaKupovina = svaKup
sveDodatno(24, "taxi will be needed to visit the castle 10km away from the hauptbahnhof")
desePuta = svaDaljina + 10
svaDaljina = desePuta
duplo = svaKupovina + 24
svaKupovina = duplo
print(str.format(" Time extra spent: {0} {1}", 24, "Oma wants to visit a Spa here, therefore, you will need to spend the day"))
pomnozi = svoVrijeme + 24 * 60
svoVrijeme = pomnozi
print()
print()
print(str.format("The final answer is: Bottom line cost: ${0:.6}, Bottom line time: {1:.4} hours, Bottom line distance: {2:.6} km ({3:.6} miles)", svaKupovina, svoVrijeme / 60, svaDaljina, svaDaljina * .621371))
def uSuprotnomStanju_2(into, dane):
dayandMonth = []
xtraExpense = 0
podjeli = dane / 7
s = math.ceil(float(podjeli))
all = 0
podjeli = 600 * s
sveKuljeno = podjeli
podjeliOne = 700 * s
sveodD = podjeliOne
podj = 2415 * s
sveodT = podj
sveodV = 0
sveodAu = 0
i = 0
arrayOne = []
arrayTwo = []
informacija = Data_Manager()
for sopjJE in into:
sp = sopjJE[0]
ab = sp
drp = sopjJE[1]
db = drp
brb = informacija.nadjiSpojeve(ab, db)
if brb == None:
one = sopjJE[2]
to = one
two = sopjJE[2]
on = two
three = sveUP(to)
mr = three
four = sveVrijeme(to)
vr = four
tr = sopjJE[0]
brg = sopjJE[1]
brb = Connection(tr, brg, 0, on, mr, 0, vr, to)
ted = all + brb.range
all = ted
tedOne = sveKuljeno + brb.CjenaP
sveKuljeno = tedOne
opa = sveodD + brb.CjenaDizela
sveodD = opa
if brb.CjenaVoza == 0:
abc = sveodT + brb.CjenaP + 115
sveodT = abc
zed = sveodV + brb.vrijemeAuta
sveodV = zed
sveodV = sveodV + brb.VrijemeVoza
sveodAu = sveodAu + brb.vrijemeAuta
natri = sveKuljeno + sveodAu
nacetri = sveodT + sveodAu
if(natri < nacetri):
if(sveKuljeno < sveodD):
vratinazadOpet = sveKuljeno, sveodAu, all
return vratinazadOpet
else:
vratise = sveodD, sveodAu, all
return vratise
Uno = sveodD + sveodAu
Due = sveodT + sveodAu
elif(Uno < Due):
allIt = sveodD, sveodAu, all
return allIt
else:
allOtherStuff = sveodT, sveodV, all
return allOtherStuff
def sveDodatno(x, y):
index = None
array = []
print(str.format(" Cost of extra is : ${0} {1}", float(x), y))
def najkraciPut(doKraja):
x = float('inf')
array = 0
for zed in range(len(doKraja)):
sveZajedno = 0
for connect in doKraja[zed]:
pomnozi = sveZajedno + connect[2]
sveZajedno = pomnozi
if sveZajedno < x:
x = sveZajedno
array = zed
return doKraja[array]
def sveIspisi(a):
finalSTep_1 = 0;
finalSTep_2 = 0;
finalSTep_3 = 0;
dobro = 0;
xr = Data_Manager()
print("Welcome to Trip to Germany!")
print("Trip consists of of these cities all together")
print("Rostock ")
print("Lubeck (home of the best marzipan) ")
print("Hamburg (Oma/Opa want to drive under the river - a taxi can do this as well)")
print("Bremen ")
print("Hannover (Consumer Electronics haven - purchase each a new iPad at 180 Euros each) ")
print("Kassel ")
print("Dusseldorf ")
print("Koln (taxi will be needed to visit the castle 10km away from the hauptbahnhof) ")
print("St. Augustine ")
print("Bonn ")
print("Wiesbaden ")
print("** Frankfurt ")
print("Mannheim ")
print("Karlsruhe ")
print("Baden Baden (Oma wants to visit a Spa here, therefore, you will need to spend the day) ")
print("** Stuttgart ")
print("** Munchen (Munich)")
print("Nurnberg")
print("Dresden ")
print("Leipzig ")
print("** Berlin")
print("Basel, Switzerland (Opa and Dad want to purchase a nice watch and this is the best place for such a purchase - you will be spending $6k/watch) ")
print()
print("Here is the way using Petrol, Diesel or Train for every city")
print("Cities of this trip:", xr.dajmigradpoGrad(a[0][0]))
for sastavi in a:
dobro = dobro + 1
b = sastavi[0]
f = sastavi[1]
city = xr.dajmigradpoGrad(b)
ovajSPoj = xr.nadjiSpojeve(b, f)
if ovajSPoj == None:
index = 0
a = sastavi[2]
b = sveGorivo(a)
c = sveUP(a)
d = sveVrijeme(a)
xrx = sastavi[0]
xrd = sastavi[1]
ovajSPoj = Connection(xrx, xrd, 0, b, c, 0, d, a)
putic, vrsta, cena, vrim = ovajSPoj.sveTezine()
way_1 = finalSTep_1 + putic
finalSTep_1 = way_1
way_2 = finalSTep_2 + cena
finalSTep_2 = way_2
way_3 = finalSTep_3 + vrim
finalSTep_3 = way_3
putit = sastavi[1]
print("Distance Number:", dobro, "", city, putit)
atm = float(putic)
tip = vrsta
fl = float(cena)
vm = float(vrim)
print(str.format("So know we know that traveling distance is: {0:.4} km, by {1}, traveling cost is: ${2:.5}, and traveling time is: {3:.4} minutes", atm, tip, fl, vm))
print("")
print()
print("Here are the alternating methods:")
tour = finalSTep_2
tourtwo = finalSTep_3 / 60
tourthree = finalSTep_1
tourfour = finalSTep_1 * .621371
print(str.format(" and all together the Cost is : ${0:.6}, Time is: {1:.4} hours, Distance is: {2:.6} km ({3:.6} miles)", tour, tourtwo, tourthree, tourfour))
print()
def uSuprotnomStanju(into, dane):
dayandMonth = []
xtraExpense = 0
podjeli = dane / 7
s = math.ceil(float(podjeli))
all = 0
podjeli = 600 * s
sveKuljeno = podjeli
podjeliOne = 700 * s
sveodD = podjeliOne
podj = 2415 * s
sveodT = podj
sveodV = 0
sveodAu = 0
i = 0
arrayOne = []
arrayTwo = []
informacija = Data_Manager()
for sopjJE in into:
sp = sopjJE[0]
ab = sp
drp = sopjJE[1]
db = drp
brb = informacija.nadjiSpojeve(ab, db)
if brb == None:
one = sopjJE[2]
to = one
two = sopjJE[2]
on = two
three = sveUP(to)
mr = three
four = sveVrijeme(to)
vr = four
tr = sopjJE[0]
brg = sopjJE[1]
brb = Connection(tr, brg, 0, on, mr, 0, vr, to)
ted = all + brb.range
all = ted
tedOne = sveKuljeno + brb.CjenaP
sveKuljeno = tedOne
opa = sveodD + brb.CjenaDizela
sveodD = opa
if brb.CjenaVoza == 0:
abc = sveodT + brb.CjenaP + 115
sveodT = abc
zed = sveodV + brb.vrijemeAuta
sveodV = zed
sveodV = sveodV + brb.VrijemeVoza
sveodAu = sveodAu + brb.vrijemeAuta
natri = sveKuljeno + sveodAu
nacetri = sveodT + sveodAu
if(natri < nacetri):
if(sveKuljeno < sveodD):
vratinazadOpet = sveKuljeno, sveodAu, all
return vratinazadOpet
else:
vratise = sveodD, sveodAu, all
return vratise
Uno = sveodD + sveodAu
Due = sveodT + sveodAu
elif(Uno < Due):
allIt = sveodD, sveodAu, all
return allIt
else:
allOtherStuff = sveodT, sveodV, all
return allOtherStuff
print("---Alternate atistics comparing different travel methods---")
print(" *Costs are based on weekly rates using only car or train,")
print(" *When calculating Train, uses price for petrol when train is not availaable")
print()
print(" By Train: ----\n")
a = sveodT
b = sveodV / 60
d = all * .621371
print(str.format(" Cost: ${0:.6} '\n', Time: {1:.4} hours '\n', Distance: {2:.6} km ({3:.6} miles)", a, b, all, d))
print()
print(" By Petrol Car: ----\n")
ye = sveKuljeno
de = sveodAu / 60
ze = all * .621371
print(str.format(" Cost: ${0:.6}, Time: {1:.4} hours, Distance: {2:.6} km ({3:.6} miles)", ye, de, all, ze))
print()
print(" By Diesel Car: ----\n")
svejeOnDa = all * .621371
print(str.format(" Cost: ${0:.6}, Time: {1:.4} hours, Distance: {2:.6} km ({3:.6} miles)", sveodD, sveodAu / 60, all,svejeOnDa))
def sveVoz():
indexof = 0
pass
def sveAuto():
indexof = 0
pass
def sveGorivo(x):
number = x * 1.49 / 13
return number
def sveUP(x):
numberTwo = x * 1.61 / 22
return numberTwo
def sveVrijeme(x):
numberThree = x / 2.25
return numberThree
def sveVoz_2():
indexof = 0
pass
def sveAuto_2():
indexof = 0
pass
def sveGorivo_2(x):
number = x * 1.49 / 13
return number
def sveUP_2(x):
numberTwo = x * 1.61 / 22
return numberTwo
def sveVrijeme_2(x):
numberThree = x / 2.25
return numberThree
if __name__ == '__main__':
main()