Difference between revisions of "Algo holics"
(→Assignment 1) |
(→Assignment 1) |
||
Line 31: | Line 31: | ||
− | If we run the sample-puzzle-1 (level- easy) file | + | If we run the sample-puzzle-1 (level- easy) file |
− | + | Text inside the sample-puzzle-1 is: | |
+ | 0 6 0 0 0 0 9 7 2 | ||
0 5 0 0 0 2 0 0 3 | 0 5 0 0 0 2 0 0 3 | ||
0 7 0 3 9 0 5 0 0 | 0 7 0 3 9 0 5 0 0 | ||
Line 42: | Line 43: | ||
7 0 0 9 0 0 0 2 0 | 7 0 0 9 0 0 0 2 0 | ||
9 2 5 0 0 0 0 4 0 | 9 2 5 0 0 0 0 4 0 | ||
+ | |||
+ | The output will be: | ||
+ | |||
+ | 1 6 3 4 5 8 9 7 2 | ||
+ | 4 5 9 7 1 2 8 6 3 | ||
+ | 8 7 2 3 9 6 5 1 4 | ||
+ | 2 9 7 1 6 5 4 3 8 | ||
+ | 5 8 6 2 3 4 1 9 7 | ||
+ | 3 4 1 8 7 9 2 5 6 | ||
+ | 6 1 4 5 2 3 7 8 9 | ||
+ | 7 3 8 9 4 1 6 2 5 | ||
+ | 9 2 5 6 8 7 3 4 1 | ||
=== Assignment 2 === | === Assignment 2 === | ||
=== Assignment 3 === | === Assignment 3 === |
Revision as of 04:06, 22 February 2019
GPU610/DPS915 | Student List | Group and Project Index | Student Resources | Glossary
Contents
Project Name Goes here
Team Members
- Sukhbeer Dhillon, Responsibilities...
- Gurpreet Singh, Some other responsibility
- Edgar Giang, Some other other responsibility
- Email All
Progress
Assignment 1
Sudoku Solver
Is it a program that solves Sudoku puzzles(9X9) using Bruteforce algorithm. Either the user can pass a Sudoku files as an input or enter the values manually. Moreover, the file or the manual entry should have strictly 9 rows and 9 columns in them. Lastly, all the cells should be separated by a space and the cells that needs to be solved should have 0 in them as their value.
The original source code can be found at Link
LOGIC
In this program the Bruteforce algorithm first put 1 in the first cell and then check if it is violating any rules. If yes, then it increment the value to 2 and check again (The value can vary from 1-9) until it finds the appropriate value. After finding a suitable value for the first cell, it moves to the second cell and put 1 in there and again check again if it violating any rules. If it is discovers that 1 is not allowed in that cell, then the algorithm will increment it to 2 and check again.
Compiling the program
g++ -std=c++0x -pg solver.cpp checks.cpp checksolution.cpp -o a a fileName
-pg directs the compiler to include the executable code required for profiling.
-o directs the compiler to name the executable a.
If we run the sample-puzzle-1 (level- easy) file
Text inside the sample-puzzle-1 is:
0 6 0 0 0 0 9 7 2 0 5 0 0 0 2 0 0 3 0 7 0 3 9 0 5 0 0 2 0 0 0 0 5 4 0 8 0 0 0 0 0 0 0 0 0 3 0 1 8 0 0 0 0 6 0 0 4 0 2 3 0 8 0 7 0 0 9 0 0 0 2 0 9 2 5 0 0 0 0 4 0
The output will be:
1 6 3 4 5 8 9 7 2 4 5 9 7 1 2 8 6 3 8 7 2 3 9 6 5 1 4 2 9 7 1 6 5 4 3 8 5 8 6 2 3 4 1 9 7 3 4 1 8 7 9 2 5 6 6 1 4 5 2 3 7 8 9 7 3 8 9 4 1 6 2 5 9 2 5 6 8 7 3 4 1