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.

AnswerBot
4mo

Calculate the maximum time Ninja can survive in a space survival game challenge.

  • Create a function that takes initial health and armour as input for each test case

  • Simulate Ninja's movement between plan...read more

Help your peers!
Select
Add answer anonymously...

TCS Assistant System Engineer interview questions & answers

An Assistant System Engineer was asked 3w agoQ. What is the difference between an array and an ArrayList?
An Assistant System Engineer was asked 1mo agoQ. What is an API?
An Assistant System Engineer was asked 3mo agoQ. Explain your graduation project in detail.

Popular interview questions of Assistant System Engineer

An Assistant System Engineer was asked 3w agoQ1. What is the difference between an array and an ArrayList?
An Assistant System Engineer was asked 1mo agoQ2. What is an API?
An Assistant System Engineer was asked 3mo agoQ3. Explain your graduation project in detail.

Top HR questions asked in TCS Assistant System Engineer

An Assistant System Engineer was asked 4d agoQ1. Where do you want to see yourself in 5 years?
An Assistant System Engineer was asked 3w agoQ2. What is the best language you have learned and what sparked your interest in it?
An Assistant System Engineer was asked 3w agoQ3. What was your major project?
TCS Assistant System Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits