Click here to Skip to main content
12,818,035 members (39,762 online)
Click here to Skip to main content
Add your own
alternative version

Stats

21.2K views
711 downloads
11 bookmarked
Posted 27 May 2006

Sudoku Solver

, 27 May 2006
Rate this:
Please Sign up or sign in to vote.
The souurce code solves the soduku(Medum Level)
<!-- Article Starts - DO NOT ADD HTML/BODY START TAGS-->

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

 

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

       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

Share

About the Author

Diwahar A K
Web Developer
India India
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.

You may also be interested in...

Comments and Discussions

 
GeneralMy vote of 3 Pin
ruddygonzalez23-Jul-12 21:07
memberruddygonzalez23-Jul-12 21:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170308.1 | Last Updated 28 May 2006
Article Copyright 2006 by Diwahar A K
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid