Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Fucking program...

Name: Anonymous 2006-09-24 22:50

Dear /prog/,
I'm wirting a program for my CS class which solves Hitori puzzles (not unlike sudoku, see http://en.wikipedia.org/wiki/Hitori for example.) Now, it seems like it should be a damn simple program to write in java, but I'm absolutely fucked when it comes to getting part of it to work. My program will get the puzzle down to one of each # per row/column, but I can't for the life of me get a properly working algorthm to ensure that all whitespace is connected. Please 4chan, would anyone be willing to help a brother out, by finding what's wrong with my code? I'll post it if anyone's willing.

Name: Anonymous 2006-09-25 5:11

Ok you have a problem in the way checkContinuity recurses - it calls itself in such a way that it doesn't terminate.

The breaksContinuity method calls checkContinuity(0) first of all (when i is 0). Upon reaching this:

if(location+1<puzzleSize&&checkContinuity(location+1)) ...

checkContinuity(1) is called, which then reaches this statement:

if(location-1>=0&&checkContinuity(location-1)) ...

and calls checkContinuity(0), which causes checkContinuity(1) to be called, and so on. There is your infinite loop.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List