Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,727

Hi;

Do you know how to use them?

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

**anonimnystefy****Real Member**- From: Harlan's World
- Registered: 2011-05-23
- Posts: 16,016

yes,but it takes so long!

anyway i noticed that the program acts weirdly around ones.

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,727

Hi anonimnystefy;

I know it takes a long time. Debugging a program is a very personal thing. You have to single step through the program checking the variables after each step. Or go through your code by hand writing down what each line does. Seeing whether or not it actually does what you think it should. Then you will find the offending line. There is no other way.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

**anonimnystefy****Real Member**- From: Harlan's World
- Registered: 2011-05-23
- Posts: 16,016

but,do you know why the program won't go to the next line?

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,727

Hi;

Probably because your looping structure is not going throw every row like it is supposed to. Check your loops or your recursive subroutine.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

**anonimnystefy****Real Member**- From: Harlan's World
- Registered: 2011-05-23
- Posts: 16,016

checked the loops,seem okay.

what's recursive subroutine?

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,727

Just a term. A recursive program is one that calls itself. You must make sure you have a base case so that the recursion stops, else it will exhaust all your memory, crash or go on forever.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

**anonimnystefy****Real Member**- From: Harlan's World
- Registered: 2011-05-23
- Posts: 16,016

well do you think it is correct?

i was just confused by the subroutine part.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,727

There is definitely an error somewhere. But you will not make much progress just by looking at it. That can help clean up syntax errors but the compiler usually spots them.

Perhaps your while loops are terminating prematurely. Is your input routine working? Have you checked?

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

**anonimnystefy****Real Member**- From: Harlan's World
- Registered: 2011-05-23
- Posts: 16,016

input routine?

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,727

Yes, the one that accepts your sudoku problem.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

**anonimnystefy****Real Member**- From: Harlan's World
- Registered: 2011-05-23
- Posts: 16,016

it looks good.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,727

Not good enough! Put a print or display statement at the end of it to make sure it has the correct structure.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

**anonimnystefy****Real Member**- From: Harlan's World
- Registered: 2011-05-23
- Posts: 16,016

did it.it loaded.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,727

Which variables represent your row and columns?

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

**anonimnystefy****Real Member**- From: Harlan's World
- Registered: 2011-05-23
- Posts: 16,016

i use a two-dimensional array for the values and variables i and j to run through them.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,727

Are i and j cycling through 1 and 9? Put a display statement inside those loops and then run a test sudoku.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

**anonimnystefy****Real Member**- From: Harlan's World
- Registered: 2011-05-23
- Posts: 16,016

i inputted a sudoku and it looks like it is calculating because i cannot type anything and nothing happens when i press enter,but could it mean anything else?

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,727

Did you put output statements to see what i and j are doing?

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

**anonimnystefy****Real Member**- From: Harlan's World
- Registered: 2011-05-23
- Posts: 16,016

oh that's what you meant!

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,727

Yes, or open up the debugger and see what is happening there.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

**anonimnystefy****Real Member**- From: Harlan's World
- Registered: 2011-05-23
- Posts: 16,016

help me!

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,727

Hi anonimnystefy;

What is wrong?

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline

**anonimnystefy****Real Member**- From: Harlan's World
- Registered: 2011-05-23
- Posts: 16,016

well it's still the same problem but this time thanks to my friend i found an infinite lup in one of the procedures.it's named 'kolona':

```
program Sudoku_solver;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes
{ you can add units after this };
{$IFDEF WINDOWS}{$R Sudoku.rc}{$ENDIF}
const
max=9;
type
niz=array[1..max] of integer;
matrica=array[1..max] of niz;
var
a:matrica;
i,j,k:integer;
ok:boolean;
function red(a:matrica;i1,j1:integer):boolean;
var
j:integer;
b:boolean;
begin
b:=true;
j:=0;
while (j<=max) and (b=true) do
begin
j:=j+1;
if j<>j1 then
if a[i1][j]=a[i1][j1] then
b:=false;
end;
red:=b;
end;
function vrsta(a:matrica;i1,j1:integer):boolean;
var
i:integer;
b:boolean;
begin
b:=true;
i:=0;
while(i<=max) and(b=true) do
begin
i:=i+1;
if i<>i1 then
if a[i][j1]=a[i1][j1] then
b:=false;
end;
vrsta:=b;
end;
function kvadrat(a:matrica;i1,j1:integer):boolean;
var
i,j,k,l:integer;
b:boolean;
begin
b:=true;
case i1 of
1,2,3: begin
k:=0;
i:=3
end;
4,5,6: begin
k:=3;
i:=6;
end;
7,8,9: begin
k:=6;
i:=9;
end;
end;
case j1 of
1,2,3: begin
l:=0;
j:=3
end;
4,5,6: begin
l:=3;
j:=6;
end;
7,8,9: begin
l:=6;
j:=9;
end;
end;
while (k<=i) do
begin
k:=k+1;
while (l<=j) do
begin
l:=l+1;
if (k<>i1) and (l<>j1) then
if a[k][l]=a[i1][j1] then
b:=false;
end;
end;
kvadrat:=b;
end;
function poz(a:matrica;i,j:integer):boolean;
begin
poz:=red(a,i,j) and vrsta(a,i,j) and kvadrat(a,i,j);
end;
procedure sudoku(var a:matrica;n,i1,j1:integer;var ok:boolean);
var
i,j,k:integer;
b:boolean;
begin
i:=i1;
j:=j1;
a[i][j]:=n;
ok:=false;
if poz(a,i,j) then
begin
ok:=true;
i:=0;
j:=0;
b:=true;
while (b=true) and (i<=max) do
begin
i:=i+1;
while (b=true) and (j<=max) do
begin
j:=j+1;
writeln(i);
writeln(j);
if a[i][j]=0 then
b:=false;
end;
end;
if b=false then
begin
k:=0;
ok:=false;
while (k<=9) and not ok do
begin
k:=k+1;
sudoku(a,k,i,j,ok);
end;
end;
end;
end;
begin
writeln('Enter Sudoku: ');
for i:=1 to 9 do
begin
for j:=1 to 9 do
read(a[i][j]);
readln;
end;
for i:=1 to 9 do
begin
for j:=1 to 9 do
write(a[i][j],' ');
writeln;
end;
k:=0;
ok:=false;
while (k<=9) and not ok do
begin
k:=k+1;
sudoku(a,k,1,1,ok);
end;
if ok then
begin
writeln('Resenje je: ');
for i:=1 to 9 do
begin
for j:=1 to 9 do
write(a[i][j],' ');
writeln;
end;
end
else writeln('Sudoku cannot be solved!!!');
readln;
end.
```

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 105,727

Hi;

Answer me honestly, did you write this code or did you use what was at the Lazarus site?

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.****No great discovery was ever made without a bold guess. **

Offline