ways to make change
|
03-02-2019, 10:33 PM
Post: #3
|
|||
|
|||
RE: ways to make change
(03-02-2019 06:58 PM)Albert Chan Wrote: PNDH ways = Σ( ((1+d) - 5k) * ((1+n-d) - 5k), k=0 to h ) Extending with all 5 coins (penny, nickel, dime, quarter, half-dollar) is now easy. Just add quarters to PNDH ways, replacing half-dollar with quarters, 1 at a time. Let this 5 coins helper function be f5: f5 ways = Σ( (1+k) * ((1+d) - 5k) * ((1+n-d) - 5k), k=0 to h ) After simplication, this is final result: Code: def f5(x): >>> PNDQH(100) # ways to add to 1 dollar, with pennies, nickels, dimes, quarter, half-dollar 292 >>> PNDQH(100000) # how about 1000 dollars ? 66793412685001L |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
ways to make change - Albert Chan - 03-02-2019, 05:37 PM
RE: ways to make change - Albert Chan - 03-02-2019, 06:58 PM
RE: ways to make change - Albert Chan - 03-02-2019 10:33 PM
RE: ways to make change - Albert Chan - 03-03-2019, 06:05 PM
RE: ways to make change - Albert Chan - 03-04-2019, 04:31 PM
RE: ways to make change - Albert Chan - 03-05-2019, 10:17 PM
|
User(s) browsing this thread: 1 Guest(s)