Haui's Bytes (Posts about Sudoku)https://haui.pdesnet.org/enContents © 2019 <a href="mailto:haui45@web.de">Haui</a> Sat, 24 Aug 2019 18:02:58 GMTNikola (getnikola.com)http://blogs.law.harvard.edu/tech/rss Sudokuhttps://haui.pdesnet.org/posts/sudoku/Haui<div><p>Solving sudoku puzzles usually requires nothing more than a pen and some time. Solving 50 sudoku puzzles, however,
requires a huge amount of time. 50 sudoku puzzles...? Yep, to get the solution for <a class="reference external" href="http://projecteuler.net/problem=96">Problem 96</a> on ProjectEuler,
50 sudokus need to be solved first. I've solved my first 49 problems on ProjectEuler a few years ago and recently rediscovered the website. So I started
with the sudoku problem and got the solution quite fast by using a simple brute force algorithm. I'm not going to post the solution for the problem,
but just the C++ code for my <a class="reference external" href="http://pdesnet.org/xhaui/scripts/misc/sudokusolver.cpp">sudoku solver</a>. After compiling the program with
<tt class="docutils literal">g++ <span class="pre">std=c++11</span> <span class="pre">O6</span> <span class="pre">o</span> sudokusolver sudokusolver.cpp</tt>, sudokus given in an input file are solved with a simple recursion based algorithm.
An example is given below:</p>
<pre class="literalblock">
Trying to solve:

003020600
900305001
001806400
008102900
700000008
006708200
002609500
800203009
005010300


V

483921657
967345821
251876493
548132976
729564138
136798245
372689514
814253769
695417382

</pre>
<p>The sudokus in the input file must consist of 9 consecutive lines containing the initial values inside the sudoku. Blank fields are represented by zero.
Multiple sudokus have to be separated by at least one dash in a single line.</p></div>ProjectEulerSudokuhttps://haui.pdesnet.org/posts/sudoku/Fri, 06 Sep 2013 10:00:00 GMT