fromrandomimportchoicesdefzombie_shootout(zombies,distance,ammo):population=[0,1]distribution=[0.05,0.95]zombies_killed=0foriinrange(distance*2):ifammo==0andzombies_killed<zombies:print("You killed %d zombies before being eaten: out of ammo"%zombies_killed)returnifzombies_killed==zombies:print("You killed %d zombies and survived"%zombies_killed)returnhit=choices(population,distribution)ifnothit:ammo-=1print(hit)else:ammo-=1zombies_killed+=1ifzombies_killed<zombies:print("You killed %d zombies before being eaten: overwhelmed"%zombies_killed)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
here's my solution in Python