Created
May 13, 2014 08:57
-
-
Save piecyk/267a6122e0f183fdb0bf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| //taks 3 | |
| //http://pasteboard.co/2DY4NjCM.png | |
| // damn... | |
| function isHeavy(i) { | |
| var sum = 0, len = 0, num = i; | |
| while (num > 0) { | |
| sum = sum + num % 10; | |
| num = num - num % 10; | |
| num = num / 10; | |
| len++; | |
| } | |
| return sum/len > 7; | |
| } | |
| function solution(A, B) { | |
| var count = 0; | |
| for (var i = A; i <= B; i++) { | |
| if (isHeavy(i)) { | |
| count++; | |
| } | |
| } | |
| return count; | |
| } | |
| console.log(solution(8675,8689)); | |
| //5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment