Skip to content

Instantly share code, notes, and snippets.

@ultramarshall
Created July 14, 2020 10:00
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 ultramarshall/7fba29f081c12c112e4cd8aaae499d1d to your computer and use it in GitHub Desktop.
Save ultramarshall/7fba29f081c12c112e4cd8aaae499d1d to your computer and use it in GitHub Desktop.
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