Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from turtle import *
- reset() ## Kelionė po dykumą :)
- # nr: 0 1 2 3 4 5
- X = [ 20, 50, 100, 80, 0, -30]
- Y = [-100, 100, 0, 50, 40, 50 ]
- K = [ 20, 40, 30 , 100, 20, 40 ] # kuras
- kuras = 250
- n = len(X)
- up()
- for i in range(n):
- goto(X[i], Y[i])
- dot(10)
- write(i)
- goto(X[0], Y[0]); down() # startas
- i = 0
- while i < n-1:
- kuras = kuras + K[i]
- write( [i, kuras] )
- for j in range(i+1, n):
- dx = X[i]-X[j]
- dy = Y[i]-Y[j]
- atstumas = round( (dx**2+dy**2)**0.5 )
- if atstumas < kuras:
- break
- if atstumas < kuras:
- goto(X[j], Y[j])
- i = j
- kuras = kuras - atstumas
- else:
- color('red'); dot(5); left(90); fd(20); write('BASTA')
- break
- mainloop()
Advertisement
Add Comment
Please, Sign In to add comment