Git Product home page Git Product logo

sudoku's Introduction

Sudoku

A command-line Java program that lets you play Sudoku. It allows you to enter a digit at a position and solves the Sudoku puzzle by iteratively updating the game board.

The game board is printed in the console with different colors for initial system entries and user inputs. When the game is solved, it prints the solved board.

Requirements

Java 8 or later.

How to Run

  • Clone the repository or download the source code.
  • Navigate to the project directory. Compile the program by running the command javac sudoco.java.
  • Run the program by running the command java sudoco.

How to Play

  • The game board is displayed in the console, with positions numbered 0-8 for each row and column.
  • To enter a digit, input the position where you want to enter the digit in the format "row column". For example, to enter a digit in the first row and second column, type "0 1" and press Enter.
  • When prompted, enter the digit you want to place in the selected position.
  • If the digit you entered is not valid (i.e., outside the range of 1-9), you will be prompted to enter the digit again.
  • Continue entering digits until the game is solved.

Implementation Details

The game board is implemented as a two-dimensional array of integers. The program iteratively updates the board until the game is solved.

The ANSI codes for colors are used to print the game board in different colors.

The program includes the following functions:

main: The main function that runs the game loop. print: Prints the game board in the console. is_solved: Returns true if the game is solved. is_correct_index: Returns true if the given index is valid for the game board. is_correct_value: Returns true if the given value is valid for the given index.

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.