All Projects → bertoort → sugoku

bertoort / sugoku

Licence: other
Sudoku puzzle solver and generator

Programming Languages

go
31211 projects - #10 most used programming language
HTML
75241 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Labels

Projects that are alternatives of or similar to sugoku

Puzzlemaker
Swift framework responsible for generating puzzles from the image
Stars: ✭ 99 (-6.6%)
Mutual labels:  puzzle
Nodulus
Puzzle game with clever twists (Unity3d)
Stars: ✭ 232 (+118.87%)
Mutual labels:  puzzle
avast-ctf-cambridge-2018
🎖 A complete write-up of the Avast challenge given at Hack Cambridge 2018
Stars: ✭ 16 (-84.91%)
Mutual labels:  puzzle
Vue Puzzle Vcode
vue 拼图人机验证 右滑拼图验证
Stars: ✭ 108 (+1.89%)
Mutual labels:  puzzle
Antimine Android
Antimine is an open source minesweeper-like puzzle game.
Stars: ✭ 218 (+105.66%)
Mutual labels:  puzzle
sliding-puzzle
Sliding puzzle game implemented in Scala / Scala.js / JavaFX
Stars: ✭ 25 (-76.42%)
Mutual labels:  puzzle
Codedojos
Code dojos
Stars: ✭ 84 (-20.75%)
Mutual labels:  puzzle
omo
Kotlin port with changes and improvements for omo originally by ForeignGuyMike
Stars: ✭ 22 (-79.25%)
Mutual labels:  puzzle
Breaklock
Web game, hybrid of Mastermind and the Android pattern lock
Stars: ✭ 232 (+118.87%)
Mutual labels:  puzzle
crackerjack
A collection of crackmes
Stars: ✭ 37 (-65.09%)
Mutual labels:  puzzle
Adpuzzleanimation
Inspired by Fabric - Answers animation. Allows to "build" given view with pieces. Allows to "destroy" given view into pieces
Stars: ✭ 123 (+16.04%)
Mutual labels:  puzzle
Cube Composer
A puzzle game inspired by functional programming
Stars: ✭ 1,845 (+1640.57%)
Mutual labels:  puzzle
pw
Best websites a Programmer should visit
Stars: ✭ 27 (-74.53%)
Mutual labels:  puzzle
Matchimals.fun
🦁 🃏 📱 An animal matching puzzle card game– built with turn-based game engine boardgame.io and React-Native + React-Native-Web
Stars: ✭ 101 (-4.72%)
Mutual labels:  puzzle
open-spelling-bee
🐝 Terminal-based python clone of New York Times' puzzle game "Spelling Bee"
Stars: ✭ 38 (-64.15%)
Mutual labels:  puzzle
Opencx
An open-source cryptocurrency exchange toolkit for implementing experimental exchange features
Stars: ✭ 86 (-18.87%)
Mutual labels:  puzzle
Rush
Rush Hour puzzle goodies!
Stars: ✭ 233 (+119.81%)
Mutual labels:  puzzle
alokmenghrajani.github.com
Alok Menghrajani's Blog
Stars: ✭ 64 (-39.62%)
Mutual labels:  puzzle
PuzzleBox
Generate 3D puzzle box (OpenSCAD source)
Stars: ✭ 92 (-13.21%)
Mutual labels:  puzzle
30secondchallenge
Inspired by the newspaper puzzle my wife's grandma tests me with each time I visit.
Stars: ✭ 19 (-82.08%)
Mutual labels:  puzzle

suGOku

https://sugoku.herokuapp.com/

Go Challenge 8 solution for the month of November 2015.

Overview

Sudoku web app: solves, generates, grades, and validates sudoku puzzles.

The algorithm implements two solving functions:

  1. QuickFill - Called so because it quickly checks horizontally, vertically and in the nine grid box for possible options. If only one possible solution remains, it adds the value to the square.

  2. Guess - It fills an empty square with a possible, non-conflicting value. If the puzzle is solved (completely filled), it validates to see if it correct. If not, it goes back and fills the square with another possible value. It recursively fills in and backtracks until the puzzle is complete.

A very interesting finding was that implementing the QuickFill function before each guess did not improve the speed of the algorithm, in fact, it slowed it down. I was not expecting it. I was so surprised that I decided to keep the original name I had given the function without Quickfill: SlowSolve().

SlowSolve is the faster function and therefore the one used for the API.

Installation

go get github.com/bertoort/sugoku

Technologies

API

Get

Board - returns a puzzle board

https://sugoku.herokuapp.com/board

Arguments -

  • Difficulty:
    • easy
    • medium
    • hard
    • random

Example:

https://sugoku.herokuapp.com/board?difficulty=easy

Post

Solve - returns the solved puzzle, along with difficulty and status

https://sugoku.herokuapp.com/solve

Grade - returns the difficulty of the puzzle

https://sugoku.herokuapp.com/grade

Validate - returns the status of the puzzle

https://sugoku.herokuapp.com/validate

NOTE:

The request does not support content-type of application/json. It must be application/x-www-form-urlencoded

To help, here is a quick and dirty encoding functions for a board:

const encodeBoard = (board) => board.reduce((result, row, i) => result + `%5B${encodeURIComponent(row)}%5D${i === board.length -1 ? '' : '%2C'}`, '')

const encodeParams = (params) => 
  Object.keys(params)
  .map(key => key + '=' + `%5B${encodeBoard(params[key])}%5D`)
  .join('&');

Here is an example sending a board:

const data = {board:[[0,0,0,0,0,0,8,0,0],[0,0,4,0,0,8,0,0,9],[0,7,0,0,0,0,0,0,5],[0,1,0,0,7,5,0,0,8],[0,5,6,0,9,1,3,0,0],[7,8,0,0,0,0,0,0,0],[0,2,0,0,0,0,0,0,0],[0,0,0,9,3,0,0,1,0],[0,0,5,7,0,0,4,0,3]]}

fetch('https://sugoku.herokuapp.com/solve', {
  method: 'POST',
  body: encodeParams(data),
  headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
})
  .then(response => response.json())
  .then(response => console.log(response.solution))
  .catch(console.warn)
jQuery Example:
var data = {
  board: "[[0,0,1,0,0,0,0,0,0],
          [2,0,0,0,0,0,0,7,0],
          [0,7,0,0,0,0,0,0,0],
          [1,0,0,4,0,6,0,0,7],
          [0,0,0,0,0,0,0,0,0],
          [0,0,0,0,1,2,5,4,6],
          [3,0,2,7,6,0,9,8,0],
          [0,6,4,9,0,3,0,0,1],
          [9,8,0,5,2,1,0,6,0]]"
}
$.post('https://sugoku.herokuapp.com/solve', data)
  .done(function (response) {

    <% response = {
      difficulty: "hard",
      solution: Array[9],
      status: "solved"
    } &>    

  });```

For more, check out the [api.js](https://github.com/BertoOrt/sugoku/blob/master/public/api.js) file
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].