word-puzzle-shuffler

shuffle given two words properly so user can find out the word into the puzzle

Usage no npm install needed!

<script type="module">
  import wordPuzzleShuffler from 'https://cdn.skypack.dev/word-puzzle-shuffler';
</script>

README

Word Puzzle Shuffler

Build Status npm version GitHub repo size Greenkeeper badge

A simple package to shuffle given two words properly to the 3 x 3 matrices.

Table of Contents

Usage

npm install word-puzzle-shuffler

const shuffle = require('word-puzzle-shuffler')

const shuffledData = shuffle(['wordA: string, wordB: string])

shuffledData.getCellValues

getCellValues returns an array which includes shuffled letters from 0 - 9 indexes, Total length of the two words have to be 9 to fit in 3 x 3 matrices.

const shuffledData = shuffle(['LEMON', 'PEAR']);

const cellValues = shuffledData.getCellValues;

["E","N","O","A","P","M","R","E","L"]

proper cells value

shuffledData.getFirstWordIndexes

getFirstWordIndexes returns an array which provides indexes of the first word in 3 x 3 matrices.

const firstWordIndexes = shuffledData.getFirstWordIndexes;

[
    [2,2],
    [2,1],
    [1,2],
    [0,2],
    [0,1]
]

first word indexes

shuffledData.getSecondWordIndexes

getSecondWordIndexes returns an array which provides indexes of the second word in 3 x 3 matrices.

const secondWordIndexes = shuffledData.getSecondWordIndexes;

[
    [1,1],
    [0,0],
    [1,0],
    [2,0]
]

second word indexes

TODO

  • Improve the code so this package would work with (n x m ) matrices.
  • Add tests included edge cases.