Something like this should do the trick in Elixir. I'm just doubling the range and subtracting one on each iteration to avoid issues with floats and because working with integers is faster.
defmoduleZombieWarsdodefzombie_shootout(n,r,a),do:_zombie_shootout(n,r*2,a,n)defp_zombie_shootout(0,_,_,s)do"You shot all #{s} zombies."enddefp_zombie_shootout(n,0,_a,s)do"You shot #{s-n} zombies before being eaten: overwhelmed."enddefp_zombie_shootout(n,_r,0,s)do"You shot #{s-n} zombies before being eaten: ran out of ammo."enddefp_zombie_shootout(n,r,a,s)doifEnum.random(1..20)==1do_zombie_shootout(n,r-1,a-1,s)else_zombie_shootout(n-1,r-1,a-1,s)endendend
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.
Something like this should do the trick in Elixir. I'm just doubling the range and subtracting one on each iteration to avoid issues with floats and because working with integers is faster.