Re: Turning a Sequence into a List?

• To: mathgroup at smc.vnet.net
• Subject: [mg130643] Re: Turning a Sequence into a List?
• From: Dana DeLouis <dana01 at me.com>
• Date: Sun, 28 Apr 2013 01:01:19 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-outx@smc.vnet.net
• Delivered-to: mathgroup-newsendx@smc.vnet.net

```> 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
= = = = = = = = = =

```

• Prev by Date: Re: Convolve: Different Looking Results. (2)
• Next by Date: Re: Wrong Answer
• Previous by thread: Re: Turning a Sequence into a List?
• Next by thread: How to apply tags to expression terms?