Hello!

Does anyone have any idea about Futoshiki Puzzle Solver.
I'm new to programming and i want to make a puzzle solver in java.

Thanks

## All 11 Replies

Yes, I have an idea that I would Google it before asking others about it on a forum.

In fact, I did Google it and found a lot of results. Give it a try.

i've been through google but could'nt find anything about futoshiki code or how to implement it in java.

Sorry abt my nudging question.

Okay, I just learned what a futoshiki puzzle is - never saw one before. Fun, in that sudoku/ken-ken sort of way.

Okay, so you want to make a solver? How much Java do you know? Where would you start?

Well i won'nt say that i'm an expert but u can say i'm intermediate student of java.

Okay, then. Where would you start in trying to solve this sort of problem?

Well i know a bit about it.
i would start off with 3 2d arrays, 1st array for Grid
2nd array for Row Constraints and 3rd array for column constraint.
then fill the grid and constraints.

after that i'm stuck that how to do the main solver logic to check the rules.

if u want to have a look at my code i can post it here.

How would you apply the constraints?

(I haven't got a plan here, so I'm just going to ask you questions and see what comes out... :) )

Okay have a look at it pls if u have any question then feel free to ask me pls.

``````public class Futoshiki
public static final int GRIDSIZE = 4;

public Futoshiki()
{
squares = new int[GRIDSIZE][GRIDSIZE];
rowConstraints = new String[GRIDSIZE][GRIDSIZE - 1];
columnConstraints = new String[GRIDSIZE][GRIDSIZE - 1];

for (int row = 0; row < GRIDSIZE; row++) {
for (int column = 0; column < GRIDSIZE - 1; column++) {
rowConstraints[row][column] = " ";
}
}

//set up initial column constraints (no constraints)
for (int column = 0; column < GRIDSIZE; column++) {
for (int row = 0; row < GRIDSIZE - 1; row++) {
columnConstraints[column][row] = " ";
}
}
}``````

I'm not sure how all of this is meant to fit together. Walk me through it. I see that you have a column constraint ">" at 0,1 - what does that represent in an actual puzzle? Does that mean that 0,1 > 0,2? If grid size is 4, laid out like so:

``````1  2  3  4
5  6  7  8
9  10 11 12
13 14 15 16``````

What do your constraints specify on this grid? I'm guessing it's
5>9, 9<10, 10<11, 11<15, and so forth - oh, but that doesn't work with your initial setting of 9 to "3". So I don't know. How are you modelling this?

Okay, here's some thoughts on the problem. It looks like what you're working up is a very procedural solution - something you could do in C. Try thinking about it from an object perspective. What are the objects you want to represent here? Well, for a start, you have a Grid. A Grid has Rows and Columns, and each of those is made up of Cells. The Cells have some Constraints. A Cell has a value, or it has a set of possible values - a row or a column also has unassigned values. Putting a value in a cell affects the possible values in the row and column that that cell belongs to, and thus the possible values of the cells in that row and column.

So maybe you should try to capture some of that in a set of classes - the capitalized nouns in the preceding paragraph are potential objects. (A Constraint might not be an object, that's a question that still remains open in my head).

This will probably make you change the way you think about the problem, possibly in a useful way.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.