PracticeSimulation

Next-Move Momentum

BeginnerSimulationstate trackingindex arithmeticinvariants Time not estimated Not started

Context

In the arcade game Neon Vault, every move has a momentum marker. The marker can be positive, zero, or negative depending on the player's current streak. The scoring engine awards a rectangular momentum bonus based on the marker and the next consecutive marker value.

Problem

Implement a function that calculates the momentum bonus for a given integer marker. The bonus is the product of the marker and the integer immediately after it. Preserve the sign and exact arithmetic result for every allowed marker, including zero, negative markers, and large markers.

Examples

Example 1
Input: marker = 5
Output: 30
Explanation: For marker 5, the executed function returns 30.
Example 2
Input: marker = 0
Output: 0
Explanation: For marker 0, the executed function returns 0.
Example 3
Input: marker = -4
Output: 12
Explanation: For marker -4, the executed function returns 12.

Constraints

  • -1000000000 <= marker <= 1000000000
  • Types: marker is int; result is int

Function signature

def calculate_momentum_bonus(marker: int) -> int
marker int
The signed integer momentum marker for the current move.
returns int
The exact product of marker and the integer immediately greater than marker.

Adapted from MBPP problem task_35 (CC BY 4.0). Rewritten, extended and verified by Iksha.

Approved · c021r1-abs_489_v113 execution-verified tests
Code
Saved
Checking environment…Python SandboxLn 1, Col 1