Have the JVM solve Sudoku

Preface

This page is like a sequel to Notes on fumbling development using JavaFX. The idea is to make the article closer to the content. To be honest, there was a lot of waste in designing the class, so I said that I updated the article when starting NumberPlaceSolver 2.0. The display has been completely eliminated. I will not write the previous specifications here, so please read the original article.

What you are trying to make

Things that can be solved by Sudoku. At school free assignment.

Environment and others

Java (8) ... has been learned to some extent (inexperienced) As an IDE, instructor Onunume's intelliJ IDEA (ver.3.2) It seems that the UI has changed a little with the recent addition of Appde. The refactoring function was too strong, and it was itchy in various places when I used eclipse.

About some simple correspondence

--The fx: id specified in FXML gets angry if you do not specify @ FXML immediately before in Controller. If you don't attach it in delimiter units, you will get angry. --If you pass the array y to the array x like x = y (tentative name), it will be passed by reference value (described later). x and y are names that refer to the same object. --If you want to treat it as another new object, use the clone method and set x = y.clone (). --This problem compares the reference value of an object with connecting another object containing the same string of type String with the conditional operator == (that is, str == new String (str)). Reminds me that false is returned for this. However, the String type itself seems to have some special specifications, so should we handle it with care? --In Sudoku, in addition to rows and columns, 3x3 subRegions also prohibit duplication. I wrote a formula to follow this 3x3 group in order.

for (int i = 0; i < 9; i++) for (int j = 0; j < 9; j++) {
  int idev3= i/3 , jdev3= j/3 ;

  int x= idev3 * 3 + jdev3 ,
      y= i % 3 * 3 + j % 3 ;

  subRegion[x][y] = cell[i][j]
//Since the inverse function becomes a similar expression (I forgot the name),[i][j]When[x][y]Even if it is reversed, it serves the purpose.
//  subRegion[i][j] = cell[x][y];
}

--About length of the two-dimensional array x = new Object [i] [j]. --x.length is ʻi --x [0] .length is j. However, if ʻi == 0, it throws ʻArrayIndexOutOfBoundsException.

In manipulating shared data

In Java, pointers in C language are called "reference variables" or "reference values".

I want to make each region store the reference value so that it can be processed with only the data group of the cell for one table. In other words, I want to change the data of cells existing in the table by the operation from the region.

The following is an image diagram that does not connect

Cell Region image

Preface to the design description of each class

I wrote it at the beginning, and if you read the contents, you will understand it, and since you should have written it in the profile, you can understand it,

I'm a beginner of crunchy. No matter what you do, I think it will be a poor one, so please forgive me. (Comments such as criticism and improvement measures are welcome.) Even beginners of the same class should not use this as a reference. Even if you use it as a reference, let's get the opinion of the educator.


[Same location in the original article](https://qiita.com/UFOnian/items/67cd4f6f8c71e178f06b#%E5%90%84%E3%82%AF%E3%83%A9%E3%82%B9%E3%81 % AE% E8% A8% AD% E8% A8% 88% E8% AA% AC% E6% 98% 8E% E3% 81% AE% E5% 89% 8D% E6% 9B% B8% E3% 81% 8D ) To the back, preferably as a failure story or as a comparison target I don't want you to read it (I want to write it so that I can understand it without reading it (desire))

So far, the part that seems to be essential although it is the same as the original article.

Future policy

Create an improved version based on the design already written.

What you want to include

--Class design review **: ** Delete methods that seem to be useless. --Temporary placement with multiple threads **: ** Increase processing speed by performing temporary placement processing with multiple threads --Prepared a static board to manage the entire data **: ** Share "denyed" information with all threads

Recommended Posts

Have the JVM solve Sudoku
Scala runs on the JVM
Let's solve the roman numerals
Let's solve the FizzBuzz problem!
How the JVM JIT compiler works