Code Monkey home page Code Monkey logo

sudoku's Introduction

A Bit of Documentation

NOTE : I AM LAZY AND THIS IS OUT OF DATE.

Puzzle Object Prototype

function Puzzle(puz, dis, pos) {
    this.value = puz;
    this.isDisabled = dis;
    this.possibles = pos;
}

The Puzzle prototype contains 3 arrays, each of size 81: value, disabled, and possibles. Values contains strings of each cells current number value, with "0" saved for an empty cell. isDisabled contains a boolean value, true if the cell should be immutable. Possibles contains strings that go into the uper left of each cell, allowing the user to save possible values for each cell.

Currently Implemented Methods

  • highlightRow

    Pass a row and column, this function will visually highlight an entire row and the specific cell.

  • highlightColumn

    Pass a row and column, this function will visually highlight an entire column and the specific cell.

  • highlightBox

    Same as the above two, but this one higlights the box that the cell is in. I'm proud of this one, it uses MATH.

  • clearPuzzle

    Clears the sudoku board.

  • clearPuzzleStyles

    Removes any inline style attributes from the puzzle cells.

  • updateButtons

    Shows/hides buttons depending on the state of the puzzle. If the puzzle is empty (void of any numbers) it hides:

    • Save
    • Clear
    • Possibles
    • Next
    • Solve As soon as any input is made or numbers are loaded into the puzzle it shows the buttons again.
  • showButtons

    Helper method to show the applicable buttons.

  • hideButtons

    Helper method to hide the applicable buttons.

  • displayPuzzle

    Takes a Puzzle object displayes all included info in relevant place on the board.

  • puzzleToObject

    Returns the currently displayed puzzle as a Puzzle object.

  • savePuzzle

    Accepts a key string and puzzle array and saves it to localStorage. Requires browser support.

  • loadPuzzle

    Accepts a key string and loads the matching puzzle from localStorage, if it exists.

  • countFilled

    Returns the number of currently filled in squares on the puzzle board.

  • updateProgressBar

    Updates the progress bar displayed (if supported) below the puzzle to reflect the percentage of cells completed.

sudoku's People

Contributors

ccoley avatar

Stargazers

 avatar

Watchers

Tyler Davis avatar James Cloos avatar  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.