If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Programming Issue...

A while back I worked on a sudoku game with a help of a lot of the guys on the forum. I've got a weird bug that I need some help with.

Basically I worked on this game in the wrong way. I had to create the game using a css grid. The problem I had is that I made it without generating it through Javascript. Not a huge problem at first, but it was only after I generated the puzzles that I saw the big problem. Instead of generating puzzles by rows it generated them by every 9x9 square. This meant that not only the generation of puzzles was wrong, but comparing them to the solution would also be wrong, along with any hint method I put in. It took a long three weeks+ but I fix two of those. However coding the hint method has made me realise that my approach was awful.

My question is.

Do I carry on with trying to fix something that shouldn't have been this broken from the start? I'm going to pose the hint code below. Please don't scream.

Or

Do I wipe this thing from the earth and start again? if you think it's easier for me to simply just delete everything, and generate the grid via script then I'm going to need some help, how would I go about doing this?

Just quickly glimpsing,
You could have these defined else where, but I'll show you variables that are not declared any where:
hint
i

Also, do not use infinite if statements, that is terrible. At least use the switch statement likewise:
switch(i) {
case '1': code;
break;
case '2' etc..
default: alert("This is if not cases are matched");
}

I can easily tell you are avoiding function parameters as best as possible lulz.
If you learn how to structure code better, it can really help you out, as you are more likely to run into more issues with infinite if statements, which is essentially deciding boolean for comparing two things, which can easily be flagged in a function.

Also, getting an element by tag name ['input'] is relating to all input tags. So if you have multiple input tags they all get set to the value you are assigning, use ById("id") to be specific. (In the case you have multiple input fields as I presume you do).

Again, look into passing parameters in functions, otherwise this whole segment of code makes you look like you're trying to attempt first grade math and applying it to calculus based physics.

Just quickly glimpsing,
You could have these defined else where, but I'll show you variables that are not declared any where:
hint
i

Also, do not use infinite if statements, that is terrible. At least use the switch statement likewise:
switch(i) {
case '1': code;
break;
case '2' etc..
default: alert("This is if not cases are matched");
}

I can easily tell you are avoiding function parameters as best as possible lulz.
If you learn how to structure code better, it can really help you out, as you are more likely to run into more issues with infinite if statements, which is essentially deciding boolean for comparing two things, which can easily be flagged in a function.

Also, getting an element by tag name ['input'] is relating to all input tags. So if you have multiple input tags they all get set to the value you are assigning, use ById("id") to be specific. (In the case you have multiple input fields as I presume you do).

Again, look into passing parameters in functions, otherwise this whole segment of code makes you look like you're trying to attempt first grade math and applying it to calculus based physics.

You cannot use boolean expressions in switch statement, so you must do so before hand. I'm seeing this: for { if{ if { } } if { { ..etc

._.
lulz

have your flags become set in the for loop (boolean) then execute the switch statement.. After you see how that works, you can even reduce the equation down more

example:
for(stuf) {
//for each if statement expression, give an abstract variable to it. like i<9 = var a ..soo
var flagOne = i < 9;
//this shows up as true or false
var boolOne = new Boolean(flagOne);
switch (boolOne) {
case 'true': var flagTwo = i
other code if you figure some other tricks out
break;
}

and so forth.. now you can use that first layer of truth tables, you even get more control as well. Then you can proceede to make the next set of truth tables that if true will output your desired content. just make sure to set the varibles to work in the right scopes

if statements show poor knowledge of coding, only use for small things. not the whole page

But I suggest actually reworking this into a more logical spawn so you can control the hint output better. Likewise, set the flags when you set the grid so you do not have to re-evaluate it in the hint.