Created
April 21, 2018 13:49
-
-
Save colevandersWands/811987e6ca2536cc4e88dab74b7d20ad to your computer and use it in GitHub Desktop.
tripledouble strategy inference
This file contains 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
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 |
This file contains 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
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