9 Deaths of the Ninja Inspired by this conversation in chat.
Your goal in this challenge is to emulate a ninja and count how many deaths he has left.
Specs
You ninja starts out with 9 deaths left. He also gets an integral starting health as an input.
Then, he takes as input a list of events in his life that alter his health. These can be negative, positive, or zero integers.
At any point, if his health reaches at or below zero, he loses a life and his health goes back to the starting health.
Your program should report the number of deaths he has left. If he has zero or less left, you should output dead instead.
This is code-golf, so shortest code in bytes wins!
Test Cases
3, [] -&gt; 9
100, [-20, 5, -50, 15, -30, -30, 10] -&gt; 8
10, [-10, -10, -10, -10] -&gt; 5
10, [-10, -10, -10, -10, -10, -10, -10, -10, -10] -&gt; dead
0, [] -&gt; dead
0, [1] -&gt; dead
100, [10, -100] -&gt; 9
Jelly, 30 28 26 bytes

»0o⁴+
;@ñ\&lt;1S_9«0N“dead”×?


Try it online!

How it works

;@ñ\&lt;1S_9«0N“dead”×?  Main link. Input: e (events), h (initial health)

;@                    Prepend h to e.
  ñ\                  Reduce the resulting array by the next, dyadic link.
                      This returns the array of intermediate results.
    &lt;1                Check each intermediate value for non-positivity.
      S               Sum. This calculates the number of event deaths.
       _9             Subtract 9 from the result.
         «0           Take the minimum of the result and 0. This yields 0 if no
                      lives are left, the negated amount of lives otherwise.
                   ?  Conditional:
                  ×     If the product of the minimum and h is non-zero:
           N              Return the negated minimum.
            “dead”      Else, return "dead".


»0o⁴+                 Dyadic helper link. Arguments: x, y

»0                    Take the maximum of x and 0.
                      This yields x if x &gt; 0 and 0 otherwise.
  o⁴                  Take the logical OR of the result and the second input (h).
    +                 Take the sum of the result and y.