From: Victor Reyes Date: 2008-05-06T08:15:16+09:00 Subject: Re: Help with array ------=_Part_19436_12991065.1210029317086 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Axel, I will do so. Thank you Victor On 5/5/08, Axel Etzold wrote: > > > -------- Original-Nachricht -------- > > Datum: Tue, 6 May 2008 04:06:01 +0900 > > Von: "Victor Reyes" > > An: ruby-talk@ruby-lang.org > > Betreff: Help with array > > > Team, > > > > On my never ending saga to learn Ruby, I am trying to write a program t= o > > solve Sudoku puzzles. > > Given a multidimensional array (9x9) I am trying to inspect each row an= d > > each column as follows: > > > > Assume the following represents a typical row in my 9x9 array: > > > > *Row*** > > > > 23 > > > > 689 > > > > 7 > > > > 12345689 > > > > 1359 > > > > 9 > > > > 2468 > > > > 359 > > > > 235 > > Row > > 23 > > 689 > > 7 > > 12345689 > > 1359 > > 9 > > 2468 > > 359 > > 235 > > Row > > > > 23 > > > > 689 > > > > 7 > > > > 12345689 > > > > 1359 > > > > 9 > > > > 2468 > > > > 359 > > > > 235 > > > > Row > > 23 > > 689 > > 7 > > 12345689 > > 1359 > > 9 > > 2468 > > 359 > > 235 > > Furthermore, assume the following is a typical column: > > > > *Column*** > > > > 23 > > > > 689 > > > > 7 > > > > 12345689 > > > > 1359 > > > > 9 > > > > 2468 > > > > 359 > > > > 235 > > I would like to be able to count the frequency of each digit on eithe= r > > row > > or column, separate of course! > > > > *Number*** > > > > 1 > > > > 2 > > > > 3 > > > > 4 > > > > 5 > > > > 6 > > > > 7 > > > > 8 > > > > 9 > > > > *Frequency*** > > > > 2 > > > > 4 > > > > 5 > > > > 2 > > > > 4 > > > > 3 > > > > 1 > > > > 3 > > > > 5 > > > > I can do this with some ugly looking and probably inefficient loop. > > However, > > Ruby has so many tools and "tricks" that perhaps there might be some wa= y > > of > > doing this quicker and easy to understand. > > > > Any help will be greatly appreciated! > > > > Thank you > > > > Victor > > Dear Victor, > > one nice feature of the Ruby list is its quiz contest. > You can have a look at different solution proposals for solving > Sudokus here: > > > http://www.rubyquiz.com/quiz43.html > > Best regards, > > Axel > -- > Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! > Ideal f=FCr Modem und ISDN: http://www.gmx.net/de/go/smartsurfer > > ------=_Part_19436_12991065.1210029317086--