-
-
Save ukd1/ccddaecc38f6e24eed52 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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