Your question is Heaviest Coin Bag Algorithm. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
During an NVIDIA H100 validation run, a calibration fixture contains 10 labeled bags, each holding 10 coins. Nine bags contain coins weighing normal_weight grams, while every coin in exactly one bag weighs heavy_weight grams. The heavier bag must be identified with one weighing.
Before weighing, remove 1 coin from bag 1, 2 coins from bag 2, and so on through 10 coins from bag 10. Weigh all 55 selected coins together. Implement a function that returns the 1-based label of the bag containing the heavier coins.
Implement find_heavy_bag(measured_weight, normal_weight, heavy_weight).
measured_weight, normal_weight, and heavy_weight are positive integers representing grams.heavy_weight > normal_weight and exactly one bag is heavy.def find_heavy_bag(measured_weight, normal_weight, heavy_weight):