Space Survival Game Challenge
Ninja is in space with unlimited fuel in his super spaceship. He starts with a health level H
and his spaceship has an armour A
. Ninja can be on only one of the three planets at a time: VENUS, MARS, or SATURN. Each second, he must change his location instantly. These planets affect health and armour in different ways:
- Venus: Decreases health by 4, decreases armour by 8.
- Mars: Increases health by 3, increases armour by 2.
- Saturn: Decreases health by 10, increases armour by 5.
The game ends when either H <= 0
or A <= 0
.
Your task is to determine the maximum time Ninja can survive.
Input:
The first line contains a single integer T
, representing the number of test cases.
Each of the next T
lines contains two space-separated integers, the initial health H
and the initial armour A
.
Output:
For each test case, print a single integer denoting the maximum time Ninja can survive.
Print the output for each test case on a new line.
Example:
Input:
2
20 8
10 15
Output:
3
6
Constraints:
1 <= T <= 10
1 <= H, A <= 1000
Note:
You don’t have to print anything. Implement the function to compute the result.
Be the first one to answer
Add answer anonymously...
Top TCS Assistant System Engineer interview questions & answers
Popular interview questions of Assistant System Engineer
Top HR questions asked in TCS Assistant System Engineer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app