Giter Club home page Giter Club logo

sudoku_validator's Introduction

Sudoku Validator

An excercise for Prime Subscribers. Visit http://learn.thoughtbot.com/prime to learn more.

Dificulty: Advanced Beginner

Your Task

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 contains all of the digits from 1 to 9.

Write a command-line program that can read a file containing a sudoku grid and validates it. The grid can be partially or completely solved. It either gives a success message or a list of errors and their positions.

Sample usage:

$ sudoku-validator ./valid_complete.sudoku
  This sudoku is valid.

$ sudoku-validator ./valid_incomplete.sudoku
  This sudoku is valid, but incomplete.

$ sudoku-validator ./invalid_complete.sudoku
  This sudoku is invalid.

$ sudoku-validator ./invalid_incomplete.sudoku
  This sudoku is invalid.

A sudoku is valid if:

  • it has no duplicates in a row
  • it has no duplicates in a column
  • it has no duplicates in a sub-grid

Input files

The input files look like this

8 5 . |. . 2 |4 . . 
7 2 . |. . . |. . 9 
. . 4 |. . . |. . . 
------+------+------
. . . |1 . 7 |. . 2 
3 . 5 |. . . |9 . . 
. 4 . |. . . |. . . 
------+------+------
. . . |. 8 . |. 7 . 
. 1 7 |. . . |. . . 
. . . |. 3 6 |. 4 . 

There are four sample sudoku files in this repo that you can use as input/test fixtures. They cover the permutations of valid/invalid and complete/incomplete

Working/Submitting

  1. To work on this exercise, fork the repo and begin implementing your solution.
  2. Your solution must be tested, preferably via TDD.
  3. Create a pull request so your code can be reviewed.
  4. Perform a code review on at least one other person's solution. Your comments should follow our code review guidelines: https://github.com/thoughtbot/guides/tree/master/code-review. Most important: be friendly. Make suggestions, not demands.
  5. Improve your solution based on the comments you've received and approaches you've learned from reviewing others' attempts.

sudoku_validator's People

Contributors

joelq avatar r00k avatar

Watchers

Artur Krasnyh avatar James Cloos avatar

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.