I have a Sudoku puzzle and I need to make sure that each row and column have each number 1 through 9. What is the easiest way of doing this? The code snippet that I have so far is below.

public static boolean rowsAreValid(int[][] array){
for(int i = 0; i < array.length; i++){
for (int j=0;j<array.length;j++){

This is my Sudoku puzzle. Note that I also need to do the same for each 3x3 section. Your help is greatly appreciated!

One way is to sum all the numbers of the row/column/section. If the sum is 45, it's probably correct.

Unfortunately that's nowhere near sensitive enough - eg the sum of nine fives is also 45. But it does inspire an idea for an improved version...
how about summing the squares of the nine numbers? I don't have the math to prove it, but I strongly suspect there's only one way to add nine perfect squares to give 285

Unfortunately that's nowhere near sensitive enough - eg the sum of nine fives is also 45. But it does inspire an idea for an improved version...
how about summing the squares of the nine numbers? I don't have the math to prove it, but I strongly suspect there's only one way to add nine perfect squares to give 285

Hehe yeah, you're right. Though the probability of getting 9x9 in a row/column/section is quite high :-)
But I admit, there's much better ways :-)

Since you are just looking for an algorithm for testing...
Set up an Array [10] and set all of the values to 0.
Traverse your row/column/3x3 taking your "found" value as the index, and set the value at THAT index to 1.
Total your Array [1..9].
If correct, your answer will be 9.
If you have less than 9, there is a number (or an index, for your purposes) missing.
Be sure to reset your Array to 0s between each iteration.

Need some help with this Array. I am trying to get the sum of the even numbers and the sum of the odd numbers using a for each loop. I know the answers to what I am trying to achive are sum of even = 84 and the sum of ...

When I execute this progammatically, I get a table with row heights much larger than when I do this manually.

Note : Sel is the Word.Selection object and the Clipboard contains an Excel Table.

public void AddClipboard()
{
Sel.PasteExcelTable(false,false, false);
var t = Sel.Tables[Sel.Tables.Count];
t.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent);
}

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...