Last active
August 29, 2015 13:57
-
-
Save lightsuner/9651747 to your computer and use it in GitHub Desktop.
solve this task - http://d2dm5kfavr4eqq.cloudfront.net/tasks/01/task.png
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
<script src="//code.jquery.com/jquery-2.1.0.min.js"></script> | |
Result: <div id="result"></div> | |
<script> | |
function hasAllPatterns(string) { | |
var requiredDigits = [ | |
0, | |
1,2,3,4,5,6,7,8,9, | |
'a', 'b', 'c', 'd', 'e' | |
]; | |
for (var i=0; i< requiredDigits.length; i++) { | |
if (string.indexOf(requiredDigits[i]) == -1) { | |
return false; | |
} | |
} | |
return true; | |
} | |
var num = 2, | |
multiplier = 0, | |
stop = false, | |
res = 0, | |
strNum, | |
base = 15, | |
$result = $('#result') | |
; | |
while (!stop) { | |
res = Math.pow(num, multiplier) | |
strNum = res.toString(base); | |
$result.html(strNum); | |
if (hasAllPatterns(strNum)) { | |
stop = true; | |
$result.append('<br>Multiplier: '+multiplier); | |
return; | |
} | |
multiplier++; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment