Skip to content

Instantly share code, notes, and snippets.

@cadebward
Created November 18, 2014 01:07
Show Gist options
  • Save cadebward/43658528ea056e76e00d to your computer and use it in GitHub Desktop.
Save cadebward/43658528ea056e76e00d to your computer and use it in GitHub Desktop.
rainforest
sample_data = [0, 1, 100, 99, 0, 10, 90, 30, 55, 33, 55, 75, 51, 49, 50, 51, 49, 51]
sample_output = [[1,99], [0,100], [10,90], [51,49], [50,50]]
var results = [];
for (var i = 0; i < sample_data.length; i++) {
for (var j = i + 1; j < sample_data.length; j++) {
if (sample_data[i] + sample_data[j] == 100) {
var combo = sample_data[i]
if (results.indexOf(sample_data[i]) == -1 && results.indexOf(100 - sample_data[i]) == -1) {
results.push(combo);
}
}
}
}
var final_output = [];
output(results);
function output(arr) {
for (var i = 0; i < arr.length; i++) {
final_output.push([arr[i], 100 - arr[i]]);
}
}
console.log(final_output);
SELECT DISTINCT client_id, email
FROM client_plans
JOIN clients as a WHERE a.id = client_id
WHERE plan_id = 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment