Every few weeks you compile a list of their expenses (in whole USD) in the order they were incurred.
For example, the list
378 -95 2234
means that $378 was deposited to their account, and after that $95 was withdrawn, and after that $2234 was deposited.
You want to make sure that the running sum of these values never goes below some threshold value T. You decide to write a program to do this for you.
Write a program or function that takes in a single integer T and a list of integers. If the running sum of the list of integers is ever less than T, then print or return a falsy value, otherwise print or return a truthy value.
You may use any usual input methods (stdin, from file, command line, arguments to function).
- At the start of the list the running sum is 0. So a positive T means the result is always falsy.
+will never be in front of positive integers.
- The list may contain 0.
- The list may be empty.
T is -5 in all of these.
1 2 3 -20
200 -300 1000
4 -3 -6
The submission with the fewest bytes wins. Tiebreaker goes to earliest posted submission.