Skip to content

Instantly share code, notes, and snippets.

@piecyk
Created May 13, 2014 08:57
Show Gist options
  • Select an option

  • Save piecyk/267a6122e0f183fdb0bf to your computer and use it in GitHub Desktop.

Select an option

Save piecyk/267a6122e0f183fdb0bf to your computer and use it in GitHub Desktop.
//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