Urgently help needed with my java class?

Ok the general idea of how to solve this kind of puzzle.

Ok the general idea of how to solve this kind of puzzle. For each cell (block) create a list of numbers. Apply rules to determine which numbers cannot be the right answer.

Repeat until the entire puzzle consists of only one number per cell. That means you'll likely need a class to represent a cell, a class to represent the entire puzzle, and a class to represent the greater than rule(s). Initially, you will be concerned with setting up the puzzle, the code will look something like this: Construct a 2d array 5x5 of cells.

Each cell initially has all five numbers as possibilities. Read in the map, and if it has a number corresponding to a particular cell, then in your map, set the cell to only have that number as a possibility. Read in the rules and make classes representing each rule.

Enter the "elimination loop" which will inspect the puzzle. It should apply rules to the puzzle and then with those rules reduce the number of possibilities in the cells. After a rule has been applied, evaulate the whole puzzle to see if it is completed.

If it is, exit the "elimination loop", if not cycle through the loop again. As there are fewer possibilities, the puzzle will likely give hints for even more reduction to its solution. I've looked at your code, but to tell you the truth, it's not packaged for others to use easily.

For example, there are no scripts to launch the application, and it is not clear if you provided a Solver at all. Much of the code appears to be the assignment code. Good luck, and hopefully you asked early enough to actually do the work described above.

Naturally, you will have to fit this within the constraints laid out by your professor. When you get stuck, remember that there's more than one way to solve any problem, so use your imagination and experiment on how to get around a particular road block.

Ok, I found your added code. I'll look at it as time permits. – Edwin Buck Apr 2 at 17:20 Ok, a few things I found.

First, you seem to have your "rules" backwards. If I see, 1,2I think you got the greater than reversed. Second, you are somehow considering numbers greater than the maximum number the puzzle can support.

In other words, if the puzzle is 4x4; then you can only solve it with numbers 1 through 4, yet you attempt to put a 5 value into one of the squares. – Edwin Buck Apr 3 at 3:04 I've noticed that often you have hard coded integers for loops and such, that's never a good thing. If you are looping over the array, then you should loop from 1 to the size of that row or column.

This allows your loop to handle all inputs, not just 4x4 inputs. – Edwin Buck Apr 3 at 3:38 In many sections of your code, you use arrays sufficent to hold 10 values, which you populate with choices 1 through 9. It's a complete waste of effort because you don't have 10 choices, and choices 1 through 9 are not always available to you.

You need to base the number of choices off the size of the puzzle, a 6x6 puzzle should build up a number of choices of 1 through 6 because you can't use the number 7 and have a successful solution – Edwin Buck Apr 3 at 4:01 You annotate each cell with a property possval, which contains possible values.It seems that you overwrite this with subsequent calls, so the number of possible values never decreases. – Edwin Buck Apr 3 at 4:15.

I had to make a futoshiki puzzle with GUI and a solver for my first year on CS too . The solver is quite simple ( at least the way I implement it ). Its a boolean that calls it self recursively .

I check the current state of the puzzle . Next if its legal I will try to put a number in the empty square and then call the method again. The code is about 10 lines so you arent looking for anything complicated just make sure you understand what you must do and you will work it out.

Oh could you please take a look at my code there under package MyFutoshikiSolver class there and at least point out what I did wrong there. Appreciate for any help! – Josh4 Apr 3 at 2:43 Well I tried to find out whats wrong but im only second year and your code seems unnecessarily complicated.

For example adding all possible numbers to a list then removing some of them then starting to test them. That could all be 1 step. If you still havent made it work correctly I can post an explanation of the logic of my solver.

– latusaki Apr 3 at 23:18.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions