www.cambridge.edu.in
Department of Electronics &
Communication Engineering
Presented by:
Aswin Thapa(1CD21EC020)
Renewable Energy Resources
Subject Code: 21EE652
“TOPIC :WIND ENERGY”
1)What is Sudoku?
Sudoku is a logic-based, number-placement puzzle which is popular for testing reasoning
and logical skills.
2) Overview of the project
a. The objective of this project is to develop a Python-based 4x4 Sudoku solver that can take a
partially filled Sudoku grid as input, validate the initial configuration, and then solve the
puzzle using a backtracking algorithm.
b. The project aims to ensure that the Sudoku solver adheres to all standard Sudoku rules,
including row, column, and subgrid constraints.
INTRODUCTION
1. Input Validation: The program takes user input for the initial Sudoku configuration and ensures that the
input numbers are within the valid range (0-4). It also validates that the initial configuration does not violate
Sudoku rules.
2. Sudoku Solving: The solver uses a backtracking algorithm to fill the grid with numbers 1-4 in such a way
that no number repeats in any row, column, or 2x2 subgrid.
3. Subgrid Validation: The solver includes checks for 2x2 subgrid constraints, which is essential for the 4x4
Sudoku.
4. Output: The program prints the solved Sudoku grid if a solution exists. If the initial configuration is invalid
or no solution exists, it notifies the user accordingly.
Key Features
1. User Input: The user is prompted to enter the Sudoku puzzle row by row. Each row should consist of 4
numbers separated by spaces, with 0 representing an empty cell.
2. Validation Function (is_initial_valid): This function checks the initial input for any violations of Sudoku
rules in terms of row, column, and subgrid constraints.
3. Safety Check Function (is_safe): This function determines if a number can be placed in a given cell without
violating Sudoku rules.
4. Backtracking Solver (solve_sudoku): This function uses a backtracking approach to solve the puzzle. It
recursively tries to fill the empty cells with valid numbers and backtracks if a conflict is found.
5. Output Function (print_board): This function formats and prints the Sudoku grid in a readable manner.
Methodology
built-in functions and methods:
o input(): Used to take user input from the console.
o print(): Used to print output to the console.
o int(): Converts strings to integers.
o map(): Applies a function to all items in an input list.
o list(): Converts the output of map() to a list.
o range(): Generates a sequence of numbers.
o split(): Splits a string into a list of substrings based on a specified delimiter.
o strip(): Removes leading and trailing whitespace from a string.
o join(): Joins elements of a list into a single string with a specified separator.
Modules and Libraries
1)This project demonstrates the application of Python programming to solve a constrained
optimization problem using backtracking.
2)It highlights the importance of input validation and constraint checking in developing robust
algorithms.
3)The project provides a foundational understanding of solving Sudoku puzzles and can be
extended to larger grids or more complex constraints.
CONCLUSION
Output (Result) of the project work:
Thank you

python presentation.pptx which includes project details

  • 1.
    www.cambridge.edu.in Department of Electronics& Communication Engineering Presented by: Aswin Thapa(1CD21EC020) Renewable Energy Resources Subject Code: 21EE652 “TOPIC :WIND ENERGY”
  • 2.
    1)What is Sudoku? Sudokuis a logic-based, number-placement puzzle which is popular for testing reasoning and logical skills. 2) Overview of the project a. The objective of this project is to develop a Python-based 4x4 Sudoku solver that can take a partially filled Sudoku grid as input, validate the initial configuration, and then solve the puzzle using a backtracking algorithm. b. The project aims to ensure that the Sudoku solver adheres to all standard Sudoku rules, including row, column, and subgrid constraints. INTRODUCTION
  • 3.
    1. Input Validation:The program takes user input for the initial Sudoku configuration and ensures that the input numbers are within the valid range (0-4). It also validates that the initial configuration does not violate Sudoku rules. 2. Sudoku Solving: The solver uses a backtracking algorithm to fill the grid with numbers 1-4 in such a way that no number repeats in any row, column, or 2x2 subgrid. 3. Subgrid Validation: The solver includes checks for 2x2 subgrid constraints, which is essential for the 4x4 Sudoku. 4. Output: The program prints the solved Sudoku grid if a solution exists. If the initial configuration is invalid or no solution exists, it notifies the user accordingly. Key Features
  • 4.
    1. User Input:The user is prompted to enter the Sudoku puzzle row by row. Each row should consist of 4 numbers separated by spaces, with 0 representing an empty cell. 2. Validation Function (is_initial_valid): This function checks the initial input for any violations of Sudoku rules in terms of row, column, and subgrid constraints. 3. Safety Check Function (is_safe): This function determines if a number can be placed in a given cell without violating Sudoku rules. 4. Backtracking Solver (solve_sudoku): This function uses a backtracking approach to solve the puzzle. It recursively tries to fill the empty cells with valid numbers and backtracks if a conflict is found. 5. Output Function (print_board): This function formats and prints the Sudoku grid in a readable manner. Methodology
  • 5.
    built-in functions andmethods: o input(): Used to take user input from the console. o print(): Used to print output to the console. o int(): Converts strings to integers. o map(): Applies a function to all items in an input list. o list(): Converts the output of map() to a list. o range(): Generates a sequence of numbers. o split(): Splits a string into a list of substrings based on a specified delimiter. o strip(): Removes leading and trailing whitespace from a string. o join(): Joins elements of a list into a single string with a specified separator. Modules and Libraries
  • 6.
    1)This project demonstratesthe application of Python programming to solve a constrained optimization problem using backtracking. 2)It highlights the importance of input validation and constraint checking in developing robust algorithms. 3)The project provides a foundational understanding of solving Sudoku puzzles and can be extended to larger grids or more complex constraints. CONCLUSION
  • 7.
    Output (Result) ofthe project work:
  • 8.