Author Topic: [Calc] Sudoku Solver  (Read 1732 times)

0 Members and 1 Guest are viewing this topic.

Offline Huntondoom

  • Baron
  • ****
  • Posts: 856
  • Cookies: 17
  • Visual C# programmer
    • View Profile
[Calc] Sudoku Solver
« on: June 18, 2011, 01:30:38 pm »
this thing Exists of 2 Scripts
one that is to write into the matrix that looks like a Sudoku
the Other is the Actual Sudoku Solver


There is 1 symbol missing since I can't find it on my computer
I have replace this symbol:


with the following Char "»"


Sudoku Writer(524 Bytes):
Code: [Select]
Lbl R
AxesOff:BG-None
Sum (Dim Mat A)≠18»{9,9}→Dim Mat A
Lbl P
Cls
Text 57,1,"clr"


For 1→X To 9
For 1→Y To 9
Mat A[X,Y]»Text 7Y-6,7X+25,Mat A[X.Y]
Not Mat A[X,Y]»Text 7Y-6,7X+25,"-"
Next
Next
1→X:1→Y
Lbl 0
Text 7Y-6,7X+25,"-"
Do:LpWhile GetKey=0
GetKey
Mat A[X,Y]»Text 7Y-6,7X+25,Mat A[X,Y]
Not Mat A[X,Y]»Text 7Y-6,7X+25,"-"
Ans=37»Y<9»Y+1→Y
Ans=28»Y>1»Y-1→Y
Ans=39»X>1»X-1→X
Ans=27»X<9»X+1→X
Ans=71»0→Mat A[X,Y]
Ans=72»1→Mat A[X,Y]
Ans=62»2→Mat A[X,Y]
Ans=52»3→Mat A[X,Y]
Ans=73»4→Mat A[X,Y]
Ans=63»5→Mat A[X,Y]
Ans=53»6→Mat A[X,Y]
Ans=74»7→Mat A[X,Y]
Ans=64»8→Mat A[X,Y]
Ans=54»9→Mat A[X,Y]
Ans=79»{9,9}→Dim Mat A
Ans=79»Goto R
Ans=29»Goto P
Goto 0

Sudoku Solver(1364 Bytes):
Code: [Select]
{9,9}→Dim Mat B
{9,9}→Dim Mat C
Mat A→Mat B
AxesOff:BG-None:Cls
StoPict 1
Lbl P
'Controle
Text 1,1,"C"
For 1→X To 9
For 1→Y To 9
Mat A[X,Y]»Mat A[X,Y]≠Mat B[X,Y]»Mat A[X,Y]→Mat B[X,Y]
Mat B[X,Y]»Text 7Y-6,7X+25,Mat B[X,Y]
Not Mat B[X,Y]»Text 7Y-6,7X+25,"-"
Next
Next
StoPict 1
'Process
For 1→I To 9
Lbl R
For 1→X To 9
For 1→Y To 9
Mat C[X,Y]»Mat B[X,Y]≠I»Text 7Y-6,7X+25,"x"
Next
Next
{9,9}→Dim Mat C
Cls:RclPict 1
Text 7,1,I
Text 1,1,"P"
For 1→X To 9
For 1→Y To 9
Mat B[X,Y]»1→Mat C[X,Y]
If Mat B[X,Y]=I
Then
For 1→A To 9
1→Mat C[X,A]
1→Mat C[A,Y]
Next
1→A
1→B
X≥4»4→A
Y≥4»4→B
X≥7»7→A
Y≥7»7→B
For A→G To A+2
For B→H To B+2
1→Mat C[G,H]
Next
Next
IfEnd
Next
Next


'Kijken
Text 1,1,"K"
For 1→S To 9 Step 3
For 1→T To 9 Step 3
0→C
For S→X To S+2
For T→Y To Y+2
Mat C[X,Y]»C+1→C
Next
Next
If C=8
Then
For S→X To S+2
For T→Y To Y+2
Mat C[X,Y]=0»I→Mat B[X,Y]
Mat C[X,Y]=0»Text 7Y-6,7X+25,I
Mat C[X,Y]=0»Goto R
Next
Next


IfEnd


Next
Next
Next


For 1→S To 9 Step 3
For 1→T To 9 Step 3
0→C
For S→X To S+2
For T→Y To Y+2
Mat C[X,Y]=0»C+1→C
Next
Next
If C≤3
Then
0→B
0→C
For S→X To S+2
For T→Y To Y+2
Mat B[X,Y]=0»1=B»1→C
Mat B[X,Y]=0»0=B»1→B
Next
Next
If 1=B And C=0
Then
For S→X To S+2
For T→Y To Y+2
If Mat B[X,Y]=0
Then
For 1→A To 9
1→Mat C[X.A]
Next
IfEnd
Next
Next
IfEnd


0→B
0→C
For T→Y To T+2
For S→X To S+2
Mat B[X,Y]=0»1=B»1→C
Mat B[X,Y]=0»0=B»1→B
Mat B[X,Y]=0»Break
Next
Next
If 1=B And C=0
Then
For T→Y To Y+2
For S→X To S+2
If Mat B[X,Y]=0
Then
For 1→A To 9
1→Mat C[A,Y]
Next
IfEnd
Next
Next
IfEnd
IfEnd
Next
Next


'Kijken
Text 1,1,"K"
For 1→S To 9 Step 3
For 1→T To 9 Step 3
0→C
For S→X To S+2
For T→Y To Y+2
Mat C[X,Y]»C+1→C
Next
Next
If C=8
Then
For S→X To S+2
For T→Y To Y+2
Mat C[X,Y]=0»I→Mat V[X,Y]
Mat C[X,Y]=0»Text 7Y-6,7X+25,I
Mat C[X,Y]=0»Goto R
Next
Next
IfEnd
Next
Next
Goto P
« Last Edit: June 18, 2011, 01:31:22 pm by Huntondoom »
Aslong as you are connected to the internet, you'll have no privacy

Advanced Internet Search
Clean Up!

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: [Calc] Sudoku Solver
« Reply #1 on: June 18, 2011, 02:01:34 pm »
Looks like gibberish :D
Is this the language? http://isthe.com/chongo/tech/comp/calc/calc-whatis.html

Offline Huntondoom

  • Baron
  • ****
  • Posts: 856
  • Cookies: 17
  • Visual C# programmer
    • View Profile
Re: [Calc] Sudoku Solver
« Reply #2 on: June 18, 2011, 05:50:58 pm »
no its a script language on the calculator it self,
Ill make a tutorial
Aslong as you are connected to the internet, you'll have no privacy

Advanced Internet Search
Clean Up!