[#285488] Zed Shaw - Ruby has dodged a bullet — Chuck Remes <cremes.devlist@...>

Much like watching a car accident in slow motion, I could scarcely

96 messages 2008/01/01

[#285678] Windows Compilation Madness — Gary Wright <gwtmp01@...>

No point in keeping this discussion in the Zed thread...

24 messages 2008/01/02

[#285742] change the symbol in an interpolated string value? — scooterm@...

PROBLEM:

11 messages 2008/01/03

[#285784] Ruby install on Kubuntu Linux - why so spread out — Tom Cloyd <tc@...>

I've migrated from WinXP in recent days, and I'm having trouble getting

19 messages 2008/01/03
[#285786] Re: Ruby install on Kubuntu Linux - why so spread out — Casimir <pikEISPAMMMseli@...> 2008/01/03

Tom Cloyd kirjoitti:

[#285792] Re: Ruby install on Kubuntu Linux - why so spread out — Peter Hickman <peter@...> 2008/01/03

Casimir I'm going to have to call you on this. As you may have just

[#285838] "wrong number of arguments" What? I must be thick or somethi — ole __ <oliver.saunders@...>

class PermutationIterator

10 messages 2008/01/03

[#285873] Time.gm(1969) chokes on Windows — Tim Ferrell <s0nspark@...>

18 messages 2008/01/03

[#285910] Get your hands dirty: Help bootstrap Ruby on Windows. — Luis Lavena <luislavena@...>

This was asked, and asked, and asked too many times, so here we go.

20 messages 2008/01/03

[#285951] Finding if an array contains a data type — Sam Phoneix <dominicjefferies@...>

Say I wanted to see if an array contained a number or not. Would I use

11 messages 2008/01/04

[#285981] How to put a Ruby website online without rails — Softmind Technology <softmindtechnology@...>

Hi,

28 messages 2008/01/04
[#286230] Re: How to put a Ruby website online without rails — James Britt <james.britt@...> 2008/01/05

Giles Bowkett wrote:

[#286252] Re: How to put a Ruby website online without rails — yudi <yudi.xue@...> 2008/01/05

Ramaze looks good, gotta take a look. Thanks :-)

[#286449] Re: How to put a Ruby website online without rails — James Dinkel <jdinkel@...> 2008/01/07

Here is a forum post that tells you how to embed ruby script into

[#285988] problem with sockets — ian@...

Hi

13 messages 2008/01/04

[#286012] Studying Blackjack (#151) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

42 messages 2008/01/04

[#286056] Re: zed shaw zed shaw zed shaw — "Rick DeNatale" <rick.denatale@...>

On Jan 4, 2008 11:52 AM, Jeremy McAnally <jeremymcanally@gmail.com> wrote:

16 messages 2008/01/04

[#286077] DBI doesn't seem to install correctly on CentOS — Xeno Campanoli <xcampanoli@...>

I tried installing with the old tarfile sequence using setup.rb, as I

14 messages 2008/01/04
[#286079] Re: DBI doesn't seem to install correctly on CentOS — Joshua Schairbaum <joshua.schairbaum@...> 2008/01/04

Try this to use DBI with MySQL:

[#286120] Best Ruby book for experienced programmer — Kamil Chmielewski <kamilski81@...>

Hello,

19 messages 2008/01/04

[#286221] Vintage 0.0.1 - The super slim, micro web framework based on the idea of the old Merb — "Jeremy McAnally" <jeremymcanally@...>

Vintage is a very small web framework based on the original idea of

23 messages 2008/01/05
[#286346] Re: [ANN] Vintage 0.0.1 - The super slim, micro web framework based on the idea of the old Merb — "ara.t.howard" <ara.t.howard@...> 2008/01/06

[#286273] Marshal Pipe — "Carlos J. Hernandez" <carlosjhr64@...>

I've just re-discovered pipes.

16 messages 2008/01/05
[#286515] Re: Marshal Pipe — Eric Hodel <drbrain@...7.net> 2008/01/07

On Jan 5, 2008, at 15:37 PM, Carlos J. Hernandez wrote:

[#286374] DateTime new_offset unexpected results — Greg Go <plant@...>

Hello, everybody:

13 messages 2008/01/06
[#286484] Re: DateTime new_offset unexpected results — "Todd Benson" <caduceass@...> 2008/01/07

On Jan 6, 2008 2:04 PM, Greg Go <plant@ultraspace.com> wrote:

[#286375] Ruby's Kernel::exec (and system and %x) — JJ <jjnoakes@...>

I was reading about Kernel::exec (and the related Kernel::system

29 messages 2008/01/06

[#286473] Where do I put the ".to_f" ? — Peter Bailey <pbailey@...>

Hello,

13 messages 2008/01/07

[#286493] Bacon 0.9, a small RSpec clone — Christian Neukirchen <chneukirchen@...>

Hello,

13 messages 2008/01/07

[#286508] Embedding 1.9 — Dave Thomas <dave@...>

Folks:

18 messages 2008/01/07

[#286558] Thin 0.5.1 LOLCAT released — Marc-andre Marc <macournoyer@...>

Hey all,

13 messages 2008/01/08

[#286656] JRuby 1.1 RC 1 Released — Thomas Enebo <Thomas.Enebo@...>

The JRuby community is pleased to announce the release of JRuby 1.1 RC 1

19 messages 2008/01/08
[#286710] Re: [ANN] JRuby 1.1 RC 1 Released — "Sander Land" <sander.land@...> 2008/01/08

With all the blog posts about JRuby being posted, I thought I would

[#286696] dow ruby's strftime not attempt POSIX-compliance? — Jochen Hayek <jochen+ruby-forum@...>

Why is ruby's core class Time acting like this:

21 messages 2008/01/08
[#286701] Re: dow ruby's strftime not attempt POSIX-compliance? — Suraj Kurapati <snk@...> 2008/01/08

Jochen Hayek wrote:

[#286702] Re: dow ruby's strftime not attempt POSIX-compliance? — Suraj Kurapati <snk@...> 2008/01/08

Suraj Kurapati wrote:

[#286717] Re: does ruby's strftime not attempt POSIX-compliance? — Jochen Hayek <jochen+ruby-forum@...> 2008/01/09

Suraj Kurapati wrote:

[#287161] Re: does ruby's strftime not attempt POSIX-compliance? — Suraj Kurapati <snk@...> 2008/01/12

Jochen Hayek wrote:

[#287217] Re: does ruby's strftime not attempt POSIX-compliance? — Jochen Hayek <jochen+ruby-forum@...> 2008/01/12

Pls let me assure you in the beginning of this note,

[#287219] Re: does ruby's strftime not attempt POSIX-compliance? — Suraj Kurapati <snk@...> 2008/01/12

Jochen Hayek wrote:

[#287344] Re: does ruby's strftime not attempt POSIX-compliance? — Yukihiro Matsumoto <matz@...> 2008/01/14

Hi,

[#286742] why does this code leak? — ara howard <ara.t.howard@...>

cfp2:~ > cat a.rb

35 messages 2008/01/09
[#286991] Re: why does this code leak? — "=?ISO-8859-2?Q?Rados=B3aw_Bu=B3at?=" <radek.bulat@...> 2008/01/10

T24gSmFuIDEwLCAyMDA4IDEwOjE1IFBNLCBSb2JlcnQgRG9iZXIgPHJvYmVydC5kb2JlckBnbWFp

[#287063] Here Document syntax is stringent - trailing blank — Todd Burch <promos@...>

text = <<EOD

12 messages 2008/01/11

[#287067] Need command line to run a file 4 times — jackster the jackle <contact@...>

Hi Ruby Forum...

13 messages 2008/01/11
[#287074] Re: Need command line to run a file 4 times — Xavier Noria <fxn@...> 2008/01/11

On Jan 11, 2008, at 2:47 PM, jackster the jackle wrote:

[#287080] Counting the files in a directory.... — "Kyle Schmitt" <kyleaschmitt@...>

SSdtIHdyaXRpbmcgc29tZSBzY3JpcHRzIHRvIGhlbHAgbWFuYWdlIGEgbWFpbCBzY2FubmVyIHVz

18 messages 2008/01/11

[#287095] IRB Keyboard Input Issues — Oliver Saunders <oliver.saunders@...>

When I press the up arrow in IRB to access history I see this:

13 messages 2008/01/11

[#287188] Stream Parsing with REXML — Marc Hoeppner <marc.hoeppner@...>

Hi (again, sort of) :)

13 messages 2008/01/12

[#287190] Callable class with block — blondinet <jblondinet@...>

Hi everyone,

12 messages 2008/01/12

[#287199] Re: gem build documentation for new gems? — Eric Hodel <drbrain@...7.net>

On Jan 12, 2008, at 07:57 AM, Giles Bowkett wrote:

11 messages 2008/01/12

[#287226] Ruby from source on Leopard excruciatingly slow internet talk — "Chris Shea" <chris@...>

Just a couple of days ago I "upgraded" from Tiger to Leopard, and the

19 messages 2008/01/13

[#287282] regualr expression (need help) — Heinrich Piard <linux@...>

Hi all,

15 messages 2008/01/13

[#287368] regular expression — Johnathan Smith <stu_09@...>

hey

15 messages 2008/01/14
[#287371] Re: regular expression — "Robert Klemme" <shortcutter@...> 2008/01/14

2008/1/14, Johnathan Smith <stu_09@hotmail.com>:

[#287414] any tricks to speed up ruby? — Roger Pack <rogerpack2005@...>

31 messages 2008/01/14
[#287423] Re: any tricks to speed up ruby? — James Britt <james.britt@...> 2008/01/14

Roger Pack wrote:

[#287583] Re: any tricks to speed up ruby? — "M. Edward (Ed) Borasky" <znmeb@...> 2008/01/16

James Britt wrote:

[#287525] Overridding A Method Via A Mixin — Andrew Stewart <boss@...>

Hi Everyone,

17 messages 2008/01/15
[#287526] Re: Overridding A Method Via A Mixin — Robert Klemme <shortcutter@...> 2008/01/15

On 15.01.2008 18:32, Andrew Stewart wrote:

[#287666] ruby annoyances ... mine is line continuation, what's yours? — "scooterm@..." <scooterm@...>

Just thinking how really smart Ruby is in most areas makes it all the

11 messages 2008/01/16

[#287720] FXRuby or Shoes? — Doug Livesey <biot023@...>

Sorry I've posted this in the generic Ruby thread, but I wanted as

14 messages 2008/01/17

[#287735] LDAP Server not connected error — Varun Goel <varun.rajeshkumar@...>

hi all i made authentication function like this

12 messages 2008/01/17
[#287752] Re: LDAP Server not connected error — "Matt Todd" <chiology@...> 2008/01/17

Pluck out the actual LDAP code into IRB and see if it works. I've not

[#287757] Ruby syntax in "respond_to do |format| line -- can clarify? — Joshua Beall <jbeall.ruby@...>

Hi All,

12 messages 2008/01/17

[#287819] passing method references in python & ruby — "rpardee@..." <rpardee@...>

Hey all,

21 messages 2008/01/18
[#287897] Re: passing method references in python & ruby — "rpardee@..." <rpardee@...> 2008/01/18

On Jan 17, 8:12 pm, Justin Collins <justincoll...@ucla.edu> wrote:

[#287914] Re: passing method references in python & ruby — "=?ISO-8859-2?Q?Rados=B3aw_Bu=B3at?=" <radek.bulat@...> 2008/01/18

SW4gcHl0aG9uIHdoZW4geW91IHVzZSBtZXRob2QgbmFtZSB3aXRob3V0IHBhcmVudGhlc2lzZXMg

[#287917] Re: passing method references in python & ruby — Justin Collins <justincollins@...> 2008/01/18

Rados梶w Buウat wrote:

[#287989] Re: passing method references in python & ruby — Robert Klemme <shortcutter@...> 2008/01/19

On 18.01.2008 20:11, Justin Collins wrote:

[#288034] Re: passing method references in python & ruby — Justin Collins <justincollins@...> 2008/01/19

Robert Klemme wrote:

[#287869] Longest Repeated Substring (#153) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

62 messages 2008/01/18
[#287931] Re: Longest Repeated Substring (#153) — yermej <yermej@...> 2008/01/18

On Jan 18, 2:38 pm, Ken Bloom <kbl...@gmail.com> wrote:

[#287932] Re: Longest Repeated Substring (#153) — "=?ISO-8859-2?Q?Rados=B3aw_Bu=B3at?=" <radek.bulat@...> 2008/01/18

T24gSmFuIDE4LCAyMDA4IDEwOjAwIFBNLCB5ZXJtZWogPHllcm1lakBnbWFpbC5jb20+IHdyb3Rl

[#287895] Thin 0.5.3 Purple Yogurt release — Marc-AndrCournoyer <macournoyer@...>

Hey all,

15 messages 2008/01/18
[#287962] Re: [ANN] Thin 0.5.3 Purple Yogurt release — "s.ross" <cwdinfo@...> 2008/01/19

This has been working so well on my Mac dev machine, I built it out on =20=

[#287973] Re: [ANN] Thin 0.5.3 Purple Yogurt release — Bob Hutchison <hutch@...> 2008/01/19

[#287984] Re: [ANN] Thin 0.5.3 Purple Yogurt release — "s.ross" <cwdinfo@...> 2008/01/19

Got it up and running ... for a while. It's running as root/root and

[#287999] Re: [ANN] Thin 0.5.3 Purple Yogurt release — Marc-AndrCournoyer <macournoyer@...> 2008/01/19

Thin runs in a single thread, no need for a mutex there.

[#287953] Looking for code to determine length of audio files — "Rick DeNatale" <rick.denatale@...>

I'm working on a project which has the requirement to automatically

11 messages 2008/01/19

[#287971] Ruby with Mac OS X — Tj Superfly <nonstickglue@...>

Hello everyone,

22 messages 2008/01/19
[#287976] Re: Ruby with Mac OS X — "Hassan Schroeder" <hassan.schroeder@...> 2008/01/19

On Jan 18, 2008 8:37 PM, Tj Superfly <nonstickglue@verizon.net> wrote:

[#287978] Re: Ruby with Mac OS X — Tj Superfly <nonstickglue@...> 2008/01/19

She can't find the run file.

[#287979] Re: Ruby with Mac OS X — "Hassan Schroeder" <hassan.schroeder@...> 2008/01/19

On Jan 18, 2008 9:25 PM, Tj Superfly <nonstickglue@verizon.net> wrote:

[#287980] Re: Ruby with Mac OS X — Tj Superfly <nonstickglue@...> 2008/01/19

Hassan Schroeder wrote:

[#287985] Re: Ruby with Mac OS X — "s.ross" <cwdinfo@...> 2008/01/19

[#288000] Re: Ruby with Mac OS X — Tj Superfly <nonstickglue@...> 2008/01/19

Okay, we've got programs running!

[#288008] Re: Ruby with Mac OS X — "Windham, Kristopher R." <kriswindham@...> 2008/01/19

not sure what you are trying to do there..

[#288009] Re: Ruby with Mac OS X — Tj Superfly <nonstickglue@...> 2008/01/19

Well, I'm using it with arrays, here's a clip of the code that I'm

[#288133] Announcing Revactor: an Actor model implementation for Ruby 1.9 — "Tony Arcieri" <tony@...>

I'm pleased to announce the initial public availability of Revactor, an

25 messages 2008/01/21

[#288258] why must I initialize this variable? — matt@... (matt neuburg)

Here's a simple variable initialization / scope question. In the

14 messages 2008/01/22

[#288290] Determine where a method is being called from? — Ben Johnson <bjohnson@...>

Is it possible to determine if a public instance method is being called

11 messages 2008/01/22

[#288303] How to improve this code? — Jair Rillo Junior <jrjuniorsp@...>

Hi guys,

16 messages 2008/01/23

[#288308] Learning to build a MUD — Sean Dolbec <helbuns@...>

13 messages 2008/01/23

[#288348] Parsing HTML / following links etc — Dan Cuddeford <dancudds@...>

Hello all,

11 messages 2008/01/23

[#288391] Scripts run using load in "for" loop run out of order — Fa Sidd <siddiqifh@...>

Hi

13 messages 2008/01/23

[#288626] Making Change (#154) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

106 messages 2008/01/25
[#288653] Re: [QUIZ] Making Change (#154) — Dominik Honnef <dominikho@...> 2008/01/25

On [Sat, 26.01.2008 00:50], Ruby Quiz wrote:

[#288656] Re: [QUIZ] Making Change (#154) — "Jes俍 Gabriel y Gal疣" <jgabrielygalan@...> 2008/01/25

On Jan 25, 2008 9:53 PM, Dominik Honnef <dominikho@gmx.net> wrote:

[#288658] Re: [QUIZ] Making Change (#154) — James Gray <james@...> 2008/01/25

On Jan 25, 2008, at 3:09 PM, Jes=FAs Gabriel y Gal=E1n wrote:

[#288692] regular expression negate a word (not character) — Summercool <Summercoolness@...>

24 messages 2008/01/26

[#288773] Extracting Data from a Webpage — Tj Superfly <nonstickglue@...>

Hello everyone.

17 messages 2008/01/27

[#288847] Treetop parser (or PEG in general?) questions — Phrogz <phrogz@...>

I've been looking for something like treetop for a while now. Very

19 messages 2008/01/28

[#288916] Final Two Quizzes — James Gray <james@...>

As most of you know, we have two Ruby Quiz problems left (http://groups.google.com/group/comp.lang.ruby/msg/6f46393932c22e49

32 messages 2008/01/28
[#288978] Re: Final Two Quizzes — fedzor <fedzor@...> 2008/01/28

[#288980] Re: Final Two Quizzes — James Gray <james@...> 2008/01/28

On Jan 28, 2008, at 5:38 PM, fedzor wrote:

[#289016] Re: Final Two Quizzes — fedzor <fedzor@...> 2008/01/29

[#289026] Re: Final Two Quizzes — James Gray <james@...> 2008/01/29

On Jan 29, 2008, at 6:33 AM, fedzor wrote:

[#289048] Re: Final Two Quizzes — "Thomas Wieczorek" <wieczo.yo@...> 2008/01/29

Thank you for the many quizzes. I came to Ruby through a blog entry

[#289051] Re: Final Two Quizzes — James Gray <james@...> 2008/01/29

On Jan 29, 2008, at 3:23 PM, Thomas Wieczorek wrote:

[#289057] Re: Final Two Quizzes — Dominik Honnef <dominikho@...> 2008/01/29

On [Wed, 30.01.2008 06:34], James Gray wrote:

[#288973] Treetop Email Parser — Phrogz <phrogz@...>

(I would post this to the treetop mailing list...except there doesn't

14 messages 2008/01/28

[#289018] Proposal/RFQ: Hash#values/keys with block — "Dirk Traulsen" <dirk.traulsen@...>

Hi!

10 messages 2008/01/29

[#289046] newbie file write problem — Lars Zeb <larzeb@...>

This is my first attempt at ruby. I've written a class (SicCode) which

15 messages 2008/01/29

[#289060] For Loop question — Mark Mr <pimea.mark@...>

ok basically i cant quite figure out how to do a for loop i want in

13 messages 2008/01/29

[#289196] counting the number of repititions in an array — Adam Akhtar <adamtemporary@...>

Hi if i want to count the number of times values are repeated in an

10 messages 2008/01/30

[#289206] Ruby Puzzle Challenge — Wyatt Greene <greenewm@...>

Write a Ruby program that prints out the numbers 1 to 100, one number

14 messages 2008/01/30

[#289210] Learn how to program — "Regnum@... Regnum@..." <regnum@...>

Hi!, i want to learn how to program.Is ruby a good option?. Thanks.

30 messages 2008/01/30
[#289351] Re: Learn how to program — longint <michael.mello@...> 2008/01/31

On Jan 30, 4:30=A0pm, "Reg...@argentina.com Reg...@argentina.com"

[#289401] Re: Learn how to program — "Michael Bevilacqua-Linn" <michael.bevilacqualinn@...> 2008/02/01

IMHO,

[#289286] can ik make this more beautifull? — Remco Hh <remco@...>

nowadays i try to improve my coding style to produce nicer and beter

17 messages 2008/01/31

[#289355] Gedankenexperiment on method duck type safety — Tim Connor <timocratic@...>

*braces for the flames to follow*

13 messages 2008/01/31

[#289364] GUI for a newbie — Matthew Borgeson <hibridmatthias@...>

Hello All-

28 messages 2008/01/31

[#289375] how do you install a local gem? — 7stud -- <bbxx789_05ss@...>

Hi,

20 messages 2008/01/31
[#289378] Re: how do you install a local gem? — Stefano Crocco <stefano.crocco@...> 2008/01/31

Alle Thursday 31 January 2008, 7stud -- ha scritto:

[#289386] Re: how do you install a local gem? — 7stud -- <bbxx789_05ss@...> 2008/01/31

Stefano Crocco wrote:

[#289388] Re: how do you install a local gem? — Stefano Crocco <stefano.crocco@...> 2008/01/31

Alle Thursday 31 January 2008, 7stud -- ha scritto:

[#289398] Re: how do you install a local gem? — 7stud -- <bbxx789_05ss@...> 2008/02/01

Stefano Crocco wrote:

Re: Making Change (#154)

From: Raffa <raffaboss@...>
Date: 2008-01-30 14:34:57 UTC
List: ruby-talk #289149
- can process inputs like "make_change 1_000_000_000_000 4 3 7 6 85 98
54  22  3423 34 509 435 243 345" in < 0.2 sec.    (in super no-
optimization / ultra-verbose mode)
- no use of recursion & stack
- no use of incremental/decremental operations
- it is not necessary to sort the input array of coins (when the input
array tends to infinite this is important)
- possibility to add coins after the processing don't affect the
previous memoizing array at all (ony incremental change). Optimal for
store/retrieve table.

- it is simple do it manual (pencil / notebook), cause all to do is to
take note of some x/y integer part and rest .

- (this code only generates the table as discussed in "manual
algorithm", useful only to perceive the relative speed/scalability of
the solution. Don't look at it! Full of boring shit)



manual algorithm:


take pencil / notebook

step 1:
trace a x/y axis, report the amount y, coins on x, eg make_change 6,
[4, 3, 1] becomes:

6|
  |
  |
  |
  |
  -------------------
    4   3   1


 step 2:
 in every matrix(x,y) cell report the integer part and the rest of the
division between the corrispondent amount/coin, in the format
"<integer part>,<rest>. If there is a rest, push it in the y axis,
too:

6| 1,2|2,0|6,0
2|
  -------------------
    4   |3  | 1


'2' is, obviously, the rest between 6 and 4

step 3:
proceed as step 2, until there are no rests to process. Where the
integer part of the division is 0, don't consider it, puts a "-" char
(nil):

6|1,2|2,0|6,0
2| -  | -  |2,0
  -------------------
    4   | 3 |   1


ok, finished. This is the result table. This has to be read in this
way:

- The number of possible solutions are the number of cells that ands
with ",0" :  2,0 at matrix(0,1); 6,0 at matrix(0,2);  2,0 at matrix
(1,2)

- If the cell containinng ",0" is a level 1 cell  [ matrix(0,x)] this
is also THE possible solution, and the formula is <integer_part> *
<coin_value> (3 *2; 6 * 1). <integer_part> represents also, obviously,
the number of coin, number_of_coins that will be used to compute the
obtimal solution

- if the ",0" is not a level 1 cell, this is only a part of the
solution, exactly the last "node", SURELY the last node of a solution.
In this case the rest in the y coordinate of the cell ('2' in the
example, below 6, the rest of 6 and 4 )  has to be considered as an
index 'linked' to a 'cell' with the identical rest.
In the matrix(0,0) there is the cell "1,2". [Geralizing, when we have
a "n,0" cell.value case, we have to now what amount we are processing,
then use it to find a "?,n" cell]. We have to do this operation n
times, until we 'parse' a cell with base ndex 0 [matrix(0,n)] (or we
can sum the amounts till total==input amount).

- at every intermediate step (previous point), we have to compute
"integer_part * relative coin, so for the example: when we found the
"2,0" cell (matrix (x,y) where x>0) we compute
    amount 2 of coin 1 +
        (find a cell with rest 2 (2 as the number of the vertical
axys) -> "1,2" of matrix(0,0)
        ... + amount 1 of coin 4

        the last "cell" is a top one then we can stop this
computation. (or: the total 2*1 + 1*4 == 6[input value]).

        we can set to 'nil' the cell so processed.

proceeding in this way all the possible 'goal' permutation are:
- 6 * 1
- 2 * 1 + 1 * 4
- 2*3
(tree as tree are the 0-rest 'cells')
the optimal solution is, obviously, the one with minor total amounts
(the third one)

that's all.



-------------------------------------------------------

more complex example

make_change 100, [20,15,9,7,5,6,4,3]

step 1: trace x/y axis, put 100 on the y, coins on the y. divide 100
for every coin and fill the cells consequently, in the format
integer_part,rest. Push every rest on the y axys

     |
100| 5,0|6,10|11,1|14,2|20,0|16,4|25,0|33,1
10 |      |
1   |     |
2   |     |
4   |     |
1   |     |
--------|----|----|----|----|----|----|---
     20|  15  |9 |   7 |   5  |  6  |  4  | 3


  step 2: proceed in the same way of step 1: divide each rest on the y
with the coin on the x and eventually push rests (if presents).
Proceed until the table is full, not more elements on the y to
process. Note: ultra-verbose / no-optimization


100| 5,0|6,10|11,1|14,2|20,0|16,4|25,0|33,1
10 | - |  -   |1,1 |  1,3| 2,0 | 1,4 | 2,2|3,1
1  |   -  |----------------------------------
2  |     |-----------------------------------
4  |     |------------------------- |1,0|1,1
1  | -----------------------------------------
1----------------------------------------------
3-------------------------------------|1,0
4---------------------------------1,0 | 1,1
2-------------------------------------------
1-------------------------------------------
1--------------------------------------------
1----------------------------------------------
--------|----|----|----|----|----|----|---
    20|15  |   9 |   7 |   5  |  6  |  4  | 3


Ok done, by hand, in a few secs, simply not?
Now, let's query this table

Q- how many solutions has this problem?
R- 7, as 7 are the cells ",O"

Q- let's go, candidate! list me these 8 kids
R-
 then... there are 3 single-step solutions (4 top-level ",0"s cells):
 1)- 5 * 20c  ---------------------------- total of 5 coins
 2)- 20 * 5c----------------------------- total of 20 coins
 3)- 25 * 4c---------------------------    total of 25 coins
 (till now the best solution is the first)

 then we have a "2,0" at matrix (1,4) so we compute 2*5c (5 is the
coin on x axys).  This is not a top-level cell then we see at the
vertical axys value (10) and we use it to find a cell with ",10"
value. Here it is at matrix(0,1) "6,10", that becomes 6*15c.
 This is a top-level cell, then we can end this path. This solution
is, then: 2*5c + 6*15. (and in effect 2*5+6*15) =100. So:
 4)- 2*5c + 6*15 -------------------- total of 8 coins

  Similarly we proceed with the "1,0" cell on (6,4):  1*4 + ..........
    the y axys value for it is 4 the we have to find a cell ",4", ok
proceed
    ops!! we have two cells with ",4"!!! the "1,4" at matrix(1,5) and
the "16,4" at (0,5). Which one we can take? mumbe mumble. let's try
with the toplevel cell (toplevel=stop computation). Then the result,
adding the previous computation is 16*6 + 1*4... =100 bingo! This is a
solution
5) 16*6+1*4 ----------------------------- total of 17 coins

and following the other path?   Not being a toplevel cell we compute
the partial (1*6)
   curr tot partial: 1*4 + 1*6
and we  watch at the y axys of "1,4",  "10", and we use this number to
find a cell ",10", ok "6,10" at matrix(0,1) [toplevel] then we add
this partial (6*15) and we have the solution

6) 1*4c + 1*6c + 6*15c--------------------- total of 8 coins
then we proceed

Q- But here we have a complication, it's not linear, you have said: no
stack, and that we can nil-lize the cells considered, here...
R- The solution is absolutely linear, it's true that there can be more
occurrences (",y") cells for a y given but let's see the entire y axys
amounts (where we push the rests). You see that the "4" case compares
2 times, and both with cells "1,0", then is true: every computed cell
can be set to null, every solution is on the board and stop.

let's proceed in speedy-mode with the last solution. we've just popped
the 1,0 at matrix(8,6) then remains the one at matrix(7,7), (y axys
amount:3)
1*3 + ...
lookup the "1,3" at matrix(1,3) [not topleve, y axys amount:10]
1*7 +
lookup for 10, found at matrix (0,1)
6*15
[top level! stop computation]

7)-   1*3c + 1*7c + 6*15c ----------------------- total of 8 coins
__________________END________________

the best solution is the number 1: 5*20

------------------------------------------------------------------------------------
Consideration & optimization

- This solution can be terribly improved, at least for memory
concerns. (eg if a division give me a rest x just computed and with
all values 'nil' we can erase it. See the 1-rest in the example).
  - I think the obtimal solution is to use an hash for the rests for
simple lookups, the value can be an array of occurrences. Or...

- The code below is terrible, full of variables not used and so on.
The purpose (for me) is to generate the table and stop. (Retrieving
the solutions is a stupid affair, and i want to think at the best data
structure for store the memoizing array [matrix is useful only for
presentation], before the last step)
--------------------------------------------------------



CODE:


Node = Struct.new(:amount, :cost, :rest,:coin)
def make_change(amount, coins = [25, 10, 5, 1])
  return [ ] if amount.zero?

  #coins = coins.sort_by { |coin| -coin }

  #@r =Hash.new # rests (indexed)

queue=[amount]
j=0

@matrix=Array.new
@row=Array.new
@amounts=Array.new
@results=Array.new
@rests=Hash.new


  loop do

    amount = queue.shift
    @amounts << amount
    return if amount == nil

    coins.each_with_index do |coin, idxCoin|

      cost=amount/coin
      #cost=nil if amount=0
      rest= amount%coin

      #puts "#{amount}-#{coin}-#{rest}"


      row="#{cost},#{rest}"
      #row="#{cost},#{coin}"
      row = nil if cost==0


      #if cost==0
       # @row << nil
      #else
      #  @row<<"#{cost},#{rest}"
      #end

      @row << row


      #aResult=
      #@results<< "#{cost}*#{coin}" if cost >0  and rest ==0
#Node.new(amount,cost,0,coin) if cost > 0 and rest ==0
      #@rests[rest] ="#{cost}*#{coin}" if cost >0  and rest >0
     #@r[rest] += Node.new(cost,coin)
     #print "- #{rest}"

     queue << rest if cost > 0 and rest >0
     #puts "(#{cost}-#{rest})"
     # p queue.size

      end
      @matrix << @row
      @row=[]

    #return if queue.size> 50

  end

end



if __FILE__ == $PROGRAM_NAME
   amount, *coins = ARGV.map { |n| Integer(n) }
   abort "Usage:  #{$PROGRAM_NAME} AMOUNT [COIN[ COIN]...]" unless
amount

   coins.empty? ? make_change(amount) : make_change(amount, coins)



@matrix.each_with_index {|x,i| puts "*amount:#{@amounts[i]}*" +
x.inspect}
  #puts @results.inspect
  #puts @rests.inspect



end


__END__






In This Thread