SudokuCracker 1.0

Post your working scripts, libraries and tools
User avatar
oldbrother
Posts: 174
Joined: 23 Oct 2013, 05:08

SudokuCracker 1.0

04 Feb 2015, 21:20

The code is badly written, but it works. :)
1.jpg
1.jpg (99.64 KiB) Viewed 3420 times
2.jpg
2.jpg (147.34 KiB) Viewed 3420 times

Code: Select all

; Sudoku Cracker 1.0 by Oldbrother

pp=0
Lsize=2
trylist=0
trylistN=0
TargetWin =SudokuCracker 1.0
Gui, Font, s15 cDefault
Gui, Add, Edit, x16 y10 w30 h30 Limit1  Va0000,   
Gui, Add, Edit, x46 y10 w30 h30 Limit1  Va0001,  
Gui, Add, Edit, x76 y10 w30 h30 Limit1  Va0002,  
Gui, Add, Edit, x108 y10 w30 h30 Limit1  Va0100,  
Gui, Add, Edit, x138 y10 w30 h30 Limit1  Va0101, 
Gui, Add, Edit, x168 y10 w30 h30 Limit1  Va0102, 
Gui, Add, Edit, x200 y10 w30 h30 Limit1  Va0200, 
Gui, Add, Edit, x230 y10 w30 h30 Limit1  Va0201, 
Gui, Add, Edit, x260 y10 w30 h30 Limit1  Va0202,
;--------------------------------------

Gui, Add, Edit, x16 y40 w30 h30  Limit1  Va0010,   
Gui, Add, Edit, x46 y40 w30 h30  Limit1  Va0011,  
Gui, Add, Edit, x76 y40 w30 h30  Limit1  Va0012,  
Gui, Add, Edit, x108 y40 w30 h30  Limit1  Va0110,  
Gui, Add, Edit, x138 y40 w30 h30  Limit1  Va0111, 
Gui, Add, Edit, x168 y40 w30 h30 Limit1  Va0112, 
Gui, Add, Edit, x200 y40 w30 h30 Limit1  Va0210, 
Gui, Add, Edit, x230 y40 w30 h30 Limit1  Va0211, 
Gui, Add, Edit, x260 y40 w30 h30 Limit1  Va0212,
;--------------------------------------

Gui, Add, Edit, x16 y70 w30 h30  Limit1  Va0020,   
Gui, Add, Edit, x46 y70 w30 h30  Limit1  Va0021,  
Gui, Add, Edit, x76 y70 w30 h30  Limit1  Va0022,  
Gui, Add, Edit, x108 y70 w30 h30  Limit1  Va0120,  
Gui, Add, Edit, x138 y70 w30 h30  Limit1  Va0121, 
Gui, Add, Edit, x168 y70 w30 h30 Limit1  Va0122, 
Gui, Add, Edit, x200 y70 w30 h30 Limit1  Va0220, 
Gui, Add, Edit, x230 y70 w30 h30 Limit1  Va0221, 
Gui, Add, Edit, x260 y70 w30 h30 Limit1  Va0222,
;--------------------------------------
;--------------------------------------
Gui, Add, Edit, x16 y102 w30   h30 Limit1  Va1000,    
Gui, Add, Edit, x46 y102 w30   h30 Limit1  Va1001,    
Gui, Add, Edit, x76 y102 w30   h30 Limit1  Va1002,    
Gui, Add, Edit, x108 y102 w30   h30 Limit1  Va1100,    
Gui, Add, Edit, x138 y102 w30   h30 Limit1  Va1101,    
Gui, Add, Edit, x168 y102 w30  h30 Limit1  Va1102,    
Gui, Add, Edit, x200 y102 w30  h30 Limit1  Va1200,    
Gui, Add, Edit, x230 y102 w30  h30 Limit1  Va1201,    
Gui, Add, Edit, x260 y102 w30  h30 Limit1  Va1202, 
   
Gui, Add, Edit, x16 y132 w30   h30 Limit1  Va1010,    
Gui, Add, Edit, x46 y132 w30   h30 Limit1  Va1011,    
Gui, Add, Edit, x76 y132 w30   h30 Limit1  Va1012,    
Gui, Add, Edit, x108 y132 w30   h30 Limit1  Va1110,    
Gui, Add, Edit, x138 y132 w30   h30 Limit1  Va1111,    
Gui, Add, Edit, x168 y132 w30  h30 Limit1  Va1112,    
Gui, Add, Edit, x200 y132 w30  h30 Limit1  Va1210,    
Gui, Add, Edit, x230 y132 w30  h30 Limit1  Va1211,    
Gui, Add, Edit, x260 y132 w30  h30 Limit1  Va1212,
    
Gui, Add, Edit, x16 y162 w30  h30 Limit1  Va1020,    
Gui, Add, Edit, x46 y162 w30  h30 Limit1  Va1021,    
Gui, Add, Edit, x76 y162 w30  h30 Limit1  Va1022,    
Gui, Add, Edit, x108 y162 w30  h30 Limit1  Va1120,    
Gui, Add, Edit, x138 y162 w30  h30 Limit1  Va1121,    
Gui, Add, Edit, x168 y162 w30 h30 Limit1  Va1122,    
Gui, Add, Edit, x200 y162 w30 h30 Limit1  Va1220,    
Gui, Add, Edit, x230 y162 w30 h30 Limit1  Va1221,    
Gui, Add, Edit, x260 y162 w30 h30 Limit1  Va1222,

;-----------------------------------

Gui, Add, Edit, x16 y194 w30  h30 Limit1  Va2000,    
Gui, Add, Edit, x46 y194 w30  h30 Limit1  Va2001,    
Gui, Add, Edit, x76 y194 w30  h30 Limit1  Va2002,    
Gui, Add, Edit, x108 y194 w30  h30 Limit1  Va2100,    
Gui, Add, Edit, x138 y194 w30  h30 Limit1  Va2101,    
Gui, Add, Edit, x168 y194 w30 h30 Limit1  Va2102,    
Gui, Add, Edit, x200 y194 w30 h30 Limit1  Va2200,    
Gui, Add, Edit, x230 y194 w30 h30 Limit1  Va2201,    
Gui, Add, Edit, x260 y194 w30 h30 Limit1  Va2202,
    
Gui, Add, Edit, x16 y224 w30  h30 Limit1  Va2010,    
Gui, Add, Edit, x46 y224 w30  h30 Limit1  Va2011,    
Gui, Add, Edit, x76 y224 w30  h30 Limit1  Va2012,    
Gui, Add, Edit, x108 y224 w30  h30 Limit1  Va2110,    
Gui, Add, Edit, x138 y224 w30  h30 Limit1  Va2111,    
Gui, Add, Edit, x168 y224 w30 h30 Limit1  Va2112,    
Gui, Add, Edit, x200 y224 w30 h30 Limit1  Va2210,    
Gui, Add, Edit, x230 y224 w30 h30 Limit1  Va2211,    
Gui, Add, Edit, x260 y224 w30 h30 Limit1  Va2212,
    
Gui, Add, Edit, x16 y254 w30  h30 Limit1  Va2020,    
Gui, Add, Edit, x46 y254 w30  h30 Limit1  Va2021,    
Gui, Add, Edit, x76 y254 w30  h30 Limit1  Va2022,    
Gui, Add, Edit, x108 y254 w30  h30 Limit1  Va2120,    
Gui, Add, Edit, x138 y254 w30  h30 Limit1  Va2121,    
Gui, Add, Edit, x168 y254 w30 h30 Limit1  Va2122,    
Gui, Add, Edit, x200 y254 w30 h30 Limit1  Va2220,    
Gui, Add, Edit, x230 y254 w30 h30 Limit1  Va2221,    
Gui, Add, Edit, x260 y254 w30 h30 Limit1  Va2222,
Gui, Font, s8 cDefault
Gui, Add, Button, x300 y50 w60 h23,Save
Gui, Add, Button, x300 y73 w60 h23,Restore
Gui, Add, Button, x300 y100 w60 h23 default,Crack 
Gui, Add, Button, x300 y123 w60 h23,Clear  
Gui, Add, Button, x300 y260 w60 h25,Quit

Gui, Add, Radio,x305 y10 w25 h20 vR1,1
Gui, Add, Radio,x332 y10 w25 h20 VR2,2
Gui, Add, Radio,x305 y30 w25 h20 VR3,3
Gui, Add, Radio,x332 y30 w25 h20 VR4,4
GuiControl,,R1,1

  E=0
  F=0
  X=0
  Y=0
  name=0
  loop 3
  {
   F=0
   X=0
   Y=0 
   loop 3
    {
      X=0
      Y=0
      loop 3
       {
         y=0
         loop 3
         {
         	name++      
          Edit%name%=%E%%X%%F%%Y%
          Y+=1
         }
  
        X+=1 
       }
  
     F+=1
    }
  E+=1
  }
;---------------------------------- 
Gui, Show,h300 w370, %TargetWin%
Return
GuiClose:
ExitApp

ButtonSave:
	Gui, Submit,NoHide
	if (R1=1)
	 store=S1
	if (R2=1)
	 store=S2 
	if (R3=1)	
	 store=S3
	if (R4=1)	
	 store=S4
        E=0
        F=0
        X=0
        Y=0
        
        po=0
        loop 3
        {
         F=0
         X=0
         Y=0 
         loop 3
          {
            X=0
            Y=0
            loop 3
             {
               y=0
               loop 3
               {
               %store%%E%%F%%X%%Y% =% a%E%%F%%X%%Y%
               Y+=1
               }
        
              X+=1 
             }
        
           F+=1
          }
        E+=1
        }	  
Return

ButtonRestore:
	Gui, Submit,NoHide
	E=0
  F=0
  X=0
  Y=0
  Lsize=2
  trylist=0
  trylistN=0
  loop 3
  {
   F=0
   X=0
   Y=0 
   loop 3
    {
      X=0
      Y=0
      loop 3
       {
         y=0
         loop 3
         {
      
         GuiControl,, a%E%%F%%X%%Y%,
         Gui, Font, cDefault
         GuiControl, Font, a%E%%F%%X%%Y%
         Y+=1
         }
  
        X+=1 
       }
  
     F+=1
    }
  E+=1
  }

	if (R1=1)
	 store=S1
	if (R2=1)
	 store=S2 
	if (R3=1)
	 store=S3
	if (R4=1)	
	 store=S4
        E=0
        F=0
        X=0
        Y=0
        
        loop 3
        {
         F=0
         X=0
         Y=0 
         loop 3
          {
            X=0
            Y=0
            loop 3
             {
               y=0
               loop 3
               {
               GuiControl,, a%E%%F%%X%%Y%,% %store%%E%%F%%X%%Y%
               Y+=1
               }
        
              X+=1 
             }
        
           F+=1
          }
        E+=1
        }
Return

ButtonQuit:
ExitApp
;WinSet,redraw, ,Cube Solution
Return

ButtonClear:
E=0
F=0
X=0
Y=0
pp=0
Lsize=2
trylist=0
trylistN=0
loop 3
{
 F=0
 X=0
 Y=0 
 loop 3
  {
    X=0
    Y=0
    loop 3
     {
       y=0
       loop 3
       {
       Gui, Font, cDefault
       GuiControl, Font, a%E%%F%%X%%Y% 
       GuiControl,, a%E%%F%%X%%Y%,
       Y+=1
       }

      X+=1 
     }

   F+=1
  }
E+=1
}

return

ButtonCrack:
start:
Gui, Submit,NoHide
E=0
F=0
X=0
Y=0
spaces=0

E=0
F=0
X=0
Y=0

loop 3
{
 F=0
 X=0
 Y=0 
 loop 3
  {
    X=0
    Y=0
    loop 3
     {
       y=0
       loop 3
       {
            n%E%%F%%X%%Y%= 
            if  a%E%%F%%X%%Y%=
            {
             Gui, Font, s15 CRed                                 
             GuiControl, Font, a%E%%F%%X%%Y%
              
              spaces++
              k=0
              loop 9
               {
                k+=1
                a%E%%F%%X%%Y%L%k%=%k%
               }
               n%E%%F%%X%%Y%=9

               A=0
               B=0
               loop 3
               {
                 B=0
                 loop 3
                 {
                   K=0
                    loop % n%E%%F%%X%%Y%
                    {
                     k+=1 
                       if a%E%%F%%X%%Y%L%k%=% a%E%%F%%A%%B%
                        {
                          j:=n%E%%F%%X%%Y%-k
                          i=%K%
                            loop %j%
                            {
                             h:=i+1
                             a%E%%F%%X%%Y%L%i%=% a%E%%F%%X%%Y%L%h%
                             i++
                            }
                         n%E%%F%%X%%Y%:=n%E%%F%%X%%Y%-1

                        }
                    }
                  B+=1
                 }
                
               A+=1
               }                 
             
               A=0
               B=0
               loop 3
               {
                 B=0
                 loop 3
                 {
                   K=0
                    loop % n%E%%F%%X%%Y%
                    {
                     k+=1 
                       if a%E%%F%%X%%Y%L%k%=% a%E%%A%%X%%B%
                        {
                          j:=n%E%%F%%X%%Y%-k
                          i=%K%
                            loop %j%
                            {
                             h:=i+1
                             a%E%%F%%X%%Y%L%i%=% a%E%%F%%X%%Y%L%h%
                             i++
                            }
                         n%E%%F%%X%%Y%:=n%E%%F%%X%%Y%-1
                        }
                    }
                  B+=1
                 }
                
               A+=1
               }   

               A=0
               B=0
               loop 3
               {
                 B=0
                 loop 3
                 {
                   K=0
                    loop % n%E%%F%%X%%Y%
                    {
                     k+=1 
                       if a%E%%F%%X%%Y%L%k%=% a%A%%F%%B%%Y%
                        {
                          j:=n%E%%F%%X%%Y%-k
                          i=%K%
                            loop %j%
                            {
                             h:=i+1
                             a%E%%F%%X%%Y%L%i%=% a%E%%F%%X%%Y%L%h%
                             i++
                            }
                         n%E%%F%%X%%Y%:=n%E%%F%%X%%Y%-1
                        }
                    }
                  B+=1
                 }
                
               A+=1
               }   

                    if n%E%%F%%X%%Y%=1
                    {
                    a%E%%F%%x%%y%=% a%E%%F%%X%%Y%L1
                    GuiControl,, a%E%%F%%X%%Y%, % a%E%%F%%X%%Y%L1
                    n%E%%F%%X%%Y%=                     
                    }
            }

       Y+=1
       }

      X+=1 
     }

   F+=1
  }
E+=1
}

E=0
F=0
X=0
Y=0

loop 3
{
 F=0
 X=0
 Y=0 
 loop 3
  {
    X=0
    Y=0
    loop 3
     {
       y=0
       loop 3
       {
                 if (n%E%%F%%X%%Y%>1)
                    {
                             A=0
                             B=0
                             i=0                           
                             
                             loop 3 ;find group
                             {
                               B=0
                               loop 3
                               {
              
                                           if (n%E%%F%%X%%Y%=n%E%%F%%A%%B%)
                                            {
                                              z=% n%E%%F%%X%%Y%
                                              sameV=0
                                              k=0
                                              
                                                   loop %z%                      
                                                   {                             
                                                   	k+=1                         
                                                   	if a%E%%F%%X%%Y%L%k%=% a%E%%F%%A%%B%L%k%                                                   	
                                                   	sameV++                                                                         
                                                   }                           
                                             
                                                   if (sameV=Z)
                                                   {
                                                   i+=1
                                                   sameV%i%=%E%%F%%A%%B%                                                  
                                                   }
                                            }
                                             
                                B+=1              
                               }                  
                             A+=1
                             }                            
                           
                             if i=% n%E%%F%%X%%Y% ; if a group exists
                             {                             	   
                             	       A=0
                                     B=0
                                     j=0
                                     loop 3 ;find other spacess
                                     {
                                       B=0
                                       loop 3
                                       {
                                          if (n%E%%F%%A%%B%>1)
                                          {
                                               jjj=0
                                               Nname=%E%%F%%A%%B%
                                               Lsame=0
                                                  loop %i%
                                                  { 
                                                  	jjj+=1                                         	
                                                  	   if (Nname=sameV%jjj%)                                                  	   
                                                  	    Lsame++                                                  	                                                 	                                                     	                                              
                                                  }
                                                 if Lsame=0
                                                 {
                                                 	j+=1
                                                 	nnn%j%=%E%%F%%A%%B%
                                                 }              
                                                  
                                           }
                                        B+=1              
                                       }                  
                                     A+=1
                                     }  
                             } 
                                                                                     
                             if i=% n%E%%F%%X%%Y%
                             {
                              	     z=% n%E%%F%%X%%Y%
                              	     jj=0
                                     loop %j%	
                                     {
                                     	jj+=1 
                                     	      zz=0
                                     	      loop %z%
                                     	      {
                                     	      	zz+=1
                                     	      	vvv=% a%E%%F%%X%%Y%L%zz%
                                     	      	
                                     	      	 k=0 
                                     	      	 LL=% NNN%jj%      ;ll=2202
                                     	      	
                                     	      	 nnn=n%LL%       ;nnn=n2202
                                     	      	 nnnn=% %nnn%    ;nnnn=6                                        
                                     	      	 loop %nnnn%                           
                                     	      	 {                                              
                                     	      	  k+=1                                          
                                     	      	    if a%LL%L%k%=%vvv%        
                                     	      	     {                                          
                                     	      	       xx:=nnnn-k                       
                                     	      	       ii=%K%                                    
                                     	      	         loop %xx%                               
                                     	      	         {                                      
                                     	      	          h:=ii+1                                
                                     	      	          a%LL%L%ii%=% a%LL%L%h% 
                                     	      	          ii++                                   
                                     	      	         }                                      
                                     	      	      n%LL%:=n%LL%-1  
                                     	      	      	 if n%LL%=1                              
                                     	      	      	 {                                               
                                     	      	      	 a%LL%=% a%LL%L1                 
                                     	      	      	 GuiControl,, a%LL%, % a%LL%L1   
                                     	      	      	 n%LL%=                                               
                                     	      	      	 }                                               
                                     	      	      	          
                                     	      	                                                
                                     	      	     }                                          
                                     	      	 }                                              
                              
                                     	      }
                                     	 
                                     }   
                              
                             }
                          ;-----------------------------------   
                             A=0
                             B=0
                             i=0                           
                             
                             loop 3 ;find group
                             {
                               B=0
                               loop 3
                               {
              
                                           if (n%E%%F%%X%%Y%=n%E%%A%%X%%B%)
                                            {
                                              z=% n%E%%F%%X%%Y%
                                              sameV=0
                                              k=0
                                              
                                                   loop %z%                      
                                                   {                             
                                                   	k+=1                         
                                                   	if a%E%%F%%X%%Y%L%k%=% a%E%%A%%X%%B%L%k%                                                   	
                                                   	sameV++                                                                         
                                                   }                           
                                             
                                                   if (sameV=Z)
                                                   {
                                                   i+=1
                                                   sameV%i%=%E%%A%%X%%B%                                                  
                                                   }
                                            }
                                             
                                B+=1              
                               }                  
                             A+=1
                             }                            
                           
                             if i=% n%E%%F%%X%%Y% ; if a group exists
                             {                             	   
                             	       A=0
                                     B=0
                                     j=0
                                     loop 3 ;find other spacess
                                     {
                                       B=0
                                       loop 3
                                       {
                                          if (n%E%%A%%X%%B%>1)
                                          {
                                               jjj=0
                                               Nname=%E%%A%%X%%B%
                                               Lsame=0
                                                  loop %i%
                                                  { 
                                                  	jjj+=1                                         	
                                                  	   if (Nname=sameV%jjj%)                                                  	   
                                                  	    Lsame++                                                 	                                                     	                                              
                                                  }
                                                 if Lsame=0
                                                 {
                                                 	j+=1
                                                 	nnn%j%=%E%%A%%X%%B%
                                                 }              
                                                  
                                           }
                                        B+=1              
                                       }                  
                                     A+=1
                                     }  
                             } 
                                                                                     
                             if i=% n%E%%F%%X%%Y%
                             {
                              	     z=% n%E%%F%%X%%Y%
                              	     jj=0
                                     loop %j%	
                                     {
                                     	jj+=1 
                                     	      zz=0
                                     	      loop %z%
                                     	      {
                                     	      	zz+=1
                                     	      	vvv=% a%E%%F%%X%%Y%L%zz%
                                     	      	
                                     	      	 k=0 
                                     	      	 LL=% NNN%jj%      ;ll=2202
                                     	      	
                                     	      	 nnn=n%LL%       ;nnn=n2202
                                     	      	 nnnn=% %nnn%    ;nnnn=6                                        
                                     	      	 loop %nnnn%                           
                                     	      	 {                                              
                                     	      	  k+=1                                          
                                     	      	    if a%LL%L%k%=%vvv%        
                                     	      	     {                                          
                                     	      	       xx:=nnnn-k                       
                                     	      	       ii=%K%                                    
                                     	      	         loop %xx%                               
                                     	      	         {                                      
                                     	      	          h:=ii+1                                
                                     	      	          a%LL%L%ii%=% a%LL%L%h% 
                                     	      	          ii++                                   
                                     	      	         }                                      
                                     	      	      n%LL%:=n%LL%-1  
                                     	      	      	 if n%LL%=1                              
                                     	      	      	 {                                               
                                     	      	      	 a%LL%=% a%LL%L1                                     	      	      	 
                                     	      	      	 GuiControl,, a%LL%, % a%LL%L1   
                                     	      	      	 n%LL%=                                                
                                     	      	      	 }                                               
                                     	      	      	          
                                     	      	                                                
                                     	      	     }                                          
                                     	      	 }                                              
                              
                                     	      }
                                     	 
                                     }   
                              
                             }
                          ;-----------------------------------   
                             A=0
                             B=0
                             i=0                           
                             
                             loop 3 ;find group
                             {
                               B=0
                               loop 3
                               {
              
                                           if (n%E%%F%%X%%Y%=n%A%%F%%B%%Y%)
                                            {
                                              z=% n%E%%F%%X%%Y%
                                              sameV=0
                                              k=0
                                              
                                                   loop %z%                      
                                                   {                             
                                                   	k+=1                         
                                                   	if a%E%%F%%X%%Y%L%k%=% a%A%%F%%B%%Y%L%k%                                                   	
                                                   	sameV++                                                                         
                                                   }                           
                                             
                                                   if (sameV=Z)
                                                   {
                                                   i+=1
                                                   sameV%i%=%A%%F%%B%%Y%                                                  
                                                   }
                                            }
                                             
                                B+=1              
                               }                  
                             A+=1
                             }                            
                           
                             if i=% n%E%%F%%X%%Y% ; if a group exists
                             {                             	   
                             	       A=0
                                     B=0
                                     j=0
                                     loop 3 ;find other spacess
                                     {
                                       B=0
                                       loop 3
                                       {
                                          if (n%A%%F%%B%%Y%>1)
                                          {
                                               jjj=0
                                               Nname=%A%%F%%B%%Y%
                                               Lsame=0
                                                  loop %i%
                                                  { 
                                                  	jjj+=1                                         	
                                                  	   if (Nname=sameV%jjj%)                                                  	   
                                                  	    Lsame++                                                  	                                                     	                                              
                                                  }
                                                 if Lsame=0
                                                 {
                                                 	j+=1
                                                 	nnn%j%=%A%%F%%B%%Y%
                                                 }              
                                                  
                                           }
                                        B+=1              
                                       }                  
                                     A+=1
                                     }  
                             } 
                                                                                     
                             if i=% n%E%%F%%X%%Y%
                             {
                              	     z=% n%E%%F%%X%%Y%
                              	     jj=0
                                     loop %j%	
                                     {
                                     	jj+=1 
                                     	      zz=0
                                     	      loop %z%
                                     	      {
                                     	      	zz+=1
                                     	      	vvv=% a%E%%F%%X%%Y%L%zz%
                                     	      	
                                     	      	 k=0 
                                     	      	 LL=% NNN%jj%      ;ll=2202
                                     	      	
                                     	      	 nnn=n%LL%       ;nnn=n2202
                                     	      	 nnnn=% %nnn%    ;nnnn=6                                        
                                     	      	 loop %nnnn%                           
                                     	      	 {                                              
                                     	      	  k+=1                                          
                                     	      	    if a%LL%L%k%=%vvv%        
                                     	      	     {                                          
                                     	      	       xx:=nnnn-k                       
                                     	      	       ii=%K%                                    
                                     	      	         loop %xx%                               
                                     	      	         {                                      
                                     	      	          h:=ii+1                                
                                     	      	          a%LL%L%ii%=% a%LL%L%h% 
                                     	      	          ii++                                   
                                     	      	         }                                      
                                     	      	      n%LL%:=n%LL%-1  
                                     	      	      	 if n%LL%=1                              
                                     	      	      	 {                                               
                                     	      	      	 a%LL%=% a%LL%L1
                                     	      	      	 GuiControl,, a%LL%, % a%LL%L1   
                                     	      	      	 n%LL%=                                                
                                     	      	      	 }                                               
                                     	      	      	          
                                     	      	                                                
                                     	      	     }                                          
                                     	      	 }                                              
                              
                                     	      }
                                     	 
                                     }   
                              
                             }
                          ;-----------------------------------   
                    }
       Y+=1
       }

      X+=1 
     }

   F+=1
  }
E+=1
}


;--------------------------------------
;--------------------------------------
E=0
F=0
X=0
Y=0

loop 3
{
 F=0
 X=0
 Y=0 
 loop 3
  {
    X=0
    Y=0
    loop 3
     {
       y=0
       loop 3
       {
                 if (n%E%%F%%X%%Y%>1)
                    {
                             A=0
                             B=0
                             i=0                           
                             
                             loop 3 ;find group
                             {
                               B=0
                               loop 3
                               {
              
                                           if (n%E%%F%%X%%Y%=n%E%%F%%A%%B%)
                                            {
                                              z=% n%E%%F%%X%%Y%
                                              sameV=0
                                              k=0
                                              
                                                   loop %z%                      
                                                   {                             
                                                   	k+=1                         
                                                   	if a%E%%F%%X%%Y%L%k%=% a%E%%F%%A%%B%L%k%                                                   	
                                                   	sameV++                                                                         
                                                   }                           
                                             
                                                   if (sameV=Z)
                                                   {
                                                   i+=1
                                                   sameV%i%=%E%%F%%A%%B%                                                  
                                                   }
                                            }
                                             
                                B+=1              
                               }                  
                             A+=1
                             }                            
                           
                             if i=% n%E%%F%%X%%Y% ; if a group exists
                             {                             	   
                             	       A=0
                                     B=0
                                     j=0
                                     loop 3 ;find other spacess
                                     {
                                       B=0
                                       loop 3
                                       {
                                          if (n%E%%F%%A%%B%>1)
                                          {
                                               jjj=0
                                               Nname=%E%%F%%A%%B%
                                               Lsame=0
                                                  loop %i%
                                                  { 
                                                  	jjj+=1                                         	
                                                  	   if (Nname=sameV%jjj%)                                                  	   
                                                  	    Lsame++                                                  	                                                 	                                                     	                                              
                                                  }
                                                 if Lsame=0
                                                 {
                                                 	j+=1
                                                 	nnn%j%=%E%%F%%A%%B%
                                                 }              
                                                  
                                           }
                                        B+=1              
                                       }                  
                                     A+=1
                                     }  
                             } 
                                                                                     
                             if i=% n%E%%F%%X%%Y%
                             {
                              	     z=% n%E%%F%%X%%Y%
                              	     jj=0
                                     loop %j%	
                                     {
                                     	jj+=1 
                                     	      zz=0
                                     	      loop %z%
                                     	      {
                                     	      	zz+=1
                                     	      	vvv=% a%E%%F%%X%%Y%L%zz%
                                     	      	
                                     	      	 k=0 
                                     	      	 LL=% NNN%jj%      ;ll=2202
                                     	      	
                                     	      	 nnn=n%LL%       ;nnn=n2202
                                     	      	 nnnn=% %nnn%    ;nnnn=6                                        
                                     	      	 loop %nnnn%                           
                                     	      	 {                                              
                                     	      	  k+=1                                          
                                     	      	    if a%LL%L%k%=%vvv%        
                                     	      	     {                                          
                                     	      	       xx:=nnnn-k                       
                                     	      	       ii=%K%                                    
                                     	      	         loop %xx%                               
                                     	      	         {                                      
                                     	      	          h:=ii+1                                
                                     	      	          a%LL%L%ii%=% a%LL%L%h% 
                                     	      	          ii++                                   
                                     	      	         }                                      
                                     	      	      n%LL%:=n%LL%-1  
                                     	      	      	 if n%LL%=1                              
                                     	      	      	 {                                               
                                     	      	      	 a%LL%=% a%LL%L1                 
                                     	      	      	 GuiControl,, a%LL%, % a%LL%L1   
                                     	      	      	 n%LL%=                                               
                                     	      	      	 }                                               
                                     	      	      	          
                                     	      	                                                
                                     	      	     }                                          
                                     	      	 }                                              
                              
                                     	      }
                                     	 
                                     }   
                              
                             }
                          ;-----------------------------------   
                             A=0
                             B=0
                             i=0                           
                             
                             loop 3 ;find group
                             {
                               B=0
                               loop 3
                               {
              
                                           if (n%E%%F%%X%%Y%=n%E%%A%%X%%B%)
                                            {
                                              z=% n%E%%F%%X%%Y%
                                              sameV=0
                                              k=0
                                              
                                                   loop %z%                      
                                                   {                             
                                                   	k+=1                         
                                                   	if a%E%%F%%X%%Y%L%k%=% a%E%%A%%X%%B%L%k%                                                   	
                                                   	sameV++                                                                         
                                                   }                           
                                             
                                                   if (sameV=Z)
                                                   {
                                                   i+=1
                                                   sameV%i%=%E%%A%%X%%B%                                                  
                                                   }
                                            }
                                             
                                B+=1              
                               }                  
                             A+=1
                             }                            
                           
                             if i=% n%E%%F%%X%%Y% ; if a group exists
                             {                             	   
                             	       A=0
                                     B=0
                                     j=0
                                     loop 3 ;find other spacess
                                     {
                                       B=0
                                       loop 3
                                       {
                                          if (n%E%%A%%X%%B%>1)
                                          {
                                               jjj=0
                                               Nname=%E%%A%%X%%B%
                                               Lsame=0
                                                  loop %i%
                                                  { 
                                                  	jjj+=1                                         	
                                                  	   if (Nname=sameV%jjj%)                                                  	   
                                                  	    Lsame++                                                 	                                                     	                                              
                                                  }
                                                 if Lsame=0
                                                 {
                                                 	j+=1
                                                 	nnn%j%=%E%%A%%X%%B%
                                                 }              
                                                  
                                           }
                                        B+=1              
                                       }                  
                                     A+=1
                                     }  
                             } 
                                                                                     
                             if i=% n%E%%F%%X%%Y%
                             {
                              	     z=% n%E%%F%%X%%Y%
                              	     jj=0
                                     loop %j%	
                                     {
                                     	jj+=1 
                                     	      zz=0
                                     	      loop %z%
                                     	      {
                                     	      	zz+=1
                                     	      	vvv=% a%E%%F%%X%%Y%L%zz%
                                     	      	
                                     	      	 k=0 
                                     	      	 LL=% NNN%jj%      ;ll=2202
                                     	      	
                                     	      	 nnn=n%LL%       ;nnn=n2202
                                     	      	 nnnn=% %nnn%    ;nnnn=6                                        
                                     	      	 loop %nnnn%                           
                                     	      	 {                                              
                                     	      	  k+=1                                          
                                     	      	    if a%LL%L%k%=%vvv%        
                                     	      	     {                                          
                                     	      	       xx:=nnnn-k                       
                                     	      	       ii=%K%                                    
                                     	      	         loop %xx%                               
                                     	      	         {                                      
                                     	      	          h:=ii+1                                
                                     	      	          a%LL%L%ii%=% a%LL%L%h% 
                                     	      	          ii++                                   
                                     	      	         }                                      
                                     	      	      n%LL%:=n%LL%-1  
                                     	      	      	 if n%LL%=1                              
                                     	      	      	 {                                               
                                     	      	      	 a%LL%=% a%LL%L1                 
                                     	      	      	 GuiControl,, a%LL%, % a%LL%L1   
                                     	      	      	 n%LL%=                                                
                                     	      	      	 }                                               
                                     	      	      	          
                                     	      	                                                
                                     	      	     }                                          
                                     	      	 }                                              
                              
                                     	      }
                                     	 
                                     }   
                              
                             }
                          ;-----------------------------------   
                             A=0
                             B=0
                             i=0                           
                             
                             loop 3 ;find group
                             {
                               B=0
                               loop 3
                               {
              
                                           if (n%E%%F%%X%%Y%=n%A%%F%%B%%Y%)
                                            {
                                              z=% n%E%%F%%X%%Y%
                                              sameV=0
                                              k=0
                                              
                                                   loop %z%                      
                                                   {                             
                                                   	k+=1                         
                                                   	if a%E%%F%%X%%Y%L%k%=% a%A%%F%%B%%Y%L%k%                                                   	
                                                   	sameV++                                                                         
                                                   }                           
                                             
                                                   if (sameV=Z)
                                                   {
                                                   i+=1
                                                   sameV%i%=%A%%F%%B%%Y%                                                  
                                                   }
                                            }
                                             
                                B+=1              
                               }                  
                             A+=1
                             }                            
                           
                             if i=% n%E%%F%%X%%Y% ; if a group exists
                             {                             	   
                             	       A=0
                                     B=0
                                     j=0
                                     loop 3 ;find other spacess
                                     {
                                       B=0
                                       loop 3
                                       {
                                          if (n%A%%F%%B%%Y%>1)
                                          {
                                               jjj=0
                                               Nname=%A%%F%%B%%Y%
                                               Lsame=0
                                                  loop %i%
                                                  { 
                                                  	jjj+=1                                         	
                                                  	   if (Nname=sameV%jjj%)                                                  	   
                                                  	    Lsame++                                                  	                                                     	                                              
                                                  }
                                                 if Lsame=0
                                                 {
                                                 	j+=1
                                                 	nnn%j%=%A%%F%%B%%Y%
                                                 }              
                                                  
                                           }
                                        B+=1              
                                       }                  
                                     A+=1
                                     }  
                             } 
                                                                                     
                             if i=% n%E%%F%%X%%Y%
                             {
                              	     z=% n%E%%F%%X%%Y%
                              	     jj=0
                                     loop %j%	
                                     {
                                     	jj+=1 
                                     	      zz=0
                                     	      loop %z%
                                     	      {
                                     	      	zz+=1
                                     	      	vvv=% a%E%%F%%X%%Y%L%zz%
                                     	      	
                                     	      	 k=0 
                                     	      	 LL=% NNN%jj%      ;ll=2202
                                     	      	
                                     	      	 nnn=n%LL%       ;nnn=n2202
                                     	      	 nnnn=% %nnn%    ;nnnn=6                                        
                                     	      	 loop %nnnn%                           
                                     	      	 {                                              
                                     	      	  k+=1                                          
                                     	      	    if a%LL%L%k%=%vvv%        
                                     	      	     {                                          
                                     	      	       xx:=nnnn-k                       
                                     	      	       ii=%K%                                    
                                     	      	         loop %xx%                               
                                     	      	         {                                      
                                     	      	          h:=ii+1                                
                                     	      	          a%LL%L%ii%=% a%LL%L%h% 
                                     	      	          ii++                                   
                                     	      	         }                                      
                                     	      	      n%LL%:=n%LL%-1  
                                     	      	      	 if n%LL%=1                              
                                     	      	      	 {                                               
                                     	      	      	 a%LL%=% a%LL%L1                 
                                     	      	      	 GuiControl,, a%LL%, % a%LL%L1   
                                     	      	      	 n%LL%=                                                
                                     	      	      	 }                                               
                                     	      	      	          
                                     	      	                                                
                                     	      	     }                                          
                                     	      	 }                                              
                              
                                     	      }
                                     	 
                                     }   
                              
                             }
                          ;-----------------------------------   
                    }
       Y+=1
       }

      X+=1 
     }

   F+=1
  }
E+=1
}
Gui, Submit,NoHide
E=0
F=0
X=0
Y=0
spaces2=0
loop 3
{
 F=0
 X=0
 Y=0 
 loop 3
  {
    X=0
    Y=0
    loop 3
     {
       y=0
       loop 3
       {
       if a%E%%F%%X%%Y%=       
        spaces2++
       Y+=1
       }

      X+=1 
     }

   F+=1
  }
E+=1
}

if (spaces2<spaces)
goto start

if (spaces2=0)
goto stop 
else
{
	if(trylist=0)
	{
		     trylist=1
		     lp=
         lv=
         lll=0
         
         E=0
         F=0
         X=0
         Y=0         
         loop 3
         {
          F=0
          X=0
          Y=0 
          loop 3
           {
             X=0
             Y=0
             loop 3
              {
                y=0
                loop 3
                {
                 temp%E%%F%%X%%Y% =% a%E%%F%%X%%Y% 
                  if a%E%%F%%X%%Y%=
                  {
                  	if (n%E%%F%%X%%Y%=2)
                  	{
                  		
                  		ss=0
                  		loop %Lsize%
                  		{
                  			ss++
                  			lll++
                  			lp%lll%=%E%%F%%X%%Y%
                  			lv%lll%=% a%E%%F%%X%%Y%L%ss%                  			
                  		}
                  	}
                  }    
                 Y+=1
                }
               X+=1 
              }
              F+=1
           }
         E+=1
         }
          E=0
         F=0
         X=0
         Y=0         
         loop 3
         {
          F=0
          X=0
          Y=0 
          loop 3
           {
             X=0
             Y=0
             loop 3
              {
                y=0
                loop 3
                {
                 temp%E%%F%%X%%Y% =% a%E%%F%%X%%Y% 
                  if a%E%%F%%X%%Y%=
                  {
                  	if (n%E%%F%%X%%Y%=3)
                  	{
                  		
                  		ss=0
                  		loop %Lsize%
                  		{
                  			ss++
                  			lll++
                  			lp%lll%=%E%%F%%X%%Y%
                  			lv%lll%=% a%E%%F%%X%%Y%L%ss%                  			
                  		}
                  	}
                  }    
                 Y+=1
                }
               X+=1 
              }
              F+=1
           }
         E+=1
         }
	} ;trylist
  if lll=0
  {
  msgbox No solutions.
  goto stop
  }
  if (trylist=1)
  {
  	trylistN++
  	 if (trylistN>lll)
  	 {
     msgbox No solutions.
      goto stop
     }
                  E=0
                  F=0
                  X=0
                  Y=0
                  
                  loop 3
                  {
                   F=0
                   X=0
                   Y=0 
                   loop 3
                    {
                      X=0
                      Y=0
                      loop 3
                       {
                         y=0
                         loop 3
                         {                         	
                          GuiControl,, a%E%%F%%X%%Y%,% temp%E%%F%%X%%Y%
                         Y+=1
                         }
                  
                        X+=1 
                       }
                  
                     F+=1
                    }
                  E+=1
                  }
        change=% lp%trylistN%
        GuiControl,, a%change%,% lv%trylistN%         
  	    goto start
  }	
}
stop:
return

right::
	send {tab}
return

left::
	Send, {SHIFTDOWN}{TAB}{SHIFTUP}
return

down::
	send, {Tab 9}
return

up::
	Send, {SHIFTDOWN}{TAB 9}{SHIFTUP}
return


User avatar
Soft
Posts: 174
Joined: 07 Jan 2015, 13:18
GitHub: visionary1
Location: Seoul
Contact:

Re: SudokuCracker 1.0

04 Feb 2015, 21:56

Interesting! :D
AutoHotkey & AutoHotkey_H v1.1.22.07
GeekDude
Posts: 874
Joined: 02 Oct 2013, 22:13

Re: SudokuCracker 1.0

04 Feb 2015, 22:58

Cool script! Two things I have to ask not necessarily related to the script, though:
  1. Are you really still running windows XP
  2. Have you heard about proper array support? Pseudo-arrays haven't needed much use for years.
Last edited by GeekDude on 04 Feb 2015, 23:16, edited 1 time in total.
guest3456
Posts: 3109
Joined: 09 Oct 2013, 10:31

Re: SudokuCracker 1.0

04 Feb 2015, 23:13

GeekDude wrote:
  1. Have you heard about proper array support? Pseudo-arrays haven't needed much use for years.
Maybe he's still using AHK Basic. I still do.

Coco
Posts: 771
Joined: 29 Sep 2013, 20:37
GitHub: cocobelgica

Re: SudokuCracker 1.0

05 Feb 2015, 04:17

Nice :)
User avatar
joedf
Posts: 7646
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: SudokuCracker 1.0

05 Feb 2015, 07:54

Very cool :cool:
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x8GB G.Skill RipJaws V - DDR4 3280 MHz | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
User avatar
oldbrother
Posts: 174
Joined: 23 Oct 2013, 05:08

Re: SudokuCracker 1.0

05 Feb 2015, 17:44

GeekDude wrote:Are you really still running windows XP
Yes, I'm still using XP both at home and at work. The ERP system of my company can only run on XP so we have no choice to use XP. I do have win8.1 on my desktop at home, but I like XP on my laptop. It's clean, lightweight, fast. I can run AHK and all kinds of programs that I need. I just don't have any motivations to move to other OS's ;) .
Soft wrote:Have you heard about proper array support? Pseudo-arrays haven't needed much use for years.
This script was written few years ago when I started learning AHK.
Last edited by oldbrother on 06 Feb 2015, 12:25, edited 1 time in total.
User avatar
empardopo
Posts: 336
Joined: 06 Oct 2013, 12:50
Location: Spain
Contact:

Re: SudokuCracker 1.0

06 Feb 2015, 03:15

Very nice! I do not know the instructions to generate a valid sudoku.
Everything is possible!
User avatar
tomoe_uehara
Posts: 210
Joined: 05 Oct 2013, 12:37
Contact:

Re: SudokuCracker 1.0

19 Feb 2015, 01:43

empardopo wrote:Very nice! I do not know the instructions to generate a valid sudoku.
A valid sudoku? Well.. You only allowed to use a number once in vertical or horizontal, so there will be no two same number in a row/column.

Anyway, it will looks nicer if you add Center to the Gui, Add, Edit

Image
User avatar
empardopo
Posts: 336
Joined: 06 Oct 2013, 12:50
Location: Spain
Contact:

Re: SudokuCracker 1.0

19 Feb 2015, 04:18

I wanted to say that I am not able to generate a valid sudoku. :D
Don't worry. I'll take a look in a newspaper.

Thanks
Attachments
sudoku.png
Everything is possible!

Return to “Scripts and Functions”

Who is online

Users browsing this forum: DataLife and 88 guests