Last active
August 24, 2018 09:25
-
-
Save dbhalling/8670b4d5ce19b8270ed1495cb98cd140 to your computer and use it in GitHub Desktop.
Codility CountNonDivisible 32
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
#Codility CountNonDivisible 32 | |
a = [3, 1, 2, 3, 6] | |
def solution(a) | |
# length = a.count | |
count = 0 | |
i = 0 | |
aresult = [] | |
while i < a.count | |
a.each do |x| | |
if a[i].modulo(x) != 0 | |
count += 1 | |
else | |
end | |
end | |
aresult.push(count) | |
count = 0 | |
i += 1 | |
end | |
return aresult | |
end | |
puts "The CountNonDivisible array is #{solution(a)}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment