From: Axel Etzold Date: 2008-05-06T04:39:07+09:00 Subject: Re: Help with array -------- 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 to > solve Sudoku puzzles. > Given a multidimensional array (9x9) I am trying to inspect each row and > 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 either > 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 way > 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�r Modem und ISDN: http://www.gmx.net/de/go/smartsurfer