MARS LANDER
Using a straightforward condition, this puzzle shows me how to compare values. The spaceship must be securely landed on the platform in order to complete this challenge. EXPLANATION OF CODE: 1) The user's input is retrieved in the first two lines of the code. The first line specifically returns the surfaceN integer value, which is the number of points used to represent the surface of Mars. The user's real input is not used in the second line's loop, which iterates surfaceN times while retrieving more input from them. 2) The primary game loop is represented by the while loop. Until the game is finished or the software is stopped, it will keep running endlessly. The program reads user input and processes it for each iteration of the loop. 3) The third line inside the while loop retrieves input from the user, splits it into an array called inputs, and assigns the fourth value of that array to a variable called vSpeed, which represents the vertical speed of the spacecraft. 4) In accordance with the value of vSpeed, the following few lines of code establish the power and angle values. Namely, if vSpeed is less than or equal to -40, the power is set to 4, and the angle is set to 0. The default setting for power and angle is 0. 5) The last line of the code outputs the angle and power values that will be used to steer the spacecraft during the current iteration of the game loop. #codingame #javascript #marslander #condition #puzzle #easy #values #compare #spaceship #landed #platform
Using a straightforward condition, this puzzle shows me how to compare values. The spaceship must be securely landed on the platform in order to complete this challenge. EXPLANATION OF CODE: 1) The user's input is retrieved in the first two lines of the code. The first line specifically returns the surfaceN integer value, which is the number of points used to represent the surface of Mars. The user's real input is not used in the second line's loop, which iterates surfaceN times while retrieving more input from them. 2) The primary game loop is represented by the while loop. Until the game is finished or the software is stopped, it will keep running endlessly. The program reads user input and processes it for each iteration of the loop. 3) The third line inside the while loop retrieves input from the user, splits it into an array called inputs, and assigns the fourth value of that array to a variable called vSpeed, which represents the vertical speed of the spacecraft. 4) In accordance with the value of vSpeed, the following few lines of code establish the power and angle values. Namely, if vSpeed is less than or equal to -40, the power is set to 4, and the angle is set to 0. The default setting for power and angle is 0. 5) The last line of the code outputs the angle and power values that will be used to steer the spacecraft during the current iteration of the game loop. #codingame #javascript #marslander #condition #puzzle #easy #values #compare #spaceship #landed #platform