Created
December 11, 2014 17:48
-
-
Save birkir/65bcc93a01cef5dd8217 to your computer and use it in GitHub Desktop.
Jóladagatal 11/24 - Umturnun á stafrófi
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
// get factorial by iteration (faster than recursive) | |
Math.factorial = function (n) { | |
var a = 1; | |
for (var i = 2; i < n; i++) { | |
a *= i; | |
} | |
return a; | |
} | |
// setup test case | |
var alphabet = 'AÁBDÐEÉFGHIÍJKLMNOÓPRSTUÚVXYÝÞÆÖ'; | |
var target = 'JÓL'; | |
// calculate answer | |
Math.factorial(alphabet.length - target.length + 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment