Skip to main content
atuuub
Source Link

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 , so shortest answer wins!

Test cases

Budget    Item prices                           Output
14.50     [0.99, 2.99, 4.50, 12.99]             [0.99, 12.99]
99.99     [79.99, 100.00]                       [79.99]
2.68      [3.00]                                []
3.50      []                                    []
5.23      [5.23]                                []
26.99     [0.01, 26.98]                         [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]        [2.00, 7.00]

tags:

MetaSpend maximal money

  • Is this a duplicate?

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 , so shortest answer wins!

Test cases

Budget    Item prices                           Output
14.50     [0.99, 2.99, 4.50, 12.99]             [0.99, 12.99]
99.99     [79.99, 100.00]                       [79.99]
2.68      [3.00]                                []
3.50      []                                    []
5.23      [5.23]                                []
26.99     [0.01, 26.98]                         [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]        [2.00, 7.00]

tags:

Meta

  • Is this a duplicate?
Rollback to Revision 9 - damn you jezza!!!
Source Link

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 , so shortest answer wins!

Test cases

Budget    Item prices                           Output
14.50     [0.99, 2.99, 4.50, 12.99]             [0.99, 12.99]
99.99     [79.99, 100.00]                       [79.99]
2.68      [3.00]                                []
3.50      []                                    []
5.23      [5.23]                                []
26.99     [0.01, 26.98]                         [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]        [2.00, 7.00]

tags:

Meta

  • Is this a duplicate?

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.
  • You may assume input will be ordered.
  • This is , so shortest answer wins!

Test cases

Budget    Item prices                           Output
14.50     [0.99, 2.99, 4.50, 12.99]             [0.99, 12.99]
99.99     [79.99, 100.00]                       [79.99]
2.68      [3.00]                                []
3.50      []                                    []
5.23      [5.23]                                []
26.99     [0.01, 26.98]                         [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]        [2.00, 7.00]

tags:

Meta

  • Is this a duplicate?

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 , so shortest answer wins!

Test cases

Budget    Item prices                           Output
14.50     [0.99, 2.99, 4.50, 12.99]             [0.99, 12.99]
99.99     [79.99, 100.00]                       [79.99]
2.68      [3.00]                                []
3.50      []                                    []
5.23      [5.23]                                []
26.99     [0.01, 26.98]                         [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]        [2.00, 7.00]

tags:

Meta

  • Is this a duplicate?
deleted 49 characters in body
Source Link

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 , so shortest answer wins!

Test cases

Budget    Item prices                           Output
14.50     [0.99, 2.99, 4.50, 12.99]             [0.99, 12.99]
99.99     [79.99, 100.00]                       [79.99]
2.68      [3.00]                                []
3.50      []                                    []
5.23      [5.23]                                []
26.99     [0.01, 26.98]                         [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]        [2.00, 7.00]

tags:

Meta

  • Is this a duplicate?

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 , so shortest answer wins!

Test cases

Budget    Item prices                           Output
14.50     [0.99, 2.99, 4.50, 12.99]             [0.99, 12.99]
99.99     [79.99, 100.00]                       [79.99]
2.68      [3.00]                                []
3.50      []                                    []
5.23      [5.23]                                []
26.99     [0.01, 26.98]                         [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]        [2.00, 7.00]

tags:

Meta

  • Is this a duplicate?

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.
  • You may assume input will be ordered.
  • This is , so shortest answer wins!

Test cases

Budget    Item prices                           Output
14.50     [0.99, 2.99, 4.50, 12.99]             [0.99, 12.99]
99.99     [79.99, 100.00]                       [79.99]
2.68      [3.00]                                []
3.50      []                                    []
5.23      [5.23]                                []
26.99     [0.01, 26.98]                         [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]        [2.00, 7.00]

tags:

Meta

  • Is this a duplicate?
deleted 6 characters in body
Source Link
Loading
uh oh
Source Link
Loading
fix test cases
Source Link
Loading
deleted 12 characters in body
Source Link
Loading
deleted 6 characters in body
Source Link
Loading
added 274 characters in body
Source Link
Loading
i need feedback or upvotes or etc
Source Link
Loading
added 61 characters in body
Source Link
Loading
Source Link
Loading