From 06e739180309bd242cf09d6589bc4ce5f22864bd Mon Sep 17 00:00:00 2001 From: Arthur Pastel Date: Fri, 18 Oct 2024 17:08:45 +0200 Subject: [PATCH] feat: change count_even implementation --- tests/test_count_even.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/test_count_even.py b/tests/test_count_even.py index b1fc605..c62e468 100644 --- a/tests/test_count_even.py +++ b/tests/test_count_even.py @@ -3,11 +3,7 @@ def count_even(arr: list[int]) -> int: """Count the number of even numbers in an array.""" - even = 0 - for num in arr: - if num % 2 == 0: - even += 1 - return even + return sum(1 for i in arr if i % 2 == 0) # Your tests can also be benchmarks