return 0; } the board variable is basically the 9 by 9 numbers in a sudoku puzzle. if the number on the puzzle is greater than 9 it returns -5 (meaning it's wrong) and if it's less than 1 it returns -5. and if the solution is correct it returns 0 (meaning no errors). That's basically what i'm trying to do, but i don't know how to assign the [9] [9] to it without it getting messed up. And i'm also not to sure how to do the rows, columns and the 3x3 grid as well, because i'm not too sure how to create their variables, do i use the board variable to do it? If someone could please help me with this it would be much appreciated. i've been trying to do this for the past day now and this is my 3rd attempt.
Leo Adams
Honestly you're better off going to Reddit or StackOverflow. This place will just shit on you for not using their personal flavor of programming language.
Christian White
We would help you more by refusing to do your homework for you
Noah Diaz
i'm not asking you to do it for me, i just need a point the right direction. Please, i already have the vague idea on what to do, i just need help with assigning the rows and variables
Liam Phillips
any sub reddit that are active?
Samuel Brooks
Why assign rows and variables? You already have everything you need. Better go read about two dimensional arrays and stop copy pasting from da stak.
Caleb Peterson
> i've been trying to do this for the past day now and this is my 3rd attempt Kys worthless piece of shit. No really if you want to have a fullfilling life you should try and get a job at McDonald's. That's something worth of your intelligence.
Ian Moore
>returns -5 kill yourself
Matthew Williams
Drop out of whatever shitty course is making you do this and read HtDP or SICP
Adrian Perry
which do you suggest and why? from what I read, HtDP is a bit more entry level, but fundamentally covers similar topics...
Is it a waste of time to read both?
Anthony Torres
? ? I don't fucking know. Half the people here don't go on reddit, and the other half would never tell you they do.
Michael Sanchez
Jesus dude, not called for. Everyone has goes through a period where they're still beginners. You can't know everything at once, he just needs to practice. Don't insult others just because your insecure.
Noah Thomas
I can't help you, but you could've avoided some of the 'kys'...
first off, don't start off with "people on Sup Forums", this is a cringeworthy flag that you are a newfag, secondly, try and post this questions on /sqt/...
Aaron Hernandez
>people are unironically discussing Reddit now
Dominic Young
[ code ] tags [ / code ] o d e ] tags
Sebastian Green
>and the other half would never tell you they do. lol so hard
Andrew Richardson
>Being loyal to a particular site with many very different communities >Being this much of a cuck
Chase Allen
kysasap
Liam Morgan
>why don't you do my homework for me???? This place is bullshit I' going and I'm never coming back I'M SERIOUS!!!!
Luis Perry
First of all. Choose better names. You are making a class for a soduko board, the verification is just a function that relates to the board. I assume you are going to solve the soduko board sometime during the class, so you might start with that assumption. Say you have an easy board, you can solve it through verification: Each field on the board contains 9 options. By running verify, you can reduce the options so there isn't a number in the same row, same column or same 3x3 square. either your verification should check if it is valid or it should reduce the options as well. Therefore, I would make the board 3 dimensional if you want to solve it as well.
Now as for your function, you return an int for no good reason. You even have to explain what the values mean, it is a very bad model to use if the only outcome is true or false. This leads us back to the naming of the function. "verify" isn't really a question that you can answer with true or false. If you choose a name like "isValid", there wouldn't be any confusion. As for the functionality, checking whether the numbers are within 1-9 (INCLUDING, not EXCLUDING) is not the point of a soduko. You need to check if the numbers are unique.
Make a few test boards to see if your function works.
Alexander Foster
People with this attitude deserve to work in Mickey dees. Unless your black or a minority you won't get hired unless you shut up and put the work in
Tyler Wood
>returns -5 -1 is the generally accepted sentinel value. -5 will work fine too, but it's bad practice to use a random number of your choice here. Stick to -1. Or better yet have verify() return a boolean true or false instead.
I'm going to move forward under the assumption that "Sudoku checker" means you're trying to validate that this.board is a valid solved Sudoku puzzle
>i don't know how to assign the [9] [9] to it without it getting messed up Not sure what you mean by this. You don't know how to define the values in the board array?
>because i'm not too sure how to create their variables You can use board like you are now. You'll also need a variable to track the sum of the numbers in the row/column/sub-grid to ensure they add up to 45 (1+2+...+9). Think about how you would modify your for loops so that you only check the first 3x3 section of the grid, adding the value you find at boards[i][j] each time, then comparing the total to 45.
Cooper Morris
It's easy. Just make sure that the sum of each row is 1+2+...+9, and also, each sub-square has also the sum 1+2+...+9. If these conditions are met, return True, else return False.
Joseph Walker
private boolean checkSudokuStatus(int[][] grid) { for (int i = 0; i < 9; i++) {
int[] row = new int[9]; int[] square = new int[9]; int[] column = grid[i].clone();
private boolean validate(int[] check) { int i = 0; Arrays.sort(check); for (int number : check) { if (number != ++i) return false; } return true; }
Chase Reed
what are you stuck on?
if you need a algorithm to put some numbers in the 3x3, i did row*3 + column.
Noah Miller
The thing with HtDP is it takes you through a set of DSLs that incrementally introduce you to features of Racket (aka PLT Scheme) instead of dumping the whole language on you at once. That and it's written in plainer language. And no, it's absolutely not a waste of time to read both books.
Matthew Campbell
It's funny how the same thing that makes java good for big projects is a nuisance for little pet codes / learning the language
a type error? > board is int[][] > candiSol is String?
how to check for valid !9 permutations? > int arr[10] = 0's > loop > arr[val] = arr[val] + 1; > loop > arr[val] == 1;