Click here to Skip to main content
Licence 
First Posted 27 May 2006
Views 17,258
Bookmarked 10 times

Sudoku Solver

By | 27 May 2006 | Article
The souurce code solves the soduku(Medum Level)

Introduction

   This is the source by which the Sudoku puzzle can be solved upto  MEDIUM Level

Description

    This puzzle is solved by two Main Functions

       1. findpossibilities()

               This function helps in finding all the possibilities of values that can be in a single cell.

here is the main part that finds the possibilities

 

For i = 0 To 8
    For j = 0 To 8
        If B(i, j) = 0 Then
           
            'check row
            For l = 0 To 8
                If B(i, l) <> 0 Then
                    temp = B(i, l) - 1
                    mem(i, j, temp) = 0
                End If
            Next l

            'check column
            For l = 0 To 8
                If B(l, j) <> 0 Then
                temp = B(l, j) - 1
                mem(i, j, temp) = 0
                End If
            Next l


            'check cell 3 x 3
            t1 = Int(i / 3)
            t2 = Int(j / 3)
            t1 = t1 * 3
            t2 = t2 * 3
            For l = t1 To (2 + t1)
                For m = (0 + t2) To (2 + t2)
                    If B(l, m) <> 0 Then
                        temp = B(l, m) - 1
                        mem(i, j, temp) = 0
                    End If
                Next m
            Next l
           
        Else
             For l = 0 To 8
                mem(i, j, l) = 0
             Next l
        End If
    Next j
Next i

       2. getmax()

              This function helps in finding the optimal value in the possibilities

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Diwahar A K

Web Developer

India India

Member

Diwahar is a Telecom Engineer working in Leading Telecom Service provider in INDIA.
Diwahar graduated from Manonamanium Sundaranar University in 2002 with a B.E. in Electronics and Comm Engg.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 28 May 2006
Article Copyright 2006 by Diwahar A K
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid