Skip to content

Instantly share code, notes, and snippets.

@mirontoli
Created June 5, 2014 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mirontoli/4fa2c5a78d5a8b783272 to your computer and use it in GitHub Desktop.
Save mirontoli/4fa2c5a78d5a8b783272 to your computer and use it in GitHub Desktop.
var prices = { x:15, y: 1, z: 0.25 };
var combinations = [];
for (var x = 1; x < 99; x++) {
for (var y = 1; y < 99; y++) {
var z = 100 - x - y;
if (z > 0) {
combinations.push({x:x,y:y,z:z});
}
}
}
var filtered = combinations.filter(function(element) {
return element.x * prices.x + element.y * prices.y + element.z * prices.z === 100;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment