Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
The Good, the Bad and the Ugly solution in Creative category for The Best Number Ever by angapov
# migrated from python 2.7
def checkio():
print("""
6, the perfect number.
Blondie, "The Good, the Bad and the Ugly""")
perfect_number = 6
class Blondie():
def __init__(self):
self.height = 'tall'
self.hairs = 'blonde'
self.smoke = 'cigar'
self.cigars = 1000000
self.dangerous_eyes = True
self.enemies = Enemies(number=6)
self.gun = Revolver(bullets=6)
print("""
I’m looking for the owner of that horse!
He’s %s, %s, he smokes a %s, and he’s a pig! – Tuco""" % \
(self.height, self.hairs, self.smoke))
if self.chew_cigar() and self.dangerous_eyes and self.gun:
self.shoot(self.gun, self.enemies)
def chew_cigar(self):
"""After a meal there's nothing like a good cigar."""
if self.cigars>=1:
return True
def dangerous_eyes(self):
return self.dangerous_eyes
def shoot(self,gun,enemies):
print("""
I have a feeling it's really gonna be a good, long battle.
""")
self.enemies_left = enemies.number
while self.enemies_left:
print("PUF!!!")
self.enemies_left = enemies.die()
print("""
I've never seen so many men wasted so badly.""")
class Revolver():
def __init__(self, bullets=None):
self.loaded_bullets = 0
self.max_bullets = 6
self.ready = True
self.load(bullets)
def load(self, bullets):
"""You see, in this world there's two kinds of people, my friend:
Those with loaded guns and those who dig. You dig."""
for bullet in range(bullets+1):
self.loaded_bullets+=1
if self.loaded_bullets==self.max_bullets:
return self.gun_full()
def gun_full(self):
print("""
I've got 6 more bullets in my gun.""")
return self.ready
class Enemies():
def __init__(self, number=None):
self.number=number
def die(self):
print("""Enemy %s has left the game""" % str(self.number))
self.number-=1
return self.number
if Blondie(): return perfect_number
if __name__ == '__main__':
# These "asserts" using only for self-checking and not necessary for auto-testing
assert isinstance(checkio(), (int, float, complex))
May 23, 2015
Comments: