@@ -172,6 +172,12 @@ data = [num for num in data if int(num, 2) % 5 == 0]
172172print (' ,' .join(data))
173173```
174174
175+ ``` python
176+ ''' Solution by: hajimalung baba
177+ '''
178+ print (* (binary for binary in input ().split(' ,' ) if int (binary,base = 2 )% 5 == 0 ))
179+ ```
180+
175181---
176182
177183# Question 12
@@ -246,6 +252,17 @@ print(",".join(lst))
246252print (' ,' .join([str (num) for num in range (1000 , 3001 ) if all (map (lambda num : int (num) % 2 == 0 , str (num)))]))
247253```
248254
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+
249266---
250267
251268# Question 13
@@ -350,6 +367,20 @@ for item in sen:
350367 digit += 1
351368print (f " LETTERS : { alp} \n DIGITS : { digit} " )
352369```
370+ ``` python
371+ ''' Solution by: hajimalung
372+ '''
373+ # using reduce for to count
374+ from functools import reduce
375+
376+ def count_letters_digits (counters ,char_to_check ):
377+ counters[0 ] += char_to_check.isalpha()
378+ counters[1 ] += char_to_check.isnumeric()
379+ return counters
380+
381+ print (' LETTERS {0} \n DIGITS {1} ' .format(* reduce (count_letters_digits,input (),[0 ,0 ])))
382+ ```
383+
353384---
354385
355386## Conclusion
0 commit comments