V
Victor Reyes
[Note: parts of this message were removed to make it a legal post.]
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
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