Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C#] Sudoku Solver

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming -> Binaries
View previous topic :: View next topic  
Author Message
haha01haha01
Grandmaster Cheater Supreme
Reputation: 0

Joined: 15 Jun 2007
Posts: 1234
Location: http://www.SaviourFagFails.com/

PostPosted: Wed Apr 01, 2009 10:53 am    Post subject: [C#] Sudoku Solver Reply with quote

This is a sudoku solver made in C#. originally made it as an experiment with two-dimensional arrays, and decided to release it.

Downloads:
Compiled binary (64bit compatible)
Source code (C#)

How-to:
The 9x9 table is where you place all the numbers given to you. by clicking on the save button you can save the table to a .txt file (rows are separated by line break and columns by commas), and by clicking on load you can load a txt file into the table (honestly these two features were mainly for debugging because it was annoying to write all the numbers every time i needed to test something)

when you click on solve, the sudoku will be solved and the result will be put in the table. IF for some reason (shouldnt happen) it cant solve the sudoku, the unsolved blocks will be left blank.


How it works:
This sudoku solver uses two "Decryption" levels to solve the sudoku.

Decryption Level One:
This is a simple procedure that checks every empty block's options based on the other numbers in its row\column\3x3 square, and if there is only one option it fills that option and starts over. this works for easy-medium level sudokus. if there are still unsolved blocks after this procedure is done, it will automatically move to level two.
also, if there are zero options (not a bug, see level two) it will throw an array out of bonds exception, because it will try to select option #0 from an empty option list.

Decryption Level Two:
This is the brute force method, so it takes longer than level one. this procedure clones the current sudoku, finds an empty block, and creates a list of all the possible options it can be (there must be more than one option, because else it would have been solved in level one). then, it tries every option on a cloned sudoku, and tries to decrypt the clone in level one and than (recursively in) level two, and if none of the options succeed it throws an empty exception. if level one throws an exception, there must be something wrong, so it catches the exception and continues with the next number. if level two throws an exception, it means that none of options tried in level two were correct (considering the number tried in the parent level two), so it goes on to the next number.


Last edited by haha01haha01 on Thu Dec 17, 2009 4:52 am; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
Deve
Expert Cheater
Reputation: 0

Joined: 20 Jan 2007
Posts: 245
Location: Stockholm, Sweden

PostPosted: Wed Apr 01, 2009 11:34 am    Post subject: Reply with quote

interesting application there Razz i'll make sure to use it
_________________


Leecher.
Back to top
View user's profile Send private message MSN Messenger
haha01haha01
Grandmaster Cheater Supreme
Reputation: 0

Joined: 15 Jun 2007
Posts: 1234
Location: http://www.SaviourFagFails.com/

PostPosted: Thu Apr 02, 2009 8:04 am    Post subject: Reply with quote

some weird bug i just found, if you just enter the numbers into the table it wont work. you have to save them to file and than load it.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Thu Apr 02, 2009 10:22 pm    Post subject: Reply with quote

It works, you just have to select all and then hit solve.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
blackmorpheus
Expert Cheater
Reputation: 0

Joined: 05 Apr 2008
Posts: 159

PostPosted: Fri Apr 03, 2009 4:43 am    Post subject: Reply with quote

Thanks for sharing Very Happy
Back to top
View user's profile Send private message
haha01haha01
Grandmaster Cheater Supreme
Reputation: 0

Joined: 15 Jun 2007
Posts: 1234
Location: http://www.SaviourFagFails.com/

PostPosted: Sat Apr 11, 2009 3:13 am    Post subject: Reply with quote

i found how to fix the bug mentioned above, you need to replace
Code:
if ((string)dataGridView1[i, j].Value == "")
with
Code:
if (dataGridView1[i,j].Value == null || (string)dataGridView1[i, j].Value == "")
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
92Garfield
I'm a spammer
Reputation: 57

Joined: 20 Dec 2007
Posts: 5871
Location: Banana Republic Germany

PostPosted: Sun May 10, 2009 2:35 am    Post subject: Reply with quote

reupload, it's down and i'd like to test it Very Happy
_________________
Back to top
View user's profile Send private message
haha01haha01
Grandmaster Cheater Supreme
Reputation: 0

Joined: 15 Jun 2007
Posts: 1234
Location: http://www.SaviourFagFails.com/

PostPosted: Sun May 10, 2009 1:21 pm    Post subject: Reply with quote

Reuploads (fixed the bug mentioned above):
Compiled Binary
Sauce
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
92Garfield
I'm a spammer
Reputation: 57

Joined: 20 Dec 2007
Posts: 5871
Location: Banana Republic Germany

PostPosted: Sun May 10, 2009 4:16 pm    Post subject: Reply with quote

Realy great job
_________________
Back to top
View user's profile Send private message
clone
Cheater
Reputation: 0

Joined: 27 Jun 2006
Posts: 31

PostPosted: Thu Dec 17, 2009 12:19 am    Post subject: Reply with quote

Thanx..nice work Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming -> Binaries All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites