Skip to content

Commit cb5f3bf

Browse files
author
hajimalung.baba
committed
adding solution for Question 12 using reduce
1 parent 3e83aec commit cb5f3bf

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Status/Day 3.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,17 @@ print(",".join(lst))
252252
print(','.join([str(num) for num in range(1000, 3001) if all(map(lambda num: int(num) % 2 == 0, str(num)))]))
253253
```
254254

255+
```python
256+
'''Solution by: hajimalung
257+
'''
258+
from functools import reduce
259+
#using reduce to check if the number has only even digits or not
260+
def is_even_and(bool_to_compare,num_as_char):
261+
return int(num_as_char)%2==0 and bool_to_compare
262+
263+
print(*(i for i in range(1000,3001) if reduce(is_even_and,str(i),True)),sep=',')
264+
```
265+
255266
---
256267

257268
# Question 13

0 commit comments

Comments
 (0)