PracticeMath

Fast-Track a New Group Member

BeginnerMathcomparisonmin/max trackingcounting Time not estimated Not started

Context

A community platform wants to estimate how many outreach actions are needed to bring a user into a private group. Each action can advance the user's progress by exactly one of two fixed trust boosts. The user is considered ready once total progress reaches or passes the required threshold. Find the fewest actions needed.

Problem

Implement a function that returns the minimum number of outreach actions needed to reach or pass a target progress value. Every action contributes either boost_a or boost_b progress points, and the same boost may be used repeatedly. If the target is zero, no actions are needed. Otherwise, choose the better displacement whenever possible and count enough actions to meet or exceed the target. The result must be an integer and must use exact integer arithmetic.

Examples

Example 1
Input: boost_a = 5boost_b = 8target = 0
Output: 0
Explanation: With boosts 5 and 8 and target 0, the normalized values are long_step = 8 and target_dist = 0, so the executed function returns 0.
Example 2
Input: boost_a = 6boost_b = 10target = 7
Output: 1
Explanation: With boosts 6 and 10 and target 7, long_step = 10 and the executed function returns jump_count = 1.
Example 3
Input: boost_a = 4boost_b = 7target = 20
Output: 3
Explanation: With boosts 4 and 7 and target 20, long_step = 7 and the executed function returns jump_count = 3.

Constraints

  • 1 <= boost_a <= 1000000000
  • 1 <= boost_b <= 1000000000
  • 0 <= target <= 1000000000
  • Types: boost_a is int, boost_b is int, target is int; result is int

Function signature

def minimum_outreach_actions(boost_a: int, boost_b: int, target: int) -> int
boost_a int
Progress points added by the first kind of outreach action.
boost_b int
Progress points added by the second kind of outreach action.
target int
Nonnegative progress threshold required for group readiness.
returns int
The smallest number of actions whose total progress reaches or exceeds target.

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

Notes

  • The two boosts may be equal.
  • An action may overshoot the target; overshooting still counts as reaching it.
Approved · cb061r1-abs_17_v214 execution-verified tests
Code
Saved
Checking environment…Python SandboxLn 1, Col 1