# idealvalues

> Idealvalues ​​is a tool you can use for hypothesis testing. Use Idealvalues ​​to find a sum value within an array of numbers.

Latest version **2.0.3** (published 2022-09-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install idealvalues
pnpm add idealvalues
yarn add idealvalues
bun add idealvalues
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2022-09-28 |
| First published | 2022-05-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Jean Pierre |
| Maintainers | santos-jp7 |
| Keywords | js, javascript, excel, solver, math, math, mathematics, hypothesis |

## Links

- npm: https://www.npmjs.com/package/idealvalues
- Repository: https://github.com/santos-jp7/idealvalues
- Homepage: https://github.com/santos-jp7/idealvalues#readme
- Issues: https://github.com/santos-jp7/idealvalues/issues
- npm.io page: https://npm.io/package/idealvalues

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 2.0.3 (latest) — 2022-09-28
- 2.0.2 — 2022-09-28
- 2.0.1 — 2022-09-28
- 2.0.0 — 2022-09-28
- 1.0.2 — 2022-05-06
- 1.0.1 — 2022-05-05
- 1.0.0 — 2022-05-05

## README

# idealvalues

Idealvalues is a tool you can use for hypothesis testing. Use Idealvalues to find a sum value within an array of numbers.

[![](https://img.shields.io/npm/v/idealvalues.svg)](https://npmjs.org/package/idealvalues)  [![](https://img.shields.io/npm/dt/idealvalues.svg?maxAge=3600)](https://www.npmjs.com/package/idealvalues) [![](https://data.jsdelivr.com/v1/package/npm/idealvalues/badge)](https://www.jsdelivr.com/package/npm/idealvalues)
## Installing

Using npm:

```bash
$ npm install idealvalues
```
---
Using cdn:

```html
<script src="https://cdn.jsdelivr.net/npm/idealvalues/cdn/idealvalues.js" integrity="sha256-pHB+sncAePApDDjJyqPddPhPLKK7OPe493sMwOlFVBs=" crossorigin="anonymous"></script>
```

## API

```js
idealvalues(number, [values], {options?});
```

Returns the numbers at which the sum arrives at the desired value.

|           |                                                                           |
| --------- | ------------------------------------------------------------------------- |
| `number`  | `Number` Number that should be the sum of all values.                     |
| `values`  | `Array`  Values to reach the desired number.                              |
| `options` | `Object` options for dealing. **Optional**                                |
| _returns_ | `Array`  Values whose sum results in the desired number.                  |
| _throws_  | `Error`  If it does not find values whose sum reaches the desired value.  |

#### options

|               |                                                                               |
| ------------- | ----------------------------------------------------------------------------- |
| `debug`       | `Boolean` Enable debug. **Default=false**                                     |
| `fullDebug`   | `Boolean` Enable full debug, with all loops of attempts.  **Default=false**   |
| `maxAttempts` | `Number` maximum attempts. **Default=1000**                                   |
| `extends`     | `Bollean` Returns a run report. **Default=false**                             |

## Examples

### Default:

```js
const idealvalues = require("idealvalues");

const values = idealvalues(180, [10, 10, 20, 20, 40, 40, 30, 50, 70, 30, 40]);

console.log(values);
```

#### Output

```js
[ 50, 40, 10, 40, 10, 30 ]
```
---
### Extends

```js
const idealvalues = require("idealvalues");

const values = idealvalues(180, [10, 10, 20, 20, 40, 40, 30, 50, 70, 30, 40], {extends: true});

console.log(values);
```

#### Output

```js
{ values: [ 40, 50, 20, 30, 40 ], sum: 180, attempts: 2 }
```
---
### CDN

```html
<script src="https://cdn.jsdelivr.net/npm/idealvalues/cdn/idealvalues.js" integrity="sha256-pHB+sncAePApDDjJyqPddPhPLKK7OPe493sMwOlFVBs=" crossorigin="anonymous"></script>
<script>
    const values = idealvalues(180, [10, 10, 20, 20, 40, 40, 30, 50, 70, 30, 40]);

    console.log(values);
</script>
```
#### Output

```js
[ 50, 40, 10, 40, 10, 30 ]
```
---
## Use cases

I went to the supermarket, and the total value of the purchase was: **$180**. In my wallet I have the following notes:

- $10
- $20 **x 2**
- $50 **x 4**
- $100

Then:

```js
const idealvalues = require("idealvalues");

const values = idealvalues(180, [10, 20, 20, 50, 50, 50, 50, 100]);

console.log(values);
```

#### Output

```js
[ 50, 100, 10, 20 ]
```

To pay I need to pass the following notes:

- $50
- $100
- $10
- $20

---
_Source: https://npm.io/package/idealvalues · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
