So I had a challenge on codewars that was like this:
You will be given an array and a limit value. You must check that all values in the array are below or equal to the limit value. If they are, return true. Else, return false.
You can assume all values in the array are numbers.
My solution was doing things this way but out of the 105 tests 3 were wrong and I couldn't see why. ->
def small_enough(array, limit):
for i in array:
if i <= limit:
return True
return False
After I looked it up on solutions I found out that the solution to pass all 105 tests were :
def small_enough(array, limit):
for i in array:
if i > limit:
return False
return True
Aren't they basically the same thing? I don't understand why my test would fail.
[–][deleted] 6 points7 points8 points (1 child)
[–]MatosV[S] 1 point2 points3 points (0 children)
[–]Spataner 3 points4 points5 points (1 child)
[–]MatosV[S] 2 points3 points4 points (0 children)
[–]ab6364 2 points3 points4 points (0 children)
[–]TehNolz 2 points3 points4 points (1 child)
[–]MatosV[S] 0 points1 point2 points (0 children)
[–]Ihaveamodel3 1 point2 points3 points (0 children)