Problem Statement
When I can't sleep I count sheep. During the first hour I count 900 sheep (I
start at 1 and count up: 1, 2, 3, ..., 899, 900). During the next hour I count
them down (so as to avoid having my numbers of sheep grow too large), that is,
I count 899, 898 etc. As I count down slower than up, I count 600 sheep down
during the second hour. Then I count up again, and so forth.
Your task is, given the number of minutes I spend trying to get to sleep, return the final number of sheep where I stop counting.
Your task is, given the number of minutes I spend trying to get to sleep, return the final number of sheep where I stop counting.
Definition
- Class:
- Insomnia
- Method:
- sheepCount
- Parameters:
- int
- Returns:
- int
- Method signature:
- int sheepCount(int minutes)
- (be sure your method is public)
Notes
- Assume that each hour I count evenly: either 15 sheep a minute up, or 10 sheep a minute down.
Constraints
- minutes is between 0 and 720, inclusive.
Examples
0
Returns: 0
120
Returns: 300
2
Returns: 30
185
Returns: 1150