Skip to content

Instantly share code, notes, and snippets.

@colevandersWands
Created April 21, 2018 13:49
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 colevandersWands/811987e6ca2536cc4e88dab74b7d20ad to your computer and use it in GitHub Desktop.
Save colevandersWands/811987e6ca2536cc4e88dab74b7d20ad to your computer and use it in GitHub Desktop.
tripledouble strategy inference
function (num1, num2)
2: declare necessary variables
6: type validation
9: convert args to practical data type
12: check first number for 3 in a row
18: if first one has 3 in a row
19: check if second has 2 in a row
26: do they both have the same letter?
31: return returner
end function
function tripledouble(num1, num2) {
let returner = "0";
let check1 = false;
let check2 = true;
if (typeof num1 !== 'number' || typeof num2 !== 'number'){
returner = 0;
} else {
var a = num1.toString().split('');
var b = num2.toString().split('');
for (let i = 0; i < a.length - 2; i++){
if(a[i] === a[i+1] && a[i] === a[i+2]){
check1 = a[i];
}
}
if (check1) {
for (let j = 0; j < b.length - 1; j++){
if(b[j] === b[j+1]){
check2 = b[j];
}
}
}
if (check1 == check2) {
returner = "1";
}
}
return returner;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment