Novices Plagiarizing Mozart

    slide-puzzle-solver

    1.0.2 • Public • Published

    slide-puzzle-solver

    Useful tool for https://hack.ainfosec.com/

    Solver for slide puzzle.

    Note that not every NxN puzzle is solvable. But this solver can solve every solvable puzzle with different sizes in limited time.

    More stable than DFS or A-star algorithm, instead of efficient.

    Usage

    const { solve } = require('slide-puzzle-solver')
    
    // 'X' stands for the empty slot
    const puzzle = [
      [1, 4, 3],
      [8, 7, 6],
      [2, 'X', 5],
    ]
    // The solution will be saved here
    // Valid moves are 'L', 'R', 'U', 'D' to move the 'X' piece Left, Right, Up, and Down respectively
    const steps = []
    
    // Returns the solved puzzle, while the origin `puzzle` will not be changed
    const solvedPuzzle = solve(puzzle, steps)

    Install

    npm i slide-puzzle-solver

    DownloadsWeekly Downloads

    5

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    23.2 kB

    Total Files

    9

    Last publish

    Collaborators

    • chinesedfan