Code Monkey home page Code Monkey logo

sudoku-solution-validator's Introduction

Sudoku-Solution-Validator

Aim

A Sudoku puzzle uses a 9 × 9 grid in which each column and row, as well as each of the nine 3 × 3 subgrids, must contain all of the digits 1 · · · 9.

This project consists of designing a multithreaded application that determines whether the solution to a Sudoku puzzle is valid or not.

Theory

A thread is a basic unit of CPU utilization. It comprises a thread ID, a program counter, a register set, and a stack. It shares with other threads belonging to the same process its code section, data section, and other operating-system resources, such as open files and signals.

Implementation

Naive Implementation

sudoku_validator_naive.c is a naive implementation of the sudoku validator. Here we check all 3 conditions for valid sudoku serially.

Multithreaded Implementation

sudoku_validator.c creates 3 threads for checking each condition parallelly. It makes use of the Pthreads library which is a POSIX standard defining an API for thread creation and synchronization supported by UNIX and several other operating systems.

Results

To see the results visibly, we use the sleep() function defined in unistd.h. After checking each condition, we pause the execution of the program for 5 seconds.

Naive implementation

Results for naive implementation

Since the program is running serially and each function sleeps for 5 seconds, the execution time is about 15 seconds.

Multithreaded implementation

Results for multithreaded implementation

Since the conditions are running parallel to each other and each function sleeps for 5 seconds, the execution time is about 5 seconds only.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.