AutoHotkey Community

It is currently May 27th, 2012, 12:58 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: October 16th, 2006, 3:00 am 
Offline

Joined: November 16th, 2004, 6:38 am
Posts: 153
Location: New York
I'm not really "IM-enabled", slomz, but I'll tell you what: I'll just post the current code (warts and all), subject to a future correction (at which point I'll ask you to burn your copy! :-)). You should note that the automatic solving code is a really tiny recursive routine, so the bulk of the program is to provide the GUI features. I'll zip up the program and a little 1-pixel .bmp file used to provide the highlighting background (to get around the inability to change a text control's background color in AHK).

The code is at http://www.autohotkey.net/~JBensimon/SudokuCode.zip

Here's a screenshot of what the prgram looks like (in manual solving mode): http://www.autohotkey.net/file/index.php?act=img&target=SudokuScreenshot.bmp


Later,

Jacques.[/url]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 16th, 2006, 3:56 am 
Offline

Joined: September 3rd, 2006, 5:34 am
Posts: 601
Location: Iowa, U.S.
That is a very complex script.

Spare time my ass.....:

Code:
InitR(1,2,3,4,5,6,7,8,9,10,19,28,37,46,55,64,73,11,12,20,21)
InitR(2,1,3,4,5,6,7,8,9,11,20,29,38,47,56,65,74,10,12,19,21)
InitR(3,1,2,4,5,6,7,8,9,12,21,30,39,48,57,66,75,10,11,19,20)
InitR(4,1,2,3,5,6,7,8,9,13,22,31,40,49,58,67,76,14,15,23,24)
InitR(5,1,2,3,4,6,7,8,9,14,23,32,41,50,59,68,77,13,15,22,24)
InitR(6,1,2,3,4,5,7,8,9,15,24,33,42,51,60,69,78,13,14,22,23)
InitR(7,1,2,3,4,5,6,8,9,16,25,34,43,52,61,70,79,17,18,26,27)
InitR(8,1,2,3,4,5,6,7,9,17,26,35,44,53,62,71,80,16,18,25,27)
InitR(9,1,2,3,4,5,6,7,8,18,27,36,45,54,63,72,81,16,17,25,26)
InitR(10,11,12,13,14,15,16,17,18,1,19,28,37,46,55,64,73,2,3,20,21)
InitR(11,10,12,13,14,15,16,17,18,2,20,29,38,47,56,65,74,1,3,19,21)
InitR(12,10,11,13,14,15,16,17,18,3,21,30,39,48,57,66,75,1,2,19,20)
InitR(13,10,11,12,14,15,16,17,18,4,22,31,40,49,58,67,76,5,6,23,24)
InitR(14,10,11,12,13,15,16,17,18,5,23,32,41,50,59,68,77,4,6,22,24)
InitR(15,10,11,12,13,14,16,17,18,6,24,33,42,51,60,69,78,4,5,22,23)
InitR(16,10,11,12,13,14,15,17,18,7,25,34,43,52,61,70,79,8,9,26,27)
InitR(17,10,11,12,13,14,15,16,18,8,26,35,44,53,62,71,80,7,9,25,27)
InitR(18,10,11,12,13,14,15,16,17,9,27,36,45,54,63,72,81,7,8,25,26)
InitR(19,20,21,22,23,24,25,26,27,1,10,28,37,46,55,64,73,2,3,11,12)
InitR(20,19,21,22,23,24,25,26,27,2,11,29,38,47,56,65,74,1,3,10,12)
InitR(21,19,20,22,23,24,25,26,27,3,12,30,39,48,57,66,75,1,2,10,11)
InitR(22,19,20,21,23,24,25,26,27,4,13,31,40,49,58,67,76,5,6,14,15)
InitR(23,19,20,21,22,24,25,26,27,5,14,32,41,50,59,68,77,4,6,13,15)
InitR(24,19,20,21,22,23,25,26,27,6,15,33,42,51,60,69,78,4,5,13,14)
InitR(25,19,20,21,22,23,24,26,27,7,16,34,43,52,61,70,79,8,9,17,18)
InitR(26,19,20,21,22,23,24,25,27,8,17,35,44,53,62,71,80,7,9,16,18)
InitR(27,19,20,21,22,23,24,25,26,9,18,36,45,54,63,72,81,7,8,16,17)
InitR(28,29,30,31,32,33,34,35,36,1,10,19,37,46,55,64,73,38,39,47,48)
InitR(29,28,30,31,32,33,34,35,36,2,11,20,38,47,56,65,74,37,39,46,48)
InitR(30,28,29,31,32,33,34,35,36,3,12,21,39,48,57,66,75,37,38,46,47)
InitR(31,28,29,30,32,33,34,35,36,4,13,22,40,49,58,67,76,41,42,50,51)
InitR(32,28,29,30,31,33,34,35,36,5,14,23,41,50,59,68,77,40,42,49,51)
InitR(33,28,29,30,31,32,34,35,36,6,15,24,42,51,60,69,78,40,41,49,50)
InitR(34,28,29,30,31,32,33,35,36,7,16,25,43,52,61,70,79,44,45,53,54)
InitR(35,28,29,30,31,32,33,34,36,8,17,26,44,53,62,71,80,43,45,52,54)
InitR(36,28,29,30,31,32,33,34,35,9,18,27,45,54,63,72,81,43,44,52,53)
InitR(37,38,39,40,41,42,43,44,45,1,10,19,28,46,55,64,73,29,30,47,48)
InitR(38,37,39,40,41,42,43,44,45,2,11,20,29,47,56,65,74,28,30,46,48)
InitR(39,37,38,40,41,42,43,44,45,3,12,21,30,48,57,66,75,28,29,46,47)
InitR(40,37,38,39,41,42,43,44,45,4,13,22,31,49,58,67,76,32,33,50,51)
InitR(41,37,38,39,40,42,43,44,45,5,14,23,32,50,59,68,77,31,33,49,51)
InitR(42,37,38,39,40,41,43,44,45,6,15,24,33,51,60,69,78,31,32,49,50)
InitR(43,37,38,39,40,41,42,44,45,7,16,25,34,52,61,70,79,35,36,53,54)
InitR(44,37,38,39,40,41,42,43,45,8,17,26,35,53,62,71,80,34,36,52,54)
InitR(45,37,38,39,40,41,42,43,44,9,18,27,36,54,63,72,81,34,35,52,53)
InitR(46,47,48,49,50,51,52,53,54,1,10,19,28,37,55,64,73,29,30,38,39)
InitR(47,46,48,49,50,51,52,53,54,2,11,20,29,38,56,65,74,28,30,37,39)
InitR(48,46,47,49,50,51,52,53,54,3,12,21,30,39,57,66,75,28,29,37,38)
InitR(49,46,47,48,50,51,52,53,54,4,13,22,31,40,58,67,76,32,33,41,42)
InitR(50,46,47,48,49,51,52,53,54,5,14,23,32,41,59,68,77,31,33,40,42)
InitR(51,46,47,48,49,50,52,53,54,6,15,24,33,42,60,69,78,31,32,40,41)
InitR(52,46,47,48,49,50,51,53,54,7,16,25,34,43,61,70,79,35,36,44,45)
InitR(53,46,47,48,49,50,51,52,54,8,17,26,35,44,62,71,80,34,36,43,45)
InitR(54,46,47,48,49,50,51,52,53,9,18,27,36,45,63,72,81,34,35,43,44)
InitR(55,56,57,58,59,60,61,62,63,1,10,19,28,37,46,64,73,65,66,74,75)
InitR(56,55,57,58,59,60,61,62,63,2,11,20,29,38,47,65,74,64,66,73,75)
InitR(57,55,56,58,59,60,61,62,63,3,12,21,30,39,48,66,75,64,65,73,74)
InitR(58,55,56,57,59,60,61,62,63,4,13,22,31,40,49,67,76,68,69,77,78)
InitR(59,55,56,57,58,60,61,62,63,5,14,23,32,41,50,68,77,67,69,76,78)
InitR(60,55,56,57,58,59,61,62,63,6,15,24,33,42,51,69,78,67,68,76,77)
InitR(61,55,56,57,58,59,60,62,63,7,16,25,34,43,52,70,79,71,72,80,81)
InitR(62,55,56,57,58,59,60,61,63,8,17,26,35,44,53,71,80,70,72,79,81)
InitR(63,55,56,57,58,59,60,61,62,9,18,27,36,45,54,72,81,70,71,79,80)
InitR(64,65,66,67,68,69,70,71,72,1,10,19,28,37,46,55,73,56,57,74,75)
InitR(65,64,66,67,68,69,70,71,72,2,11,20,29,38,47,56,74,55,57,73,75)
InitR(66,64,65,67,68,69,70,71,72,3,12,21,30,39,48,57,75,55,56,73,74)
InitR(67,64,65,66,68,69,70,71,72,4,13,22,31,40,49,58,76,59,60,77,78)
InitR(68,64,65,66,67,69,70,71,72,5,14,23,32,41,50,59,77,58,60,76,78)
InitR(69,64,65,66,67,68,70,71,72,6,15,24,33,42,51,60,78,58,59,76,77)
InitR(70,64,65,66,67,68,69,71,72,7,16,25,34,43,52,61,79,62,63,80,81)
InitR(71,64,65,66,67,68,69,70,72,8,17,26,35,44,53,62,80,61,63,79,81)
InitR(72,64,65,66,67,68,69,70,71,9,18,27,36,45,54,63,81,61,62,79,80)
InitR(73,74,75,76,77,78,79,80,81,1,10,19,28,37,46,55,64,56,57,65,66)
InitR(74,73,75,76,77,78,79,80,81,2,11,20,29,38,47,56,65,55,57,64,66)
InitR(75,73,74,76,77,78,79,80,81,3,12,21,30,39,48,57,66,55,56,64,65)
InitR(76,73,74,75,77,78,79,80,81,4,13,22,31,40,49,58,67,59,60,68,69)
InitR(77,73,74,75,76,78,79,80,81,5,14,23,32,41,50,59,68,58,60,67,69)
InitR(78,73,74,75,76,77,79,80,81,6,15,24,33,42,51,60,69,58,59,67,68)
InitR(79,73,74,75,76,77,78,80,81,7,16,25,34,43,52,61,70,62,63,71,72)
InitR(80,73,74,75,76,77,78,79,81,8,17,26,35,44,53,62,71,61,63,70,72)
InitR(81,73,74,75,76,77,78,79,80,9,18,27,36,45,54,63,72,61,62,70,71)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 16th, 2006, 4:30 am 
Offline

Joined: November 16th, 2004, 6:38 am
Posts: 153
Location: New York
:) Two week-ends, to be specific.

The piece of code you quoted (which pre-defines a specific 81x20 matrix) is a shortcut way of identifying the 20 "peers" of any Sudoku grid entry. Using the entries in this matrix allows the puzzle to be stored and manipulated as an 81-element vector rather than a 9x9 matrix, which significantly cuts down on index calculations and speeds up the identification of candidates for any empty cell. My original Sudoku solver was (literally) a two-line recursive APL program (anybody remember APL?), and I pre-calculated that matrix as a way of making that program fast -- I just ported it to AHK when I decided to try creating a GUI version. The solving algorithm is also ported from my original APL program (which is why it's only about 15 lines in AHK).

Jacques.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 8th, 2006, 4:23 am 
Offline

Joined: November 16th, 2004, 6:38 am
Posts: 153
Location: New York
As promised, I've posted a finished (for now) version of the program and its code. See the following post in the "Scripts & Functions" forum:

http://www.autohotkey.com/forum/viewtopic.php?t=13995

Jacques.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 6th, 2009, 1:17 am 
slomz wrote:
Very nice JBensimon. That is a great script. Nothing I could ever accomplish. Could you im me and show me the script?


Is that the same script you can see on daily sudoku http://dailysudoku.info
maybe I've had to much cofee tonight, seems similar.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 8th, 2009, 8:46 pm 
Offline

Joined: November 16th, 2004, 6:38 am
Posts: 153
Location: New York
Not even a vague similarity as far as I can tell. That's not even a standalone Windows program.

Jacques.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, chaosad, Google Feedfetcher, MSN [Bot], Yahoo [Bot] and 17 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group