PracticeArrays

Twin Score Merge

BeginnerArraystraversalaccumulationstate tracking Time not estimated Not started

Context

In the arcade game Neon Rift, a player receives a base score and a combo bonus at each move. The two score logs may stop at different times. Combine the logs position by position to create the player's merged score log.

Problem

Write a function that combines two integer lists, base_scores and combo_bonuses. For every position available in both lists, add the two values at that position and append the sum to the result. Keep the sums in their original order. If one list is longer, ignore its unmatched ending. If either list is empty, return an empty list.

Examples

Example 1
Input: base_scores = [10, 20, 15]combo_bonuses = [2, 5, 3]
Output: [12, 25, 18]
Explanation: The executed output for the first example is [12, 25, 18].
Example 2
Input: base_scores = [7, 12, 4, 9]combo_bonuses = [1, 3]
Output: [8, 15]
Explanation: The executed output for the second example is [8, 15].
Example 3
Input: base_scores = []combo_bonuses = [5, 10]
Output: []
Explanation: The executed output for the third example is an empty list.

Constraints

  • 0 <= len(base_scores) <= 100
  • -1000000 <= base_scores[i] <= 1000000 for every i
  • 0 <= len(combo_bonuses) <= 100
  • -1000000 <= combo_bonuses[i] <= 1000000 for every i
  • Types: base_scores is int[], combo_bonuses is int[]; result is int[]

Function signature

def merge_move_scores(base_scores: list[int], combo_bonuses: list[int]) -> list[int]
base_scores list[int]
The score earned directly on each move.
combo_bonuses list[int]
The bonus score aligned with each move.
returns list[int]
A list containing the sum of each aligned pair, in input order, with one result per shared position.

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

Notes

  • Unmatched values at the end of the longer list do not contribute to the result.
  • Negative values and zero are valid scores.
Approved · c037-abs_128_v214 execution-verified tests
Code
Saved
Checking environment…Python SandboxLn 1, Col 1