← All competitions

THE COMPETITION ARCHIVE

2024.

Explore five lunar-landing coding questions from the GIC Futuristic Festival.

Question 1

The lunar lander has 4 fuel tanks, each with a capacity of 100 units. Write a program to calculate the total fuel available for the landing.

Starting values

fuel_per_tank = 100
num_tanks = 4

CHECK YOUR ANSWER

Try your answer.

Run your program in your own editor, then paste its output below. This checks the stated output; it does not assess your full program. Practice attempts do not affect competition scores.

Enter total fuel units.

Reveal worked answer

Total fuel

400

4 tanks × 100 units = 400 units.

Question 2

The lunar lander needs to slow down during descent. Write a program that takes the current velocity (in meters per second) as input and determines if it's safe to land (velocity less than 2 meters per second).

Starting values

safe_landing_velocity = 2
current_velocity = 4

CHECK YOUR ANSWER

Try your answer.

Run your program in your own editor, then paste its output below. This checks the stated output; it does not assess your full program. Practice attempts do not affect competition scores.

At the given velocity of 4 m/s, enter yes or no.

Reveal worked answer

Safe to land? · one valid answer

no

4 is not less than 2, so landing is not safe.

Question 3

The lunar module has various sensors that send data as binary strings (0s and 1s). Write a program that takes a binary string as input and converts it to decimal.

Binary input

0100101110

CHECK YOUR ANSWER

Try your answer.

Run your program in your own editor, then paste its output below. This checks the stated output; it does not assess your full program. Practice attempts do not affect competition scores.

Reveal worked answer

Decimal value

302

The set bits contribute 256 + 32 + 8 + 4 + 2 = 302.

Question 4

The lunar lander needs to identify potential landing zones based on surface temperature data. Write a program that takes a list of temperature readings (in degrees Celsius) and identifies areas with a temperature between 0 and 20 degrees Celsius (suitable for landing).

Temperature readings to try

25, 0, 4, 37, 12, 85, 14, 63, 7, 10, -3, 20, 56

Starting code

temperatures = [int(x) for x in input("Enter temperature readings (space-separated): ").split()]

CHECK YOUR ANSWER

Try your answer.

Run your program in your own editor, then paste its output below. This checks the stated output; it does not assess your full program. Practice attempts do not affect competition scores.

Following the supplied key, enter the zero-based indices of readings from 0 through 20 inclusive, in ascending order. Submit indices, not temperatures.

Reveal worked answer

Suitable landing-zone indices

[1, 2, 4, 6, 8, 9, 11]

The suitable readings are 0, 4, 12, 14, 7, 10 and 20, at indices 1, 2, 4, 6, 8, 9 and 11.

Question 5

The lunar lander has limited fuel and needs to optimize its descent path. Write a program that simulates a simple descent with varying fuel consumption based on altitude. The program should calculate the remaining fuel after each step and determine if the lander can reach the surface with the remaining fuel.

Scenario 1

initial_fuel = 230
altitude = 92
fuel_consumption_per_meter = 5

Scenario 2

initial_fuel = 4503
altitude = 332
fuel_consumption_per_meter = 13

CHECK YOUR ANSWER

Try your answer.

Run your program in your own editor, then paste its output below. This checks the stated output; it does not assess your full program. Practice attempts do not affect competition scores.

Enter yes or no.

Enter remaining fuel units.

Reveal worked answer

Scenario 1: can land? · one valid answer

no

Scenario 2: remaining fuel at the surface

187

Scenario 1 needs 92×5 = 460 units but has only 230. Scenario 2 needs 332×13 = 4316 and has 4503, leaving 187.