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 lookAndSay(number) { | |
var regex = /(.)\1*/g; | |
return number.toString().replace(regex, function(regexMatch) { | |
return regexMatch.length.toString() + regexMatch.substring(0, 1); | |
}); | |
} | |
// Usage | |
function init() { | |
var number = 1; |
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
// Convert decimal number to desired base and convert the result to it's respective alphabets from the dictionary. | |
function convertBaseFromDecimal(number, desiredBase) { | |
var num = number; | |
var rem = 0; | |
var convertedNumber = []; | |
// NOTE: Modify dictionary if desiredBase != 5 | |
var dict = { | |
0 : "a", |