Skip to content

Ran350/make10

Repository files navigation

make10

GitHub version Code Check

the npm library that solving Make 10 Puzzle

Make 10 Puzzle is the game that making 10 through using only 4 numbers and +-×÷.

Demo

You can play it in this web app.

Install

yarn add @ran350/make10
or
npm install @ran350/make10

Run the following command, if it gives the error such as error https://npm.pkg.github.com/download/@ran350/make10/(VERSION)/(HASH): Integrity checked failed for "@ran350/make10" (none of the specified algorithms are supported).

yarn add @ran350/make10 --update-checksums

Example

import { make10 } from "@ran350/make10";

console.log(make10(["1", "2", "3", "4"]));
// -> [ "((1+2)+3)+4", "((1+2)+4)+3", "(3+4)+(1+2)",
//      ... 51 more items
//    ]

console.log(make10(["1", "1", "9", "9"]));
// -> ["((1/9)+1)*9"]

console.log(make10(["2", "5"]));
// -> ["2*5"]

console.log(make10(["1", "2", "4"]));
// -> ["(1+4)*2"]

console.log(make10(["5", "9", "9", "9", "9"]));
// -> ["((9/9)+(9/9))*5"]

Algorithm

See here.