PracticeArrays

Choose the Highest Shipment Priority

BeginnerArraystraversalstate trackingcomparison Time not estimated Not started

Context

A warehouse must decide which of four shipments deserves attention first. Each shipment has an integer priority score: larger scores mean more urgent handling, while negative scores indicate low urgency. Find the greatest score among the four shipments.

Problem

Write a function that receives the priority scores for exactly four shipments and returns the greatest score. Begin with one supplied score as the current best, compare it with each remaining score, and replace the current best whenever a larger score is found. Equal scores, negative values, zero, and repeated greatest values must be handled through ordinary integer comparisons. The returned value must be one of the supplied scores.

Examples

Example 1
Input: priority_scores = [12, 7, 19, 4]
Output: 19
Explanation: For `[12, 7, 19, 4]`, the executed call returns `19`; its final `current_best`, `selected_value`, and maximum are all `19`.
Example 2
Input: priority_scores = [-8, 0, -3, -12]
Output: 0
Explanation: For `[-8, 0, -3, -12]`, the executed call returns `0`; its final `current_best` and `selected_value` are `0`.
Example 3
Input: priority_scores = [6, 6, 2, 6]
Output: 6
Explanation: For `[6, 6, 2, 6]`, the executed call returns `6`; its final `current_best` and `selected_value` are `6`.

Constraints

  • 4 <= len(priority_scores) <= 4
  • -1000000 <= priority_scores[i] <= 1000000 for every i
  • Types: priority_scores is int[]; result is int

Function signature

def highest_shipment_priority(priority_scores: list[int]) -> int
priority_scores list[int]
The integer priority scores for exactly four shipments.
returns int
The greatest priority score among the four supplied shipment scores.

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

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