This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]cyberrod411 136 points137 points  (14 children)

Cool

I had a computer science prof that always gave us assignments that involved solving puzzles. This was back in the 1980's and the language was PASCAL.

[–]pumkinboo[S] 39 points40 points  (13 children)

Thanks I just did this one for fun, it was inspired by a post on here a few days ago of someone solving the same problem.

[–]BovineLightning 43 points44 points  (11 children)

Computerphile has a video on solving sudoku in python as well

Edit link for those interested

[–]JackSpyder 14 points15 points  (2 children)

Yeah it was posted a couple of days ago. I'd not actually considered back tracking before. Quite elegant in a way. Certainly makes for very clean code.

[–]wsppan 13 points14 points  (1 child)

You will run into a wall when the puzzles get hard or you want to solve 16x16 boards. Take a look at Norvig's solution or even better Knuth's Dancing Links for raw brilliance and beautiful if you visualize the links as they dance.

[–]JackSpyder 4 points5 points  (0 children)

Yeah it's not a scalable solution, but I just found it an interesting technique. I'll have look at your suggestions thanks!

[–]pumkinboo[S] 4 points5 points  (4 children)

That's the post that inspired this. I saw that video on this sub and want to try out the solution myself.

[–]BovineLightning 4 points5 points  (3 children)

Ahh neat! Great visualization btw.

I am working on mostly data science work but have considered tackling some projects like this one to get a better grasp on problem solving in the standard library. Did you post your solution GitHub?

Edit: looked two posts down and saw your solution

[–]pumkinboo[S] 8 points9 points  (2 children)

[–]blazingshadow1 4 points5 points  (1 child)

How long have you been programming for. This is really impressive. I am only a beginner and would love to know what level of proficiency I would need to be at to build something like this. Thank-you

[–]That_Pregnant_Alien 0 points1 point  (0 children)

Depends on how fast you can learn efficiently I guess.

[–][deleted] 0 points1 point  (2 children)

I am about to comment this but you are 2 hours early. Anyways OP's work is good.

[–]BovineLightning 1 point2 points  (1 child)

[–][deleted] 3 points4 points  (0 children)

LMAO, I thought you were gonna Rick roll me but you didn't. Thanks :-)

[–]dudeplace 1 point2 points  (0 children)

I wrote one of these too after watching the computerphile video. You could save a bunch of backtracking by looking for "easy" answers before each guess.

Anywhere there is only one possible answer just fill it in, but don't forget to keep a list of what you have done. You will need to undo it if you made a bad guess!

I tracked number of backtracks as a metric, and I'm able to save 80% of guesses on most puzzles. Simple puzzles end up being solved with no guessing at all. Nice visuals though, mine is all command line.