Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- encoding: utf-8 -*-
- import sys
- class Gato(object):
- def __init__(self, x, y):
- self.x = x
- self.y = y
- def addPasso(self):
- self.y += 1
- def isColidiu(self, x, y):
- if self.x == x and self.y== y:
- return True
- return False
- def __repr__(self):
- return 'X:{} Y:{}'.format(self.x, self.y)
- class Carro(object):
- def __init__(self, x, y, v):
- self.x = x
- self.y = y
- self.v = v
- self.newCar = 0
- def addPasso(self):
- self.x += self.v
- def onMedium(self):
- if self.x > 6 and self.newCar == 0:
- self.newCar += 1
- return True
- return False
- def onEnd(self):
- if self.x >= 12:
- return True
- return False
- def __repr__(self):
- return 'X:{} Y:{} V:{}'.format(self.x, self.y, self.v)
- line = sys.stdin.readline.split()
- entradas = [int(l) for l in line]
- cars = [Carro(0, y+1, v) for y, v in enumerate(entradas)]
- cat = Gato(6,0)
- colisao = 0
- for x in xrange(0, 6):
- if colisao != 0:
- break
- else:
- cat.addPasso()
- for car in cars:
- car.addPasso()
- if cat.isColidiu(car.x, car.y):
- colisao = cat.y
- break
- else:
- if car.onMedium():
- cars.append(Carro(0, car.y, car.v))
- if car.onEnd():
- cars.remove(car)
- print colisao
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement