Coder Social home page Coder Social logo

sudokupuzzle's Introduction

Print a Soduku Puzzle

Senior Interview Question

Offline assessment

Time allowed: 20-30mins

The Game

A Soduku Puzzle is a logic-based puzzle game that starts with a 9x9 tiled-square - illustrated below.

To play Sudoku the player must use the numbers from 1-9 inclusive and place each number only once

  1. Within a row left-to-right
  2. Vertically top to bottom
  3. Within each 3x3 square

The problem

Presented with a pattern of 81 digits, draw the initial Sudoku puzzle board.

  1. Each row should start with a bar |
  2. Each row should end with a bar |
  3. Every three rows should be separated with a row of hyphens
  4. The header and footer of the puzzle should be closed with a row of hyphens

For example a puzzle may look like this:

The Pattern: 120098357764000000589000000120098357764000000589000000120098357764000000589000000

|- - -|- - -|- - -|

|1 2 0|0 9 8|3 5 7|

|7 6 4|0 0 0|0 0 0|

|5 8 9|0 0 0|0 0 0|

|- - -|- - -|- - -|

|1 2 0|0 9 8|3 5 7|

|7 6 4|0 0 0|0 0 0|

|5 8 9|0 0 0|0 0 0|

|- - -|- - -|- - -|

|1 2 0|0 9 8|3 5 7|

|7 6 4|0 0 0|0 0 0|

|5 8 9|0 0 0|0 0 0|

|- - -|- - -|- - -|

Zeros have been used in the Pattern string to represent a space or non-number. You can use whichever you need.

Note this is for illustrative purposes only. The puzzle will not be solvable with the numbers from this pattern. The objective is just to draw the board. You maybe use this pattern and output as a guide.

Observation

This follows the same concept of a FizzBuzz test. I have included a FizzBuzz Test for reference.

Given the numbers 1..N, for every number that is divisible by 3, write "Fizz". For every number divisible by 5, write "Buzz". For any number that is both divisible by 3 and 5, write "FizzBuzz". A number should only have one output.

sudokupuzzle's People

Watchers

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.