New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

24game-solver

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

24game-solver

Solve 24 Game with less duplicated results.

Source
npmnpm
Version
0.2.5
Version published
Weekly downloads
49
-43.02%
Maintainers
1
Weekly downloads
 
Created
Source

24 Game Solver

Solve 24 game with less duplicated results.

Web based example can be launched from https://frank-deng.github.io/24game-solver/index.html.

Package expression-calculator is required for calculating RPN expressions.

Usage

Node

var solve24game = require('24game-solver');

/*
The returned result contains all the expressions which calculation result equals the goal.
Parameter a, b, c, d are numbers between 1 and 13
Parameter goal is the expected calculation result, default is 24.
*/
var result = solve24game(a, b, c, d, goal);

Brwoser

<script type='text/javascript' src='exprcalc.min.js'></script>
<script type='text/javascript' src='24game-solver.js'></script>
<script type='text/javascript'>
	/*
	The returned result contains all the expressions which calculation result equals the goal.
	Parameter a, b, c, d are numbers between 1 and 13
	Parameter goal is the expected calculation result, default is 24.
	*/
	var result = solve24game(a, b, c, d, goal);
</script>

exprcalc.min.js required by the code above can be downloaded from here.

Test Case

Run npm test to run the test case.

The test will check if both solve24game() and ordinary method have or don't have answer, for each pairs of 4 numbers between 1 and 13, goals within 1 and 99.

After the test finished successfully, it will output how many pairs of 4 numbers out of 1820 pairs have answer for each goals.

The test will take about 12 minutes to finish.

Keywords

24game

FAQs

Package last updated on 01 Mar 2019

Related posts