# breaking it down advanced

The Treasure Budget

The pirate market sells wonders, and you may buy EXACTLY TWO — spending as much of your gold as possible (showing off is the point). 🏴‍☠️

You get your budget and the item prices (at least two). Find the pair of different items with the biggest total that still fits the budget. Print that total, or keep saving if no pair fits.

Example:

Input: budget = 10, prices = [3, 8, 5, 2] Output: 10

Checking every pair, 8 + 2 = 10 is the biggest total that still fits the budget exactly.

💡 need a hint?

brk-treasure-budget.py🔒 given lines are locked — write your code in between
loading...