Skip to main content
100%

Optimal denominations

✓ Published0🌍 Public
ZZJONSSON
Last edited Nov 6, 2014
Created on Jul 25, 2014

This example shows how many coins of which denominations minimize the number needed to make any amount from one cent to one dollar, calculating the optimal set for 2 through 6 coins. The page iterates through all combinations of candidate denominations, scores each set by summing the coin count required for every amount using a greedy algorithm, and outputs the best result. It uses plain JavaScript combinatory functions and DOM manipulation via `document.createElement`, with data defined in `denom.js` and logic in `index.html`.

AI-generated description

This small script uses combinatory analysis to figure out the optimal denominations for given number of possible coins to minimize the coins required to produce any amount between 1 cent and 1 dollar. The candidate set of denominations is reduced to keep the combinatory possibilities within reason.

Similar vizzes