Top-Rated Free Essay
Preview

Paradise Lost or Gain

Powerful Essays
1773 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Paradise Lost or Gain
[pic]

TERM PAPER

Foundation of computing

CSE 101

Topic : - Sudoku game

DOA : -02/11/2010

DOS : -20/11/2010

Submitted to : - Submitted by : -

Gagandeep Kaur Vaibhav Kumar Tripathi

Deptt. Of foundation computing Roll no: -RG4003A34

Section: -G4003

Reg.no:- 11000653

ACKNOWLEDGEMENT

I owe a great thanks to many people who helped and supported me during the writing of this term paper.

My deepest thanks to lecturer, Gagandeep Kaur the guide of the project for guiding and correcting various document of mine with attention and care. She has taken pain to go through the term paper and make necessary correction as and when needed.

I would also thank my institution and my faculty members without whom this term paper.

I would have been distant realty. I also extent my heartfelt thanks to my family and well wishers …

Vaibhav Kumar Tripathi

Lovely Professional University

CONTENTS

1. INTRODUCTION TO C

(A)INTRODUCTION TO SUDOKU

2. HISTORY

3. MATHEMATICS OF SUDOKU

4. RECENT POPULARITY

5. LIST OF ORGANISATION AND CONVENTIONS

(A) GRID LAYOUT AND PUZZLE TERMS

(B) SUDOKU VARIANTS

(C) SUDOKU TYPES AND CLASSES

(D) VARIANTS BY SIZE

6. CONSTRAINTS AND CLUE VARIANTS

7. SOURCE CODE

8. ADVANTAGES

9. REFERENCES

Introduction

C was one of the first general-purpose high-level programming languages to gain almost universal use, and today you can program in C on almost any platform and machine. It was created by Dennis Ritchie in 1971, as the successor to the "B" compiler, for UNIX systems.

Sudoku is a logic-based, combinatorial number-placement puzzle. The objective is to fill a 9×9 grid with digits so that each column, each row, and each of the nine 3×3 sub-grids that compose the grid (also called "boxes", "blocks", "regions", or "sub-squares") contains all of the digits from 1 to 9. The puzzle setter provides a partially completed grid. Completed puzzles are usually a type of Latin square with an additional constraint on the contents of individual regions . Sudoku was popularized in 1986 by the Japanese puzzle company Nikoli, under the name Sudoku, meaning single number.It became an international hit in 2005.

[pic][pic]

Histroy
Number puzzles first appeared in newspapers in the late 19th century, when French puzzle setters began experimenting with removing numbers from magic squares. Le Siècle, a Paris-based daily, published a partially completed 9×9 magic square with 3×3 sub-squares on November 19, 1892. It was not a Sudoku because it contained double-digit numbers and required arithmetic rather than logic to solve, but it shared key characteristics: each row, column and sub-square added up to the same number.

Grid layout and puzzle terms

A Sudokugrid has 9 rows, columns and boxes each having 9 cells. The full grid has 81 cells. Cells are commonly called squares, but in technical descriptions the term square is avoided since the boxes and grid are also squares. Boxes are also known as blocks or zones. Three vertically stacked blocks make a stack. Three horizontally connected blocks make a band. A chute is either a band or a stack. A grid has 3 bands, 3 stacks and 6 chutes.
The use of the boxes to partition the grid can be generalized to other equal sized partition shapes, in which case the sub-areas are known as regions, zones, subgrids, or nonets. See Variants below. In some cases the regions are only equal sized, not equal shaped.
Rows, columns and regions are collectively referred to as units or scopes, of which the grid has 27. The One Rule can then be compactly stated as: 'Each digit appears once in each unit'.
Size refers to the size of a puzzle or grid. Often a composite row × column designation is used, e.g. size 9×9. In technical discussions size may mean the number of cells, e.g. 81. Since the number of cells in a region must be the side dimension of the square grid, e.g. 9 cells per block for a 9×9 grid, it is convenient to just use the region size, e.g. 9.

Terms related to solving

The meanings of most of these terms can be extended to region shapes other than blocks. To simplify reading, definitions are given only in terms of blocks or boxes.
Scanning

the process of working through a puzzle to look for or eliminate values

cross hatching

process of elimination that checks rows and columns intersecting a block for a given value to limit the possible locations in the block

Counting

process of stepping through the values for a row, column or block to see where they can or cannot be used

Box line reduction strategy

A form of intersection removal in which candidates which must belong to a line can be ruled out as candidates in a block (or box) that intersects the line in question.

Candidate

Potential value for a cell.

Contingency

A condition limiting the location of a value.

Chain

A sequence of contingencies connected by alternative values.

Higher circuits

Related locations outside the immediate row, column and grid. The locations are related by value contingencies.

Independent clues

A set of clues that cannot be deduced from each other. Often depends on the order of choosing the clues for a given grid.

Intersection removal

When any one number occurs twice or three times in just one unit (or scope) then we can remove that number from the intersection of another unit. For example, if a certain number must occur on a certain line, then occurrences of that number found in a block that intersects this line can be ruled out as candidates. Sometimes called Pointing (or matched) Pairs (or twins)/Triples (triplets) as they point out a candidate that can be removed.

Trial and error

the process of guessing successive candidate values in conjunction with deductive elimination. A.k.a.: what-if, bifurcation, garden of forking paths, depth first search, exhaustive search, back-tracking search, Ariadne's thread. Note: there is no clear boundary between trial-and-error and the use of pattern recognition strategies to eliminate values (higher circuits), the latter being a condensed form of analysis based on elimination by contradiction, i.e. the same as what-if.

The One Rule

fill in all (blank) cells so that each row, column and box contains the values 1-9. Same as: fill in the grid so that each row, column and box contains the values 1-9 exactly once, without changing the clues.

Hidden single

a candidate that appears with others, but only once in a given row, column or box.

Locked candidate

a candidate limited to a row or column within a block.

Naked pair

Two cells in a row, column or block, which together contain only the same two candidates. These candidates can be excluded from other cells in the same row, column or block.

Hidden pair

Two candidates that appear only in two cells in a row, column or block. Other candidates in those two cells can be eliminated.

Trio

Three cells in a unit sharing three numbers exclusively. See "Triples and quads".

Triples and quads

the concepts applied to pairs can also be applied to triples and quads.

X-wing

See N-fish (with N=2).

Swordfish

See N-fish (with N=3).

N-fish

Analogues of hidden pairs/triples/quads for multiple rows and columns. A pattern formed by all candidate cells for some digit in N rows (or columns), that spans only N columns (rows). All other candidates for that digit in those columns (rows) can then be excluded. Names for various N-fish:

• 2-fish : X-wing • 3-fish : Swordfish • 4-fish : Jellyfish • 5-fish : Squirmbag - For 9×9 Sudoku, there's no in point naming higher-order (>4) fish, since every N-fish comes paired with a 9-N fish whose effect is the same (thus any 5-fish is paired with a jellyfish; any 6-fish with a swordfish; any 7-fish with an x-wing; any 8-fish with a hidden or naked single). Nevertheless, a 5-fish is occasionally called a squirmbag. • 6+ fish : 6-gronk, 7-gronk.. - these patterns are only useful for Sudoku larger than 9×9.
Remote Pairs When a long string of naked pairs that leads around the grid exists, any cells that are in the intersection of the cells at the beginning and the end of the string may not be either of the numbers in the naked pairs, for example, 4 and 7.

Source Code

#include

#include

#include

#define TRUE 1

#define FALSE 0

#define NULL 0

#define err_rec_lmt 1000

#define err_ip "\n\nINVALID INPUT!! Please Try Again !!"

#define err_file "\n\nERROR!! FILE CANNOT BE OPENED!!"

/* Global Variable declarations */

int sgrid[10][4][4]; /* A 3D Integer array that will store the members

of individual sub grids in it */

int sol[10][10];

int poss[10][10][10];

int trace_no_rec=0;

int ip_mode,op_mode;

int elims_exhausted=FALSE;

FILE *fp;

/* Function Declarations */

/* I/P - O/P Functions & I/P Verification */

void ip_solvesudoku();

void ip_storesudoku();

void change_settings();

void ascertain_mode();

int verify_ipval(int ip[10][10]);

/*Board Displaying Funcs */

void align_N_create(int ip[10][10]);

void create_boardpattern(int i,int c[]);

/* Intermediate checking/groundwork Funcs */

void initialize_subgrids(int sgrid[10][4][4]);

int get_subgrid(int row,int col);

void change_subgrid(int k,int row,int col);

int verify_placing(int i,int row,int col);

int all_entries_placed(int sol[10][10]);

/* RECURSIVE Funcs - the main Brain of the Prog */

void solve_get_basic_vals(int sol[10][10]);

//void solve_advanced_elims(int sol[10][10]);

//void solve_still_no_sol(int sol[10][10]);

/* MAIN PROGRAM */

void main()

{

char choice;

clrscr();

printf("******* TEST VERSION *******");

getch();

do{

clrscr();

printf("MAIN MENU");

printf("\n\n\n1. SOLVE a Sudoku Puzzle");

printf("\n\n2. STORE a Sudoku Puzzle & its Solution");

printf("\n\n3. CHANGE Settings/Preferences");

printf("\n\n4. Credits");

printf("\n\n5. Exit");

printf("\n\nEnter your choice : ");

scanf("%d",&choice);

clrscr();

switch(choice)

{

case 1:

ascertain_mode();

ip_solvesudoku();

break;

case 2:

ip_storesudoku();

break;

case 3:

change_settings();

break;

case 4:

printf("Created & Conceived By : Rajiv A Iyer");

printf("\nCopyright 2005 - Rai");

printf("\n\nAlgorithm adopted from the site :\n");

printf("http://www.eddaardvark.co.uk/sudokusolver.html");

getch();

break;

case 5:

break;

default:

printf("\a%s\a",err_ip);

getch();

}

//getch();

}while(choice!=5);

}

/* I/P-O/P Functions & I/P Verification Functions Begin */

/* This Routine asks for I/P from user to solve a Sudoku Puzzle & ATTEMPTS

to solve it, by calling the Recursive routine : "solve_get_basic_vals()" */

void ip_solvesudoku()

{

int i,j,k,n,ip[10][10],ipno_tmp;

int flag;

do{

/* Initializing all the entries of array 'ip' & 'sol' to default value of '0' */

for(i=0;i

You May Also Find These Documents Helpful

  • Satisfactory Essays

    In 1970 C programing was created by Dennis Richie and ken Thompson was made to create portability in UNIX…

    • 388 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Lockheed Martin Operations

    • 4351 Words
    • 18 Pages

    I would like to thank my lecturer and all the people who help me in the completion of this assignment through their valuable input.…

    • 4351 Words
    • 18 Pages
    Powerful Essays
  • Better Essays

    Next, want to thank my family for the support given all these while. Thank you for the encouragement given physically and emotionally.…

    • 2149 Words
    • 9 Pages
    Better Essays
  • Powerful Essays

    Task 1

    • 2644 Words
    • 8 Pages

    Procedural programming uses C programming language. C is considered to be a general purpose, work-horse language ideal for creating applications. Operating systems and interfacing with electronic control systems. It was made in 1972 by Dennis Ritchie at the Bell Telephone Laboratories. Unlike languages such as BASIC and PASCAL, C relies on symbols rather than keywords. As such, it is often described as being ‘terse’ and more difficult to learn, but typically offer more powerful solutions…

    • 2644 Words
    • 8 Pages
    Powerful Essays
  • Good Essays

    Paradise Lost

    • 253 Words
    • 2 Pages

    One of Milton's strengths used in his epic Paradise Lost is his vivid imagery. He uses imagery not only for visual impact but also for reinforcing themes and characterization. Many of the images used pertain to light and dark, which help to convey his main purpose of justifying the ways of God to man and illustrating Hell. Milton justifies the ways of God to man all throughout his story. Line twenty-two explains to man that God can make the darkness in one's life go away by bringing "light" to his situation. This is exemplified when Milton writes "What in me is dark Illumine what is low raise and support," which means that God can pick up those who have fallen or who are not sturdy, as well as improve misfortunes in one's life. Milton also uses imagery to display the power of God and characterizes Hell. "Him the Almighty Power hurled head long flaming from the ethereal sky with hideous ruin and combustion down to bottomless perdition," illustrates that God is very powerful and how He cast Satan into Hell. Milton goes on to show the reader, with images of light and dark, that Hell is "A dungeon horrible, on all sides round as one great furnace flamed, yet from those flames no light, but rather darkness visible." With his use of imagery, Milton is able to let the reader into another world and can see what God can do for mankind and see what Hell looks…

    • 253 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    The war

    • 1240 Words
    • 5 Pages

    B.A. in Mathematics, Reed College, 1971. M.Sc. 1974, Ph.D. 1979, in Computer Science, Stanford University. Fulbright Senior Scholar Award (1997); Fellow of the Association Computing Machinery, 2001.…

    • 1240 Words
    • 5 Pages
    Satisfactory Essays
  • Powerful Essays

    UNIX was moved from the now obsolete PDP-7 to the much more modern PDP-11/20 and…

    • 4831 Words
    • 20 Pages
    Powerful Essays
  • Good Essays

    Paradise Lost

    • 437 Words
    • 2 Pages

    In the epic poem, Paradise Lost by John Milton, he uses the theme of jealousy. Milton uses many examples of this theme throughout the poem. He uses Satan’s jealousy of God’s power, Heaven, and Adam and Eve as examples of the theme of jealousy.…

    • 437 Words
    • 2 Pages
    Good Essays
  • Powerful Essays

    We would like to express our special thanks of gratitude to Prof. Usha Kumar as well as BVIMSR respectively who gave us the golden opportunity to work on this wonderful project covering the topic of:…

    • 3695 Words
    • 15 Pages
    Powerful Essays
  • Satisfactory Essays

    Sudoku game

    • 281 Words
    • 2 Pages

    A typical Sudoku puzzle grid, with nine rows and nine columns that intersect at square spaces.…

    • 281 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Abstract: This paper presents an innovative prototype design of electric fan with smart characteristics. This electric fan uses a…

    • 2529 Words
    • 11 Pages
    Powerful Essays
  • Powerful Essays

    NETWORK BANDWIDTH

    • 2338 Words
    • 14 Pages

    Network Bandwidth Predictor (NBP): A System for Online Network performance Forecasting Alaknantha Eswaradass, Xian-He Sun, Ming Wu Department of Computer Science Illinois Institute of Technology Chicago, Illinois 60616, USA {eswaala, sun, wuming}@iit.edu Abstract The applicability of network-based computing depends on the availability of the underlying network bandwidth. However, network resources are shared and the available network bandwidth varies with time.…

    • 2338 Words
    • 14 Pages
    Powerful Essays
  • Powerful Essays

    MGT 101

    • 3366 Words
    • 17 Pages

    We also acknowledge our gratitude to those persons who have helped us and passed their valuable comments on the draft of the assignment paper. If you need any assistance in interpreting this term paper, please contact us at any time.…

    • 3366 Words
    • 17 Pages
    Powerful Essays
  • Satisfactory Essays

    I owe thanks to many people who have helped and supported me during the writing of this report.…

    • 720 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Minor

    • 15260 Words
    • 62 Pages

    Cambridge International A & AS Level Computing 9691. Examination in June and November 2013. © UCLES 2009…

    • 15260 Words
    • 62 Pages
    Satisfactory Essays

Related Topics