Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- from random import randrange
- class mouse(object) :
- def __init__(self) :
- self.alive = True
- def drink(self,bottle) :
- if bottle.isPoisoned() == True :
- self.alive = False
- def isAlive(self) :
- return self.alive
- class wine(object) :
- def __init__(self,num) :
- self.number = num
- self.poisoned = False
- def setPoisoned(self) :
- self.poisoned = True
- def isPoisoned(self) :
- return self.poisoned
- def getNum(self) :
- return self.number
- mice = []
- bottles = []
- for i in range(0,1000) :
- bottles.append(wine(i+1))
- for i in range(0,10) :
- mice.append(mouse())
- r = randrange(0,len(bottles))
- bottles[r].setPoisoned()
- for bottle in bottles :
- binbot = list(map(lambda a: int(a),"{0:010b}".format(bottle.getNum())))
- for i in range(0,10) :
- if binbot[i] == 1 :
- if mice[i].isAlive() == False :
- continue #дохлая мышь не пьет, технически ненужный момент для имитации real life
- mice[i].drink(bottle)
- answer = ''
- for m in mice :
- if m.isAlive() == True :
- answer += '0'
- else :
- answer += '1'
- print(int(answer,2))
Advertisement
Add Comment
Please, Sign In to add comment