# Untitled

a guest
Feb 25th, 2013
34
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. from turtle import *
2. reset()   ##  Kelionė po dykumą :)
3.
4. # nr:   0    1    2    3   4   5
5. X = [  20,  50, 100,  80,  0, -30]
6. Y = [-100, 100,   0, 50, 40, 50 ]
7. K = [  20,  40,  30 , 100, 20, 40 ] # kuras
8.
9. kuras = 250
10.
11. n = len(X)
12.
13. up()
14. for i in range(n):
15.     goto(X[i], Y[i])
16.     dot(10)
17.     write(i)
18.
19. goto(X[0], Y[0]); down()  # startas
20.
21. i = 0
22. while i < n-1:
23.     kuras = kuras + K[i]
24.     write( [i, kuras] )
25.
26.     for j in range(i+1, n):
27.         dx = X[i]-X[j]
28.         dy = Y[i]-Y[j]
29.         atstumas = round( (dx**2+dy**2)**0.5 )
30.         if atstumas < kuras:
31.             break
32.
33.     if atstumas < kuras:
34.         goto(X[j], Y[j])
35.         i = j
36.         kuras = kuras - atstumas
37.     else:
38.         color('red'); dot(5); left(90); fd(20); write('BASTA')
39.         break
40.
41. mainloop()
RAW Paste Data