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
1
Returns: 15
59
Returns: 885
60
Returns: 900
61
Returns: 890
119
Returns: 310
121
Returns: 315
179
Returns: 1185
180
Returns: 1200
181
Returns: 1190
239
Returns: 610
240
Returns: 600
241
Returns: 615
299
Returns: 1485
300
Returns: 1500
301
Returns: 1490
599
Returns: 1510
600
Returns: 1500
601
Returns: 1515
719
Returns: 1810
720
Returns: 1800
467
Returns: 1330
150
Returns: 750