Skip to content

Commit 9b87af5

Browse files
authored
Merge pull request darkprinx#40 from hajimalung/master
solution for question 9 added/improved
2 parents 98a0b02 + a1d9e87 commit 9b87af5

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

Status/Day 2.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,19 @@ for line in map(str.upper, user_input()):
438438
print(line)
439439
```
440440

441+
```python
442+
'''Soltuion by: hajimalung baba
443+
'''
444+
def inputs():
445+
while True:
446+
string = input()
447+
if not string:
448+
return
449+
yield string
450+
451+
print(*(line.upper() for line in inputs()),sep='\n')
452+
```
453+
441454
---
442455

443456
[**_go to previous day_**](https://github.com/darkprinx/100-plus-Python-programming-exercises-extended/blob/master/Status/Day%201.md "Day 1")

Status/Day 3.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ data = [num for num in data if int(num, 2) % 5 == 0]
172172
print(','.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))
246252
print(','.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
351368
print(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}\nDIGITS {1}'.format(*reduce(count_letters_digits,input(),[0,0])))
382+
```
383+
353384
---
354385

355386
## Conclusion

0 commit comments

Comments
 (0)