mirror of
https://github.com/aljazceru/cryptoanarchywiki.github.io.git
synced 2025-12-17 05:04:21 +01:00
725 B
725 B
layout, title, date, categories
| layout | title | date | categories | ||
|---|---|---|---|---|---|
| post | Find the number of even digits in the given integer [CF] | 2016-06-11 03:39:03 +0700 |
|
Find the number of even digits in the given integer.
Example
- For
n = 1010, the output should benumberOfEvenDigits(n) = 2. - For
n = 123, the output should benumberOfEvenDigits(n) = 1.
Input/Output
- [time limit] 4000ms (py)
- [input] integer n (A positive integer).
Constraints:
-
1 ≤ n ≤ 106.
-
[output] integer
My Solution:
def numberOfEvenDigits(n):
return len(filter(lambda m: m.isdigit() and int(m) % 2 == 0, str(n)))
Rests Tests:
n: 1010
Output: 2
n: 123
Output: 1
n: 135
Output: 0