Created
July 14, 2020 10:00
-
-
Save ultramarshall/7fba29f081c12c112e4cd8aaae499d1d to your computer and use it in GitHub Desktop.
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 recur(digits, i, n, str) { | |
if (i == n && typeof(str) != 'undefined') { | |
//console.log(str) | |
return; | |
} | |
var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
var sum = 0; | |
for (j = i; j <= Math.min(i + 1, n - 1); j++) { | |
console.log(j) | |
sum = (sum * 10) + digits[j]; | |
if (sum <= 26) | |
recur(digits, j + 1, n, str + alphabet[sum - 1]); | |
} | |
} | |
var digits = [1,1,2,3]; | |
var n = digits.length; | |
var str; | |
recur(digits, 0, n, str); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment