• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to print a 9x9 array?  RSS feed

 
Jim Venolia
Ranch Hand
Posts: 312
2
Chrome Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a Sudoku puzzle, I can display it fine, but how do I send it to the printer? Doing a screen cap doesn't count. Needs to have lines showing a 9x9 array, bonus if the starting numbers are bolded or somesuch.

To be honest a local paper has a contest where if you finish their puzzle in 4 days you can win a t-shirt. I spent 2 days writing a java Sudoku solver, now I don't care about the t-shirt I just want my name to show up where nobody of any importance can see it.

If you want the code let me know, I'll email it to you. It's really fun as every time I enter the solve routine I print out the depth, then use gnuplot to graph the results. Takes 2-3 seconds to solve the puzzle, I'm guessing 90% of that is printing the depth, but graphing the result is strangely hypnotic.
 
Campbell Ritchie
Marshal
Posts: 56209
171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What algorithm do you use to solve the puzzle? I used the naïve technique of subtracting from sets of available numbers so I can see backtracking. I had one puzzle (there is a chap at Coventry who has a database of 22000 puzzles) which took over 5× as long for the computer to solve as it took me with a pencil.
 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:What algorithm do you use to solve the puzzle?

Forget solving it. I'd like to know how to create a Sudoku puzzle, 'cause I bet once you've got that, the solution's easy.

Winston
 
Jim Venolia
Ranch Hand
Posts: 312
2
Chrome Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The algorithm is nothing but brute force recursion. I wrote it as I wanted to refresh my recursion skills.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!