Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #14342

Re: Turning a Sequence into a List?

From Dana DeLouis <dana01@me.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Turning a Sequence into a List?
Date 2013-04-28 04:58 +0000
Message-ID <kliaa8$sab$1@smc.vnet.net> (permalink)
Organization Time-Warner Telecom

Show all headers | View raw


> Hello, I'm playing with a problem with minimum coins to make change.
> Here's a problem spot where I look at ways to make up 52 and 53 cents
>  <snip>
> (later I'll use v =  Range[1,99].

Hi.  This doesn't quite answer your question, but I've always found this interesting.

One can find All combinations, say up to 100, very quickly with the following.
Then, a specific combination is quickly found because all the hard work is already done.

Here's the generating function for all combinations:

gf = 1 / Times@@(1-{p,n,d,q} *x^{1,5,10,25});

// Find them all up to 100:

equ=ExpandAll[Series[gf,{x,0,100}]];

// Here are all the ways to make 11.
// (d p means 1 dime and 1 penny)
// (n^2 p  means 2 nickels and one penny)

List@@Coefficient[equ,x,11]
{d p,n^2 p,n p^6,p^11}

The 49 combinations for 52 are:

List@@Coefficient[equ,x,52]
{d^5 p^2,d^4 n^2 p^2,d^3 n^4 p^2,=85 <snip > ,p^27 q,p^2 q^2}

The smallest number of coins has the smallest sum of exponents.
ie  q^2 p^2  ->  2+2 = 4

Again=85 just interesting. 


= = = = = = = = = =
HTH  :>)
Dana DeLouis
Mac & Mathematica 9
= = = = = = = = = =


Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Turning a Sequence into a List? Dana DeLouis <dana01@me.com> - 2013-04-28 04:58 +0000

csiph-web