This is a powerful sudoku solver that can find infinitely many solution to a given sudoku. This application is capable of finding 1, multiple or as many solutions to a sudoku as possible. I had written the same algorithm in C back then in 2006, but I cant seem to find it now. I tested it then, using compiler ifor90 (Intel Fotran Compiler, 2006 Edition) and found it to be more efficient that C, C++ or similar codes.

 

My Sudoku Solver I Wrote in 2006-2007 while learning to code in Fotran 90 !
  1 ! copyright @ 2007, arpan dubey
  2 ! simple sudoku solver .
  3 !
  4 ! FINITE SOLUTION VERSION !!
  5 !
  6 ! ******************************* SAMPLE ********************************
  7 !
  8 ! SAMPLE,UNIQUE SOLN.  SOLUTION
  9 !
 10 !  0 0 0 2 0 0 5 0 0   7 8 3 2 1 6 5 9 4
 11 !  0 0 4 0 0 8 3 7 0   2 1 4 9 5 8 3 7 6
 12 !  0 0 0 0 0 0 0 8 1   6 9 5 7 4 3 2 8 1
 13 !  0 0 7 6 0 1 4 0 0   9 2 7 6 8 1 4 3 5
 14 !  0 0 6 0 7 0 0 2 0   1 3 6 5 7 4 9 2 8
 15 !  5 0 0 3 2 0 1 0 0   5 4 8 3 2 9 1 6 7
 16 !  0 0 0 0 0 7 0 0 0   4 5 2 8 3 7 6 1 9
 17 !  3 0 9 0 6 0 8 4 0   3 7 9 1 6 5 8 4 2
 18 !  0 0 0 4 9 0 0 5 0   8 6 1 4 9 2 7 5 3
 19 !
 20 ! 2 SOLUTION SUDOKU    SOLUTION # 1        SOLUTION # 2
 21 !
 22 !  1 0 0 0 0 0 0 0 5   1 8 3 9 6 7 4 2 5   1 9 3 8 6 7 4 2 5  
 23 !  0 0 0 0 3 0 0 0 0   4 6 9 5 3 2 8 1 7   4 6 8 5 3 2 9 1 7
 24 !  0 0 2 0 4 0 0 0 0   7 5 2 1 4 8 6 9 3   7 5 2 1 4 9 6 8 3
 25 !  0 0 0 0 0 0 0 0 0   6 2 1 4 7 3 5 8 9   6 2 1 4 7 3 5 9 8
 26 !  0 3 4 0 0 0 7 0 0   5 3 4 8 1 9 7 6 2   5 3 4 9 1 8 7 6 2
 27 !  0 0 0 2 0 6 0 0 1   8 9 7 2 5 6 3 4 1   9 8 7 2 5 6 3 4 1
 28 !  2 0 0 0 0 5 0 0 0   2 1 6 3 8 5 9 7 4   2 1 6 3 9 5 8 7 4
 29 !  0 7 0 0 0 0 0 3 0   9 7 5 6 2 4 1 3 8   8 7 5 6 2 4 1 3 9
 30 !  0 0 0 0 0 1 0 0 0   3 4 8 7 9 1 2 5 6   3 4 9 7 8 1 2 5 6
 31 !  
 32 !
 33 ! ****************************************************************************
 34 
 35 module routines
 36 
 37   implicit none
 38 
 39   ! the sudoku size N, means a sudoku with NxN. n=9 means a common 9x9 Sudoku
 40   integer,parameter :: n=9
 41 
 42   ! .true. produces beautiful output on screen. .false. just prints array
 43   logical,parameter :: sorted_output=.true.
 44 
 45   ! options for multiple solutions 
 46   logical,parameter :: many_solutions=.true.         ! gives many solutions
 47   integer,parameter :: max_num_solutions=999999      ! maximum number solutions
 48   integer :: nsolutions                          ! how many solutions.
 49   real :: computation_time                           ! time took to computes
 50 
 51   ! the sudoku input file name.
 52   character(*),parameter :: input_file='sudoku.dat'  ! default input file.
 53
................. .............................................................
............................................................................... 
400   duration=finish-start
401   print*,'CPU TIME :',duration,'sec.'
402   print*,'copyright @ 2007, Arpan Dubey'
403   CLOSE(UNIT=2)
404   CLOSE(UNIT=3)
405 end program main
406

 

This is the Output to a 2 Solution Sudoku .

SOLUTION NUMBER 1 in 1.032064 secs
1 8 3 9 6 7 4 2 5
4 6 9 5 3 2 8 1 7
7 5 2 1 4 8 6 9 3
6 2 1 4 7 3 5 8 9
5 3 4 8 1 9 7 6 2
8 9 7 2 5 6 3 4 1
2 1 6 3 8 5 9 7 4
9 7 5 6 2 4 1 3 8
3 4 8 7 9 1 2 5 6
SOLUTION NUMBER 2 in 1.060066 secs
1 9 3 8 6 7 4 2 5
4 6 8 5 3 2 9 1 7
7 5 2 1 4 9 6 8 3
6 2 1 4 7 3 5 9 8
5 3 4 9 1 8 7 6 2
9 8 7 2 5 6 3 4 1
2 1 6 3 9 5 8 7 4
8 7 5 6 2 4 1 3 9
3 4 9 7 8 1 2 5 6

For a complete fortran90 mail me at dubey.arpan@gmail.com.

  1. TommyE

    Guys you should try dzaine money making system – brings me some good cash, just search it in google

Leave a Reply

Your email address will not be published. Required fields are marked *