# Spend maximal money Imagine that you're going shopping. You are on a budget and just looking around the store, trying to find things you would be interested in. Eventually, you find a set amount of things. However, since you have zero morals, you want to spend the most money possible without going over or equaling your budget. So, given a budget \$n\$ and a list of positive floats (prices) \$l\$, try to spend as most money as possible without the total price being greater than/equal to \$n\$. ## Rules + Standard rules and I/O methods apply. + Loopholes are forbidden. + Prioritize choosing items from left to right. + You may assume input will be ordered. + This is [tag:code-golf], so shortest answer wins! ## Test cases Budget Item prices Output 14.50 [4.50, 2.99, 0.99, 12.99] [12.99, 0.99] 99.99 [79.99, 100.00] [79.99] 2.68 [3.00] [] 3.50 [] [] 5.23 [5.23] [] 26.99 [26.98, 0.01] [26.98] 17.00 [0.99, 1.99, 2.99, 3.99, 4.99, 5.99] [1.99, 3.99, 4.99, 5.99] 10.00 [5.00, 5.00, 10.00] [5.00] 10.00 [1.00, 2.00, 5.00, 5.00, 7.00] [1.00, 2.00, 5.00] --- tags: [tag:code-golf] [tag:array] # Meta + Is this a duplicate?