Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °
| |
|
|
You are not logged in. #51 2011-10-06 06:34:26
Re: Another programming problem!!!i wrote it.i would never lie to you. The limit operator is just an excuse for doing something you know you can't. “It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman “A secret's worth depends on the people from whom it must be kept.” ― Carlos Ruiz Zafón #52 2011-10-06 06:35:46
Re: Another programming problem!!!Okay, did you fix the infinite loop? In mathematics, you don't understand things. You just get used to them. Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means. 90% of mathematicians do not understand 90% of currently published mathematics. #53 2011-10-06 06:37:48
Re: Another programming problem!!!yes i did. The limit operator is just an excuse for doing something you know you can't. “It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman “A secret's worth depends on the people from whom it must be kept.” ― Carlos Ruiz Zafón #54 2011-10-06 06:38:36
Re: Another programming problem!!!Copy the code that you think is causing the problem. The minimum amount please. In mathematics, you don't understand things. You just get used to them. Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means. 90% of mathematicians do not understand 90% of currently published mathematics. #55 2011-10-06 06:40:08
Re: Another programming problem!!!i don't know the code where the problem is in.if i did i would probably know how to correct it.but i don't The limit operator is just an excuse for doing something you know you can't. “It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman “A secret's worth depends on the people from whom it must be kept.” ― Carlos Ruiz Zafón #56 2011-10-06 06:41:52
Re: Another programming problem!!!You said you fixed it. Where did you do the fixing? Did your friend tell you about where? In mathematics, you don't understand things. You just get used to them. Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means. 90% of mathematicians do not understand 90% of currently published mathematics. #57 2011-10-06 06:42:51
Re: Another programming problem!!!no i fixed the infinite loop problem.but there is still this one. The limit operator is just an excuse for doing something you know you can't. “It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman “A secret's worth depends on the people from whom it must be kept.” ― Carlos Ruiz Zafón #58 2011-10-06 06:47:41
Re: Another programming problem!!!Do you know the part of the code that handles the rows? In mathematics, you don't understand things. You just get used to them. Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means. 90% of mathematicians do not understand 90% of currently published mathematics. #59 2011-10-06 06:53:38
Re: Another programming problem!!!part of the code in the sudoku procedure finds the first element equal to 0,because the spaces are represented that way. Code: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;but i don't see the problem. Last edited by anonimnystefy (2011-10-06 06:53:57) The limit operator is just an excuse for doing something you know you can't. “It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman “A secret's worth depends on the people from whom it must be kept.” ― Carlos Ruiz Zafón #60 2011-10-06 06:58:24
Re: Another programming problem!!!That looks like code to print the answer.
I do not think you are understanding me. Looking can only find syntax errors. The compiler finds them too. To find logic errors you have to single step through a piece of code. In mathematics, you don't understand things. You just get used to them. Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means. 90% of mathematicians do not understand 90% of currently published mathematics. #61 2011-10-06 07:02:16
Re: Another programming problem!!!i do it in my head.and i understand you perfectly. The limit operator is just an excuse for doing something you know you can't. “It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman “A secret's worth depends on the people from whom it must be kept.” ― Carlos Ruiz Zafón #62 2011-10-06 07:08:20
Re: Another programming problem!!!That is where you are not following me. I say there is only 2 ways and you try to come up with a third way! But let's forget that for right now. In mathematics, you don't understand things. You just get used to them. Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means. 90% of mathematicians do not understand 90% of currently published mathematics. #63 2011-10-06 07:11:36
Re: Another programming problem!!!you said to print out values of i and j. The limit operator is just an excuse for doing something you know you can't. “It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman “A secret's worth depends on the people from whom it must be kept.” ― Carlos Ruiz Zafón #64 2011-10-06 07:13:12
Re: Another programming problem!!!But you did not answer the question, are those the only two lines you put in? In mathematics, you don't understand things. You just get used to them. Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means. 90% of mathematicians do not understand 90% of currently published mathematics. #65 2011-10-06 07:15:32
Re: Another programming problem!!!i don't really understand the question. The limit operator is just an excuse for doing something you know you can't. “It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman “A secret's worth depends on the people from whom it must be kept.” ― Carlos Ruiz Zafón #66 2011-10-06 07:16:56
Re: Another programming problem!!!Code: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;In the above routine which is what I told you to put in? In mathematics, you don't understand things. You just get used to them. Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means. 90% of mathematicians do not understand 90% of currently published mathematics. #67 2011-10-07 02:36:14
Re: Another programming problem!!!hi bobbym Code: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:=1;
while (j<=max) and (b=true) do
begin
if j<>j1 then
if a[i1][j]=a[i1][j1] then
b:=false;
j:=j+1;
end;
red:=b;
end;
function kolona(a:matrica;i1,j1:integer):boolean;
var
i:integer;
b:boolean;
begin
b:=true;
i:=1;
while (i<=max) and (b=true) do
begin
if i<>i1 then
if a[i][j1]=a[i1][j1] then
b:=false;
i:=i+1;
end;
kolona:=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:=1;
i:=3;
end;
4,5,6: begin
k:=4;
i:=6;
end;
7,8,9: begin
k:=7;
i:=9;
end;
end;
while (k<=i) and (b=true) do
begin
case j1 of
1,2,3: begin
l:=1;
j:=3;
end;
4,5,6: begin
l:=4;
j:=6;
end;
7,8,9: begin
l:=7;
j:=9;
end;
end;
while (l<=j) and (b=true) do
begin
if (k<>i1) or (l<>j1) then
if a[k][l]=a[i1][j1] then
b:=false;
l:=l+1;
end;
k:=k+1;
end;
kvadrat:=b;
end;
function poz(a:matrica;i,j:integer):boolean;
begin
poz:=red(a,i,j) and kolona(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:=1;
b:=true;
while (b=true) and (i<=max) do
begin
j:=1;
while (b=true) and (j<=max) do
begin
writeln(i);
writeln(j);
if a[i][j]=0 then
b:=false
else j:=j+1;
end;
if b=true then
i:=i+1;
end;
if b=false then
begin
k:=1;
ok:=false;
while (k<=max) and not ok do
begin
sudoku(a,k,i,j,ok);
k:=k+1;
end;
end;
end;
end;
begin
writeln('Unesite 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 se ne moze resiti!!!');
readln;
end.but this time the problem seems to be that the functions for checking if a number can be in the given row column and square aren't doing what they should.those are 'red','kolona' and 'kvadrat'. The limit operator is just an excuse for doing something you know you can't. “It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman “A secret's worth depends on the people from whom it must be kept.” ― Carlos Ruiz Zafón #68 2011-10-07 02:53:27
Re: Another programming problem!!!Hi; In mathematics, you don't understand things. You just get used to them. Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means. 90% of mathematicians do not understand 90% of currently published mathematics. #69 2011-10-07 04:22:03
Re: Another programming problem!!!'Put some write statements in there.' - why? The limit operator is just an excuse for doing something you know you can't. “It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman “A secret's worth depends on the people from whom it must be kept.” ― Carlos Ruiz Zafón #70 2011-10-07 04:49:35
Re: Another programming problem!!!i and j are called indices. Make sure you are cycling through every element of the matrix. In mathematics, you don't understand things. You just get used to them. Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means. 90% of mathematicians do not understand 90% of currently published mathematics. #71 2011-10-07 04:57:43
Re: Another programming problem!!!i tested the first few elements,but this problem seems like it's something to do with nines. The limit operator is just an excuse for doing something you know you can't. “It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman “A secret's worth depends on the people from whom it must be kept.” ― Carlos Ruiz Zafón #72 2011-10-07 06:59:46
Re: Another programming problem!!!When is the first error? In mathematics, you don't understand things. You just get used to them. Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means. 90% of mathematicians do not understand 90% of currently published mathematics. #73 2011-10-08 00:36:24
Re: Another programming problem!!!hi bobbym The limit operator is just an excuse for doing something you know you can't. “It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman “A secret's worth depends on the people from whom it must be kept.” ― Carlos Ruiz Zafón #74 2011-10-08 00:41:42
Re: Another programming problem!!!Hi; In mathematics, you don't understand things. You just get used to them. Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means. 90% of mathematicians do not understand 90% of currently published mathematics. #75 2011-10-08 00:45:42
Re: Another programming problem!!!hi The limit operator is just an excuse for doing something you know you can't. “It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman “A secret's worth depends on the people from whom it must be kept.” ― Carlos Ruiz Zafón |