https://github.com/peterdee/pairs-test
Pairs multiplication test
https://github.com/peterdee/pairs-test
Last synced: over 1 year ago
JSON representation
Pairs multiplication test
- Host: GitHub
- URL: https://github.com/peterdee/pairs-test
- Owner: peterdee
- Created: 2019-07-10T14:07:25.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T07:24:16.000Z (over 3 years ago)
- Last Synced: 2025-01-21T10:11:16.218Z (over 1 year ago)
- Language: JavaScript
- Size: 53.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Pairs test
#### Task
```
You are given a list of integers, both positive and negative.
Each integer in the list must either be paired with another element in the list or be a single element.
Once the elements have been paired, the integers in the pairs are multiplied and
the results are summed up - the sum will include the single elements.
Write a program to find the sequence of pairs and singles which give the biggest possible sum,
and calculate this max sum.
Examples:
1. For the list [0,1,2,3,4,5] the pairs (4,5) and (2,3) are formed and 0 and 1 are single elements.
The max. sum is 27: (20+6+0+1).
2. For the list [-1,0,1] the pairs (-1,0) is formed and 1 is a single element.
The max. sum is 1.
3. For the list [1,1] no pairs are formed only two single elements.
The max. sum is 2.
You choose how input/output is handled etc.
```
#### Implementation
This is a Node / Express server, that serves the static files.
Static page is shown to the user.
User can enter the values (**comma-separated, numbers and symbols**), and values are going to be processed accordingly.
The final result is going to be the sum of pairs and single elements.
Static page available at http://localhost:3030
#### Calculation code
https://gist.github.com/peterdee/1700ac54add5c396b4b8fa31c0ac3353
#### Deploy
- `git clone https://github.com/peterdee/pairs-test.git`
- `cd pairs-test`
- `nvm use 12.6`
- `npm i`
#### Launch
- `npm run dev`