Computer Science Canada Logic Puzzle Challenge |
Author: | wtd [ Sun Jul 24, 2005 5:53 pm ] | ||
Post subject: | Logic Puzzle Challenge | ||
I have a 9 by 9 grid. Each space may contain a number between 1 and 9. Each row and rolumn may only contain unique numbers. The grid is further divided into 9 3 by 3 grids. Each of these smaller grids may only contain unique numbers. You start out with:
Where asterisks represent unknowns. Write a computer program which computes the unknowns. |
Author: | 1of42 [ Sun Jul 24, 2005 6:09 pm ] |
Post subject: | |
O.M.F.G. This is the puzzle that's sweepnig through Canada in the Globe, isn't it? (Name escapes me at the moment). I'll have to give it a try though. |
Author: | Hikaru79 [ Sun Jul 24, 2005 6:12 pm ] |
Post subject: | |
1of42, yes it is, but don't say the name because then people might be tempted to cheat by looking up existing algorithms. Security by obscurity ![]() I'm working on it too ![]() |
Author: | wtd [ Sun Jul 24, 2005 6:12 pm ] |
Post subject: | |
The example is the July 22nd puzzle. ![]() Oh, and the output should be the same as the input, but with the final values in place of asterisks. |
Author: | Delos [ Sun Jul 24, 2005 6:13 pm ] |
Post subject: | |
I've solved a couple of them. Remind me of my precious Rubicks cube in many respects. Since they are all computer generated, I figure there must be an algorithm to *create* them, thus there ought to be one to solve them. I have some ideas, though most are pretty long and tedious. [mod:f88bf0f35e="wtd (I'm guessing)"]One word removed to maintain a fair competition.[/mod:f88bf0f35e] |
Author: | wtd [ Sun Jul 24, 2005 6:17 pm ] | ||
Post subject: | |||
I know it can be solved.
![]() |
Author: | MysticVegeta [ Mon Jul 25, 2005 9:15 am ] |
Post subject: | Re: Logic Puzzle Challenge |
wtd wrote: Where asterisks represent unknowns. Write a computer program which computes the unknowns. What do you mean? We dont know the relations between the numbers, how to compute the asterisks??? ![]() |
Author: | wtd [ Mon Jul 25, 2005 11:24 am ] |
Post subject: | Re: Logic Puzzle Challenge |
MysticVegeta wrote: wtd wrote: Where asterisks represent unknowns. Write a computer program which computes the unknowns. What do you mean? We dont know the relations between the numbers, how to compute the asterisks??? ![]() The same number may not occur twice in any row, column, or smaller 3 by 3 grid. |
Author: | rizzix [ Mon Jul 25, 2005 4:45 pm ] |
Post subject: | |
Aight, took me 17 whole min... rizzix wrote: __________________
|4-6-8 |1-2-3-|5-7-9-| |9-5-7-|8-6-4-|2-3-1-| |2-3-1-|9-7-5-|8-4-6-| |~~~~|~~~~|~~~~| |7-4-6-|2-3-9-|1-8-5-| |1-9-5-|6-4-8-|7-2-3-| |8-2-3-|7-5-1-|9-6-4-| |~~~~|~~~~|~~~~| |6-1-9-|3-8-7-|4-5-2-| |3-8-4-|5-9-2-|6-1-7-| |5-7-2-|4-1-6-|3-9-8-| ~~~~~~~~~~~~~~ |
Author: | wtd [ Mon Jul 25, 2005 4:48 pm ] |
Post subject: | |
Yes, I can solve it by had in around 10 minutes. Now, show me the program you used to programmatically generate that answer. ![]() |
Author: | rizzix [ Mon Jul 25, 2005 4:51 pm ] |
Post subject: | |
i didn;t... it was by hand... ![]() |
Author: | Hikaru79 [ Mon Jul 25, 2005 8:34 pm ] |
Post subject: | |
I'm almost done my Python program. Awesome challenge, wtd, I really feel like my Python improved from doing this! I'll send it to you as soon as it is done, wtd. |
Author: | wtd [ Tue Jul 26, 2005 3:01 am ] |
Post subject: | |
Hikaru79 wrote: I'm almost done my Python program. Awesome challenge, wtd, I really feel like my Python improved from doing this!
I'll send it to you as soon as it is done, wtd. Great. I'm working on retooling mine to be more object-oriented... and... you know... work. The messy one works. The clean, elegant one... not so much. Yet. |
Author: | bugzpodder [ Tue Jul 26, 2005 9:41 pm ] |
Post subject: | |
i am assuming this is an attempt to show that python is much better than C++ in doing this. since i dont know python i'll have to stick to what i know. when i have time this weekend, I'll churn up something in C++. Stay tuned. |
Author: | wtd [ Tue Jul 26, 2005 9:57 pm ] |
Post subject: | |
Any language works. I just picked Python because it has a handy feature in its standard library for this problem. No, I'm not going to tell you what the handy feature is, because that would give away how to solve the problem. ![]() |
Author: | bugzpodder [ Tue Jul 26, 2005 10:02 pm ] |
Post subject: | |
i figured so ![]() |
Author: | bugzpodder [ Tue Jul 26, 2005 10:46 pm ] | ||
Post subject: | |||
this doesnt work yet... too tired to debug at night. continue tomorrow I bet this is already twice as long as your python thingy |
Author: | wtd [ Wed Jul 27, 2005 1:26 pm ] | ||
Post subject: | |||
I'm not even going to evaluate code that uses such horrendous variable naming, lacks decent use of whitespace, makes use of C-isms like memset (for which there is no readily apparent include), makes inconsistent use of braces, and uses multidimensional arrays instead of a matrix class. ![]() P.S. That is shorter than my Python program. That is not a virtue. |
Author: | 1of42 [ Wed Jul 27, 2005 2:13 pm ] |
Post subject: | |
You know, wtd, one of these days somebody is going to snap when they hear "whitespace" one more time and go on a massive killing spree. ![]() |
Author: | wtd [ Wed Jul 27, 2005 2:35 pm ] |
Post subject: | |
1of42 wrote: You know, wtd, one of these days somebody is going to snap when they hear "whitespace" one more time and go on a massive killing spree.
![]() As soon as people start using whitespace appropriately in their programs, I'll shut up about it. |
Author: | bugzpodder [ Wed Jul 27, 2005 8:57 pm ] |
Post subject: | |
oh come on, i've tried... i've even added comments!! and i indented!! at first i declared global variables. i thought you'd say something about that so i even moved them into local variables. now back to debugging... ps i am using notepad... |
Author: | wtd [ Wed Jul 27, 2005 9:11 pm ] | ||
Post subject: | |||
bugzpodder wrote: oh come on, i've tried... i've even added comments!!
Don't use comments when you can write self-explanatory code. Key to this is not writing your own code when the library contains a function that already does what you want.
bugzpodder wrote: ps i am using notepad...
Don't. Use Textpad, if you have to use Windows. |
Author: | Delos [ Wed Jul 27, 2005 10:54 pm ] |
Post subject: | |
Well, I have an awful programme working under OOT. It's very, very primitive, baically bashing away random numbers until it finds a solution. I was able to optimize it a little, but not too much. So far it can solve a puzzle with 8 missing spaces in between half and five seconds. Not worth it. I've been thinking about a more elegant algorithm, but haven't found anything yet. I will eventually, though. I'm slowly starting to see some patterns. Of course as far as I know they're the wrong ones, but bah. |
Author: | wtd [ Wed Jul 27, 2005 11:02 pm ] |
Post subject: | |
A hint for everyone, since it's been a little while: For each square that has no known value, you can generate a list of possibilities by starting with the set of numbers (1, 2, 3, 4, 5, 6, 7, 8, 9) and removing anything that it can't be. Once you do this, you may notice that there are spaces which have only a single possibility. |
Author: | Catalyst [ Thu Jul 28, 2005 1:10 am ] |
Post subject: | |
kinda verbose but it works |
Author: | wtd [ Thu Jul 28, 2005 3:56 am ] | ||
Post subject: | |||
Tsk tsk...
|
Author: | Catalyst [ Thu Jul 28, 2005 11:45 pm ] |
Post subject: | |
is it incorrect or just not as clean as it could be? |
Author: | wtd [ Thu Jul 28, 2005 11:58 pm ] |
Post subject: | |
Catalyst wrote: is it incorrect or just not as clean as it could be?
I have no idea if it's incorrect, but it's horrendous code. You need to use meaningful variable names. ![]() |
Author: | 1of42 [ Fri Jul 29, 2005 12:08 am ] |
Post subject: | |
Honestly, I think wtd just made this thread so he could correct some more people ont heir variable names. ![]() (yes, i'm joking) |
Author: | wtd [ Fri Jul 29, 2005 12:19 am ] |
Post subject: | |
As I said... I'll stop harping on it when people actually start listening to me. ![]() |
Author: | Catalyst [ Fri Jul 29, 2005 12:33 am ] |
Post subject: | |
while the code could be a bit more elegant and the names longer and more meaningful I didn't think of putting in the effort of cleaning it up when not many people would read the code |
Author: | wtd [ Fri Jul 29, 2005 12:38 am ] |
Post subject: | |
And still not good enough. ![]() "row", "col"... do these refer to an index, or some kind of data structure that stores a row or column? |
Author: | MysticVegeta [ Fri Jul 29, 2005 7:40 am ] |
Post subject: | |
I am trying to code this in turing ![]() ![]() |
Author: | Catalyst [ Fri Jul 29, 2005 1:09 pm ] |
Post subject: | |
oh well it happens ![]() |
Author: | bugzpodder [ Sat Jul 30, 2005 8:27 pm ] |
Post subject: | |
lol after reading zylum's solution I realized that I didnt read the question properly. I didnt know each 3x3 square contained only unique digits! |
Author: | wtd [ Sat Jul 30, 2005 10:57 pm ] |
Post subject: | |
Anybody who doesn't want to see my Python code for this... say so now! I'm ready to post it. ![]() |
Author: | Hikaru79 [ Sun Jul 31, 2005 2:13 am ] |
Post subject: | |
Ack, just in time! I've been done for a few days now, but it was on a different computer so I kept putting off posting it. Here it is, and just for the record, I had thought of wtd's suggestion before it was given. Note: The forum doesn't allow uploading .py so just rename it before executing. Another note: Both of these are with UNIX line breaks, so use something like ScITE or vim if the whole thing looks like one long line to you. |
Author: | wtd [ Sun Jul 31, 2005 4:19 am ] | ||||
Post subject: | |||||
Hikaru79, this:
Can be written as:
|
Author: | rizzix [ Sun Jul 31, 2005 10:47 am ] |
Post subject: | |
what version of python do i need to use to run your script? i can't get it to work (using python2.2) i got mine done, but i won't be posting it, yet... it can solve the puzzle. but.. well there's some issue i need to attend to... so far i've seen this issue in Hikaru's and Catalysts' solution. i simply can't test it on yours. i can't run it. |
Author: | Hikaru79 [ Sun Jul 31, 2005 12:16 pm ] |
Post subject: | |
rizzix wrote: what version of python do i need to use to run your script? i can't get it to work (using python2.2)
i got mine done, but i won't be posting it, yet... it can solve the puzzle. but.. well there's some issue i need to attend to... so far i've seen this issue in Hikaru's and Catalysts' solution. i simply can't test it on yours. i can't run it. It works fine for me (Python 2.4). Make sure you pass the filename of the puzzle as an argument. (I'm assuming you were reffering to wtd's program) What issue did mine and Catalyst's have? ![]() |
Author: | wtd [ Sun Jul 31, 2005 1:39 pm ] |
Post subject: | |
Yes. My program takes advantages of features that only exist in Python 2.4. |
Author: | Hikaru79 [ Sun Jul 31, 2005 2:21 pm ] | ||
Post subject: | |||
Well, guys, here's an extension to wtd's excellent challenge! Our programs aren't perfect yet ![]() Here, for example, is a puzzle that none of the programs submitted so far can solve:
|
Author: | wtd [ Sun Jul 31, 2005 3:36 pm ] |
Post subject: | |
Does anyone think there might be a recursive algorithm that could be beneficial? |
Author: | wtd [ Sun Jul 31, 2005 3:37 pm ] |
Post subject: | |
I also suspect this would be blindingly obvious if my Prolog skills were better. ![]() |
Author: | wtd [ Sun Jul 31, 2005 3:47 pm ] |
Post subject: | |
I think I may have challenged myself a bit too well on this one. |
Author: | wtd [ Sun Jul 31, 2005 3:49 pm ] | ||
Post subject: | |||
Hikaru79 wrote: Well, guys, here's an extension to wtd's excellent challenge! Our programs aren't perfect yet
![]() Here, for example, is a puzzle that none of the programs submitted so far can solve:
Have you done this one by hand? I'm having a lot of trouble finding a solution that way. |
Author: | Hikaru79 [ Sun Jul 31, 2005 4:05 pm ] | ||
Post subject: | |||
Yes, it's considered pretty difficult ![]() Here's the actual solution, if it helps any:
|
Author: | wtd [ Sun Jul 31, 2005 4:17 pm ] |
Post subject: | |
Maybe it makes me stupid, but I can see no conceivable way to solve this puzzle. |
Author: | Hikaru79 [ Sun Jul 31, 2005 4:22 pm ] |
Post subject: | |
Here is an analysis of the puzzle, which is considered to be quite hard even by the standards of people who have sizable post counts on a forum about Sudoku. (I guess its safe to let the cat out of the bag now ![]() My little scriptlet is going to need a complete overhaul ^_^; I think I'm going to go the OOP route too, if I'm going to make one that can solve any of these more difficult ones. |
Author: | MysticVegeta [ Sun Jul 31, 2005 5:42 pm ] |
Post subject: | |
is the turing solution still on? I am almost done with it, minor fixations. (no i didnt cheat/read the algorithm) by the ways, shouldnt algorithm be spelled alogrithm. People usually say "alog". Algo is more like "al go there" as in a phrase. Or maybe i am just dumb ![]() |
Author: | wtd [ Sun Jul 31, 2005 5:48 pm ] |
Post subject: | |
MysticVegeta wrote: is the turing solution still on? I am almost done with it, minor fixations. (no i didnt cheat/read the algorithm)
by the ways, shouldnt algorithm be spelled alogrithm. People usually say "alog". Algo is more like "al go there" as in a phrase. Or maybe i am just dumb ![]() You're welcome to solve it in watever way you see fit, as long as it works. ![]() |
Author: | Delos [ Sun Jul 31, 2005 10:10 pm ] |
Post subject: | |
MysticVegeta wrote: by the ways, shouldnt algorithm be spelled alogrithm. People usually say "alog". Algo is more like "al go there" as in a phrase. Or maybe i am just dumb
![]() I'm not sure who you've been speaking to, but I've never heard anyone pronounce algorithm as "al-og-rithm". Check here for the pronouciation. |
Author: | Hikaru79 [ Sun Jul 31, 2005 10:20 pm ] |
Post subject: | |
Yup, it's "algorithm" ... interesting fact: the word is based on the name of the Persian Mathematician Al-Khwarizmi (pronounce it out -- it sounds like algorithm!) who also happens to be the guy who wrote the "al-Kitab al-mukhtasar fi hisab al-jabr wa'l-muqabala (حساب الجبر و المقابلة)". That word in the middle "al-jabr" is where our word for "Algebra" comes from. This guy, which the word "algorithm" is named after, is actually the father of algebra! ![]() Just thought that was neat. Sorry for the hijack ![]() |
Author: | zylum [ Mon Aug 01, 2005 7:29 am ] | ||
Post subject: | |||
haha i win... without cheating too!!!
thank you recursion! this problem is actaully very easy if you think about it... what i have is a 9x9 array of vectors which store the possible values of that location. i also have an array of ints which keeps track of which values are unknown. then you recursively try every single combination of numbers each time removing numbers from the possiblilities. i was at first trying to get this to work with turing but it would be hard to do without vectors... also while working on this i was trying to clone the array of vectors like: Tgrid = Vgrid.clone(); which Tgrid and Vgrid are both 2d arrays of vectors... the problem is that i only make a shallow copy of the 2d array, therefore im sending the direct reference of the original vectors to the new vectors. this means when i change the new vectors, so do the old ones... after many frustrating hours if finally realized this and fixed it by looping through the arrays and cloning each individual vector ![]() |
Author: | MysticVegeta [ Mon Aug 01, 2005 9:01 am ] |
Post subject: | |
nono, dont post the turing solution, genius. Save that for me and people my level ![]() ![]() |
Author: | Hikaru79 [ Mon Aug 01, 2005 11:07 am ] | ||||||
Post subject: | |||||||
Zylum, your program does some very wierd stuff. For example, I put in the tough puzzle that nobody has solved yet:
And yours spits out:
Well, that's a legal board position and all, but ... your program has switched around the clues! Almost all of them have disappeared... I tried it with a bunch of different puzzle files, and they all do this -- your program never gives a correct answer! It always just gives legal positions that do not match the clues that were given in the original puzzle ![]() Another example: Your program thinks this is the solution the wtd's original posted puzzle:
|
Author: | rizzix [ Mon Aug 01, 2005 1:53 pm ] |
Post subject: | |
YEs this is the issue i'm talking about.. i have a vague idea of a solution, its only a matter of implementing it. Hint: bla bla bla.. yes there was a hint here but I deleted, cuz i'm soo stupidly selfish and it gives away the solution anyways.. ![]() |
Author: | Hikaru79 [ Mon Aug 01, 2005 6:42 pm ] |
Post subject: | |
rizzix wrote: ROFL! solved! can't post it yet though... hehe i want those prizes from thestar.com!!!
![]() An iPod is it? Neat! ![]() what prizes? maybe i should hide my solution too ![]() |
Author: | rizzix [ Mon Aug 01, 2005 8:24 pm ] | ||||
Post subject: | |||||
oooh a new case eh? nope dosen't seem like it ![]()
as for your puzzle here's up to how much my program can solve before quitting: ![]()
|
Author: | zylum [ Mon Aug 01, 2005 8:58 pm ] | ||
Post subject: | |||
ok why you guys have to go scare me like that? lol when i was printing the solution i mixed up my col and row vars so it was printing the answer rotated 90 degrees lol. i made last minute changes before posting (better variable names) and missed the mistake. anyways its fixed now. the solution it gives me to the one rizzix posted is:
how could you guys ever doubt me? ![]() anyways, an interesting thing you can do with my program is enter all asterisks and it will spit out all possible ways the numbers can be arranged. There seems to be quite a few.. |
Author: | rizzix [ Mon Aug 01, 2005 11:08 pm ] |
Post subject: | |
nice zylum, but a couple of things... #1) your algorithm is the basic trial & error. It works, but it is the most inefficient. Nevertheless, congrants for being the first one to come up with a _working_ solution! #2) man... tidy up!! took me a while to figure out what ur doin... good job though! Eitherway, more meaningful names would have helped a lot. Also, a more OO approach would have cleaned things up pretty good. #) yea congrants again for being the first.. |
Author: | Hikaru79 [ Tue Aug 02, 2005 12:01 am ] |
Post subject: | |
Whoo, good job, zylum ![]() +50 BITS! Edit: Aw, crap =/ You're a mod. Well, it's the thought that counts right? ![]() |
Author: | rizzix [ Tue Aug 02, 2005 9:52 am ] |
Post subject: | |
mine passes part2 as well.. but only if it invovles a little trial & error. And no it's not the same as his. ok i've attached it... to compile & run using ant:
|
Author: | MysticVegeta [ Tue Aug 02, 2005 2:08 pm ] |
Post subject: | |
zylum wrote: anyways, an interesting thing you can do with my program is enter all asterisks and it will spit out all possible ways the numbers can be arranged. There seems to be quite a few.. Then that means your program has a fault. There are more than 1,000,000,000 possible ways made uptill now. Read it on the sudoku newspaper. ![]() ![]() ![]() Edit : Just found. There are 6,670,903,752,021,072,936,960 possibilites. Executes forever. |
Author: | zylum [ Tue Aug 02, 2005 8:16 pm ] |
Post subject: | |
MysticVegeta wrote: zylum wrote: anyways, an interesting thing you can do with my program is enter all asterisks and it will spit out all possible ways the numbers can be arranged. There seems to be quite a few.. Then that means your program has a fault. There are more than 1,000,000,000 possible ways made uptill now. Read it on the sudoku newspaper. ![]() ![]() ![]() Edit : Just found. There are 6,670,903,752,021,072,936,960 possibilites. Executes forever. how is my program at fault? i never said how many solutions there were, all i said is there are quite a few. meaning i ran the program for like 2 minutes and it was still giving me solutions. |
Author: | MysticVegeta [ Wed Aug 03, 2005 9:06 am ] |
Post subject: | |
ic ic, sry about that. I thought it told you the possible ways. Good job! Execute it for 1 hour and sell the puzzle to the local newspaper. ![]() |
Author: | wtd [ Thu Aug 18, 2005 2:39 pm ] | ||||
Post subject: | |||||
Still working on this, and not brute-forcing it. The fiendish game I'm working with is:
So far I can get it to:
My code thus far is attached. Yes, there's lots of reduce voodoo involving sets. ![]() I've implemented three solving techniques thus far. The simplest is to use the knowns to eliminate possibilities. The next technique is to look for unique unknowns. If only one square in a row, column, or zone has a possibility, then that must be the value of the square. The next technique looks at unknowns again, and determines if there are cases where you can determine that a certain number must be in a particular row or column within a zone. If so, then that number isn't in the corresponding row or column in other zones. |
Author: | MysticVegeta [ Sat Aug 20, 2005 12:03 pm ] |
Post subject: | |
I am getting nowhere with the turing solution but i am trying hard... |
Author: | wtd [ Sat Aug 20, 2005 4:23 pm ] |
Post subject: | |
MysticVegeta wrote: I am getting nowhere with the turing solution but i am trying hard...
I can imagine very few other languages that would make this as tedious as Turing. For instance, I find myself very frequently making use of lists or in other words, "dynamically sized collections": something that might have any number of items. Turing does not make dealing with such easy, and there are enough complications in this problem without wasting so much time on tedium. |
Author: | zylum [ Tue Aug 30, 2005 3:24 am ] | ||
Post subject: | |||
here's a turing solution:
have fun ![]() |
Author: | rizzix [ Tue Nov 29, 2005 12:26 pm ] |
Post subject: | |
Hi there guys... just to bring back this good old topic so as to let you know.. my algorithm fails against the Top95 sudoku puzzles (well at least against the 1st two anyway): Here, test your solutions against these: Top 95 and the so-called Impossible 520 Edit: I'm tying running zylum's solution against the 2nd of the Top95 and.. well on my old 450mhz cpu.. it's taking a really long time.. although i'm pretty sure it will solve it... (right?).. at some point anyway.. |
Author: | rizzix [ Tue Nov 29, 2005 1:08 pm ] | ||
Post subject: | |||
finally! solved! (took around 40min): solution to the 2nd one:
...it was solved using zylum's code btw. |
Author: | wtd [ Tue Nov 29, 2005 1:35 pm ] | ||||
Post subject: | |||||
I've been continuing to work on this using Python, and I have two possibility reduction techniques successfully implemented in my new, cleaner codebase. They're fairly simple. The first simply removes any possibilities that already occur in the row, column or zone (3x3 square). The second checks to see if an unsolved cell contains a possibility that is not present in the rest of the row, column, or zone. I can get from:
To:
Without guessing. A third strategy would allow me to proceed further, but I have not yet been able to successfully implement it. Consider the bottom left zone. In it, there is only one row where 9 can occur. Knowing that, I can cast it's "shadow" across the bottom middle zone. The fourth strategy would be to look for the resulting square created by cells at row 3 column 4, row 3 column 6, row 7 column 4 and row 7 column 6. Knowing that 9 is a possibility in all four of these, we can deduce that It has to occur in both of these rows and columns. Aside from these cells, 9 can be eliminated as a possibility from the other cells in those rows and columns. That makes it possible to deduce that the cell at row 4 column 5 has a value of 9. From that we can determine that row 5, column 2 has a value of 9. And from that we can figure out that row 8, column 3 has a value of 9. |
Author: | rizzix [ Wed Nov 30, 2005 1:51 am ] |
Post subject: | |
Constraint Programming: Solving Sudoku (a recent article on java.net) |
Author: | TheZsterBunny [ Tue Dec 13, 2005 8:03 pm ] | ||
Post subject: | |||
just got around to posting now. fixed up my algorithm a bit. uh, its working in swing, which is nice, but its limited as of now to 9x9, possible puzzles (of _any_ difficulty) here's the meat of the code, the rest is attached.
-Z |
Author: | MysticVegeta [ Wed Dec 14, 2005 6:57 pm ] |
Post subject: | |
Hmm. I got my Turing solution to work but takes long time. Strategy I used: Plug in Random numbers for each cell.. Test if works. Of course the random number I plug into the cell won't be in the row/column/3*3 grid. |
Author: | MysticVegeta [ Sat Dec 24, 2005 10:48 pm ] | ||
Post subject: | |||
Sorry I cannot see the button.. so anyways, heres my turing code, takes about 5-10 minutes to complete the solution... but hey! Its turing. There are several commented attempts/techniques I used but Random # brute force seems to be the best one that was able to solve the problem. Anyways, here.
Note: For the method #4 which is the working one, most of the declared vars are not required because they were used by other attempts so I decided to leave it in.... |
Author: | MysticVegeta [ Sun Dec 25, 2005 12:15 pm ] | ||
Post subject: | |||
zylum wrote: here's a turing solution:
have fun ![]() Still no edit button ![]() |
Author: | zylum [ Tue Dec 27, 2005 1:43 am ] |
Post subject: | |
its not that confusing... if the column is 10 that means i have filled in the last number and i print out the grid. otherwise i plug in one of the possiblilities for the current cell and then move on to the next cell... thats about it... along the way i update the possible numbers for the other cells to speed things up. |
Author: | MysticVegeta [ Tue Dec 27, 2005 11:20 am ] |
Post subject: | |
zylum wrote: along the way i update the possible numbers for the other cells to speed things up.
Ah thats the only part I am missing. and whats the logic behind updating the possible numbers? Because For example: Cell 1: Possibilities : 2,4. Taken #: 2 Cell 2: Posssibilities: 5, 7. Taken #: 5 Cell 3 : Possibilities : none because of some error in cell 1 and cell 2. So, what would you update because Either (2 is right and 5 is wrong) or (2 is wrong 5 is right) or (2 is wrong and 5 is wrong) |
Author: | Bored [ Tue Jan 31, 2006 11:07 pm ] |
Post subject: | |
I've created a Turing sudoku solver that uses recursion to solve the puzzle. It can solve any sudoku you throw at it because it can potentially check every possible solution until it fins the right one. I've compiled it incase you don't have turing and I've also added the source code that even if you don't know turing you should be able to follow. It works fairly fast but some puzzles may take quite a few seconds to solve. It starts by having you input a puzzle using arrow keys to move along the grid, numbers to input values, 0 or delete to delete a value and enter to solve puzzle. Try whatever soduko you can find and just try to beat it (with a solvable suduko). |
Author: | Bored [ Tue Jan 31, 2006 11:21 pm ] |
Post subject: | |
Fewww, Now that I look through I'm gald I didn't look past page 2 cus some people had already posted answers. Now that I look back I see the first post of a recursive solution. I had that same problem with mine where it would erase some of the clues. Turned out when it was reseting values back to zero whether they where a clue or not and I just had to move the 3 lines that reset the values back to 0. |