diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 0000000..dd84ea7
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,38 @@
+---
+name: Bug report
+about: Create a report to help us improve
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+**Describe the bug**
+A clear and concise description of what the bug is.
+
+**To Reproduce**
+Steps to reproduce the behavior:
+1. Go to '...'
+2. Click on '....'
+3. Scroll down to '....'
+4. See error
+
+**Expected behavior**
+A clear and concise description of what you expected to happen.
+
+**Screenshots**
+If applicable, add screenshots to help explain your problem.
+
+**Desktop (please complete the following information):**
+ - OS: [e.g. iOS]
+ - Browser [e.g. chrome, safari]
+ - Version [e.g. 22]
+
+**Smartphone (please complete the following information):**
+ - Device: [e.g. iPhone6]
+ - OS: [e.g. iOS8.1]
+ - Browser [e.g. stock browser, safari]
+ - Version [e.g. 22]
+
+**Additional context**
+Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 0000000..bbcbbe7
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,20 @@
+---
+name: Feature request
+about: Suggest an idea for this project
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
+
+**Additional context**
+Add any other context or screenshots about the feature request here.
diff --git a/README.md b/README.md
index 0e516dd..0808031 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,11 @@
-# Python-programming-exercises
+# Break The Ice With Python
+
+### A journey of 100+ simple yet interesting problems which are explained, solved, discussed in different pythonic ways
+
+[](https://mybinder.org/v2/gh/darkprinx/100-plus-Python-programming-exercises-extended/master?filepath=notebooks%2F)
+[](https://deepnote.com/launch?url=https%3A%2F%2Fgithub.com%2Fdarkprinx%2F100-plus-Python-programming-exercises-extended%2Fblob%2Fmaster%2Fnotebooks%2FDay_01.ipynb)
-[](https://mybinder.org/v2/gh/darkprinx/100-plus-Python-programming-exercises-extended/master?filepath=notebooks%2F)
---------------------
## Introduction
@@ -88,5 +93,11 @@
* **[Day 24](https://github.com/darkprinx/100-plus-Python-programming-exercises-extended/blob/master/Status/Day_24.md "Day 24 Status")**- ***Question 100-103***
-----------------------
-### **_Sharing new questions and solutions are warmly welcome. Be a proud contributor of this repository by just making a pull request of your changes._**
+
+---
+
+## 🌱 Empower dedication with your generosity
+#### Every single coffee boosts towards greater motivation, turning compassion into action. Show your kind support with just a little click! 😃
+
+
+
diff --git a/Status/Day 1.md b/Status/Day 1.md
index 524e036..557714e 100644
--- a/Status/Day 1.md
+++ b/Status/Day 1.md
@@ -103,7 +103,37 @@ print fact(x)
print(shortFact(n))
```
+---
+```python
+'''Solution by: minnielahoti
+'''
+
+while True:
+try:
+ num = int(input("Enter a number: "))
+ break
+except ValueError as err:
+ print(err)
+
+org = num
+fact = 1
+while num:
+ fact = num * fact
+ num = num - 1
+print(f'the factorial of {org} is {fact}')
+```
+---
+```python
+'''Soltuion by: KruthikaSR
+'''
+from functools import reduce
+
+def fun(acc, item):
+ return acc*item
+num = int(input())
+print(reduce(fun,range(1, num+1), 1))
+```
---
# Question 3
@@ -155,9 +185,35 @@ n = int(input())
ans={i : i*i for i in range(1,n+1)}
print(ans)
```
-
---
+```python
+'''Solution by: minnielahoti
+ Corrected by: TheNobleKnight
+'''
+
+try:
+ num = int(input("Enter a number: "))
+except ValueError as err:
+ print(err)
+
+dictio = dict()
+for item in range(num+1):
+ if item == 0:
+ continue
+ else:
+ dictio[item] = item * item
+print(dictio)
+```
+---
+```python
+'''Solution by: yurbika
+ Corrected by: developer-47
+'''
+num = int(input("Number: "))
+print(dict(enumerate([i*i for i in range(1, num+1)], 1)))
+```
+---
## Conclusion
**_These was the solved problems of day 1. The above problems are very easy for the basic syntex learners.I have shown some easy ways of coding in my solutions. Lets see how to face and attack new problems in the next day._**
diff --git a/Status/Day 2.md b/Status/Day 2.md
index ca34f29..37aaf66 100644
--- a/Status/Day 2.md
+++ b/Status/Day 2.md
@@ -45,7 +45,12 @@ tpl = tuple(lst) # tuple method converts list to tuple
print(lst)
print(tpl)
```
-
+---
+```python
+'''solution by: minnielahoti
+'''
+print(tuple(input("Enter a series of numbers separated by a comma :").split(',')))
+```
---
# Question 5
@@ -89,9 +94,6 @@ str_obj.print_string()
```python
class IOstring():
- def __init__(self):
- pass
-
def get_string(self):
self.s = input()
@@ -215,7 +217,30 @@ D = input().split(',')
D = list(map(calc,D)) # applying calc function on D and storing as a list
print(",".join(D))
```
+---
+```python
+'''Solution by: parian5
+'''
+from math import sqrt
+C, H = 50, 30
+mylist = input().split(',')
+print(*(round(sqrt(2*C*int(D)/H)) for D in mylist), sep=",")
+```
+---
+```python
+
+'''Solution by: saxenaharsh24
+'''
+
+my_list = [int(x) for x in input('').split(',')]
+C, H, x = 50, 30, []
+for D in my_list:
+ Q = ((2*C*D)/H)**(1/2)
+ x.append(round(Q))
+
+print(','.join(map(str, x)))
+```
---
# Question 7
@@ -326,6 +351,17 @@ lst = input().split(',')
lst.sort()
print(",".join(lst))
```
+---
+```python
+'''Solution by Poonam-glitch
+'''
+def my_func(e):
+ return e[0]
+
+my_list = input('Enter a comma separated string: ').split(",")
+my_list.sort(key=my_func)
+print(",".join(my_list))
+```
---
@@ -379,7 +415,7 @@ for sentence in lines:
```python
lst = []
-while input():
+while True:
x = input()
if len(x)==0:
break
@@ -403,6 +439,19 @@ for line in map(str.upper, user_input()):
print(line)
```
+```python
+'''Soltuion by: hajimalung baba
+'''
+def inputs():
+ while True:
+ string = input()
+ if not string:
+ return
+ yield string
+
+print(*(line.upper() for line in inputs()),sep='\n')
+```
+
---
[**_go to previous day_**](https://github.com/darkprinx/100-plus-Python-programming-exercises-extended/blob/master/Status/Day%201.md "Day 1")
diff --git a/Status/Day 3.md b/Status/Day 3.md
index 0389ae7..cf099fa 100644
--- a/Status/Day 3.md
+++ b/Status/Day 3.md
@@ -64,6 +64,17 @@ word = sorted(list(set(input().split()))) # input string splits ->
print(" ".join(word))
```
+---
+```python
+'''Solution by: Sukanya-Mahapatra
+'''
+inp_string = input("Enter string: ").split()
+out_string = []
+for words in inp_string:
+ if words not in out_string:
+ out_string.append(words)
+print(" ".join(sorted(out_string)))
+```
---
# Question 11
@@ -153,6 +164,22 @@ print(",".join(data))
---
+```python
+'''Solution by: nikitaMogilev
+'''
+data = input().split(',')
+data = [num for num in data if int(num, 2) % 5 == 0]
+print(','.join(data))
+```
+
+```python
+'''Solution by: hajimalung baba
+'''
+print(*(binary for binary in input().split(',') if int(binary,base=2)%5==0))
+```
+
+---
+
# Question 12
### **Question:**
@@ -217,6 +244,27 @@ print(",".join(lst))
---
+```python
+'''Solution by: nikitaMogilev
+'''
+# map() digits of each number with lambda function and check if all() of them even
+# str(num) gives us opportunity to iterate through number by map() and join()
+print(','.join([str(num) for num in range(1000, 3001) if all(map(lambda num: int(num) % 2 == 0, str(num)))]))
+```
+
+```python
+'''Solution by: hajimalung
+'''
+from functools import reduce
+#using reduce to check if the number has only even digits or not
+def is_even_and(bool_to_compare,num_as_char):
+ return int(num_as_char)%2==0 and bool_to_compare
+
+print(*(i for i in range(1000,3001) if reduce(is_even_and,str(i),True)),sep=',')
+```
+
+---
+
# Question 13
### **Question:**
@@ -302,6 +350,37 @@ counter = {"LETTERS":len(re.findall("[a-zA-Z]", input_string)), "NUMBERS":len(re
print(counter)
```
+---
+```python
+'''Solution by: MarkisLandis
+'''
+
+sen = input("").split(" ")
+alp, digit = 0, 0
+
+for item in sen:
+ lst = [char for char in item]
+ for j in lst:
+ if 64 < ord(j) < 123:
+ alp += 1
+ if j.isdigit():
+ digit += 1
+print(f"LETTERS : {alp} \n DIGITS : {digit}")
+```
+```python
+'''Solution by: hajimalung
+'''
+#using reduce for to count
+from functools import reduce
+
+def count_letters_digits(counters,char_to_check):
+ counters[0] += char_to_check.isalpha()
+ counters[1] += char_to_check.isnumeric()
+ return counters
+
+print('LETTERS {0}\nDIGITS {1}'.format(*reduce(count_letters_digits,input(),[0,0])))
+```
+
---
## Conclusion
diff --git a/Status/Day 4.md b/Status/Day 4.md
index 4b5c510..af5a343 100644
--- a/Status/Day 4.md
+++ b/Status/Day 4.md
@@ -160,6 +160,32 @@ a = input()
total = int(a) + int(2*a) + int(3*a) + int(4*a) # N*a=Na, for example a="23", 2*a="2323",3*a="232323"
print(total)
```
+---
+```python
+'''Solution by: ChichiLovesDonkeys
+'''
+from functools import reduce
+x = input('please enter a digit:')
+reduce(lambda x, y: int(x) + int(y), [x*i for i in range(1,5)])
+```
+---
+```python
+'''Solution by: lcastrooliveira
+'''
+def question_15(string_digit):
+ return sum(int(string_digit * n) for n in range(1, 5))
+
+inp = input()
+print(question_15(inp))
+```
+---
+```python
+'''Solution by: apenam7
+'''
+a = input()
+print(sum(int(i*a) for i in range(1,5)))
+```
+---
[**_go to previous day_**](https://github.com/darkprinx/100-plus-Python-programming-exercises-extended/blob/master/Status/Day%203.md "Day 3")
diff --git a/Status/Day 5.md b/Status/Day 5.md
index 3d4c974..540695d 100644
--- a/Status/Day 5.md
+++ b/Status/Day 5.md
@@ -57,6 +57,16 @@ seq = [str(i) for i in seq] # All the integers are converted to string to be a
print(",".join(seq))
```
+
+```python
+'''Solution by: Jack'''
+seq = input().split(',')
+lst = [int(i) for i in seq]
+def flt(i): #Define a filter function
+ return i % 2 != 0
+result_l = [str(i * i) for i in filter(flt,lst)]
+print(",".join(result_l))
+```
---
**_There were a mistake in the the test case and the solution's whice were notified and fixed with the help of @dwedigital. My warm thanks to him._**
@@ -215,6 +225,22 @@ balance = sum(transactions)
print(f"Balance is {balance}")
```
---
+```python
+'''Solution by: ChichiLovesDonkeys
+'''
+
+money = 0
+while 1:
+ trans = input().split(' ')
+ if trans[0] == 'D':
+ money = money + int(trans[1])
+ elif trans[0] == 'W':
+ money = money - int(trans[1])
+ elif input() == '':
+ break
+ print(f'Your current balance is: {money}')
+```
+---
[**_go to previous day_**](https://github.com/darkprinx/100-plus-Python-programming-exercises-extended/blob/master/Status/Day%204.md "Day 4")
diff --git a/Status/Day 6.md b/Status/Day 6.md
index 7bba039..0dcd8eb 100644
--- a/Status/Day 6.md
+++ b/Status/Day 6.md
@@ -155,6 +155,37 @@ print(",".join(lst))
---
+```python
+'''Solution by: pratikb0501
+'''
+import re
+a = input('Enter passwords: ').split(',')
+pass_pattern = re.compile(r"^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[$#@]).{6,12}$")
+for i in a:
+ if pass_pattern.fullmatch(i):
+ print(i)
+```
+
+**OR**
+
+```python
+import re
+def multiple (patterns, string):
+ for i in patterns:
+ if not re.search(i, string):
+ return False
+
+ if 6 <= len(string) <= 12:
+ return True
+ else:
+ return False
+x = str(input("Type password: "))
+patterns = [r"[a-z]", r"[A-Z]", r"[0-9]", r"[$|#|@]"]
+print(multiple(patterns, x))
+```
+
+---
+
# Question 19
### **Question:**
@@ -218,7 +249,7 @@ while True:
break
lst.append(tuple(s))
-lst.sort(key= lambda x:(x[0],x[1],x[2])) # here key is defined by lambda and the data is sorted by element priority 0>1>2 in accending order
+lst.sort(key= lambda x:(x[0],int(x[1]),int(x[2]))) # here key is defined by lambda and the data is sorted by element priority 0>1>2 in accending order
print(lst)
```
@@ -226,7 +257,7 @@ print(lst)
## Conclusion
-**_Before the above problems, I didn't even know about re(regular expression) module and its use. I didn't even know how to sort by multiple keys. To solve those problems in different ways I had to explore and learn those syntax.There are a lots of interesting stuffs in re module though I faced quite a bit hardship to understand many of them._**
+**_Before the above problems, I didn't even know about re(regular expression) module and its use. I didn't even know how to sort by multiple keys. To solve those problems in different ways I had to explore and learn those syntax. There are a lots of interesting stuffs in re module though I faced quite a bit hardship to understand many of them._**
[**_go to previous day_**](https://github.com/darkprinx/100-plus-Python-programming-exercises-extended/blob/master/Status/Day%205.md "Day 5")
diff --git a/Status/Day 7.md b/Status/Day 7.md
index 6e86094..9003d16 100644
--- a/Status/Day 7.md
+++ b/Status/Day 7.md
@@ -4,6 +4,19 @@
> **_Define a class with a generator which can iterate the numbers, which are divisible by 7, between a given range 0 and n._**
+> **_Suppose the following input is supplied to the program:_**
+
+```
+7
+```
+
+> **_Then, the output should be:_**
+
+```
+0
+7
+14
+```
---
### Hints:
@@ -40,7 +53,7 @@ for i in MyGen().by_seven( int(input('Please enter a number... ')) ):
class Divisible:
def by_seven(self, n):
- for number in range(n + 1):
+ for number in range(1,n + 1):
if number % 7 == 0: yield number
@@ -141,7 +154,30 @@ while True:
dist = round(math.sqrt(x**2 + y**2)) # euclidean distance = square root of (x^2+y^2) and rounding it to nearest integer
print(dist)
```
+---
+```python
+'''Solution by: pratikb0501
+'''
+from math import sqrt
+lst = []
+position = [0,0]
+while True:
+ a = input()
+ if not a:
+ break
+ lst.append(a)
+for i in lst:
+ if 'UP' in i:
+ position[0] -= int(i.strip('UP '))
+ if 'DOWN' in i:
+ position[0] += int(i.strip('DOWN '))
+ if 'LEFT' in i:
+ position[1] -= int(i.strip('LEFT '))
+ if 'RIGHT' in i:
+ position[1] += int(i.strip('RIGHT '))
+print(round(sqrt(position[1] ** 2 + position[0] ** 2)))
+```
---
[**_go to previous day_**](https://github.com/darkprinx/100-plus-Python-programming-exercises-extended/blob/master/Status/Day%206.md "Day 6")
diff --git a/Status/Day_10.md b/Status/Day_10.md
index 23d1f65..33be5a7 100644
--- a/Status/Day_10.md
+++ b/Status/Day_10.md
@@ -165,7 +165,15 @@ def printList():
printList()
```
-
+---
+```python
+'''Solution by: popomaticbubble
+'''
+def squares(n):
+ squares_list = [i**2 for i in range(1,n+1)]
+ print(squares_list[0:5])
+squares(20)
+```
---
```python
@@ -215,6 +223,15 @@ def printList():
printList()
```
+---
+```python
+'''Solution by: popomaticbubble
+'''
+def squares(n):
+ squares_list = [i**2 for i in range(1,n+1)]
+ print(squares_list[-5:])
+squares(20)
+```
---
diff --git a/Status/Day_11.md b/Status/Day_11.md
index a16ec5a..c30f663 100644
--- a/Status/Day_11.md
+++ b/Status/Day_11.md
@@ -51,8 +51,7 @@ for i in range(5,10):
print(lst1)
print(lst2)
```
-
-**OR**
+----
```python
@@ -67,8 +66,6 @@ print(tup[:lt], tup[lt:])
---
-**OR**
-
```python
'''
@@ -84,6 +81,15 @@ print('The Original Tuple:',tp)
```
---
+```python
+
+'''
+Solution by: saxenaharsh24
+'''
+
+tup = [i for i in range(1, 11)]
+print(f'{tuple(tup[:5])} \n{tuple(tup[5:])}')
+```
# Question 39
@@ -227,7 +233,18 @@ li = [1,2,3,4,5,6,7,8,9,10]
squaredNumbers = map(lambda x: x**2, li) # returns map type object data
print(list(squaredNumbers)) # converting the object into list
```
+---
+```python
+'''
+Solution by: saxenaharsh24
+'''
+def sqrs(item):
+ return item ** 2
+
+lst = [i for i in range(1, 11)]
+print(list(map(sqrs, lst)))
+```
---
# Question 42
@@ -267,7 +284,19 @@ li = [1,2,3,4,5,6,7,8,9,10]
li = map(squer,filter(even,li)) # first filters number by even number and the apply map() on the resultant elements
print(list(li))
```
+---
+```python
+"""
+Solution by: saxenaharsh24
+"""
+def even(item):
+ if item % 2 == 0:
+ return item**2
+
+lst = [i for i in range(1, 11)]
+print(list(filter(lambda j: j is not None, list(map(even, lst)))))
+```
---
# Question 43
diff --git a/Status/Day_15.md b/Status/Day_15.md
index 8acdacc..2d6184c 100644
--- a/Status/Day_15.md
+++ b/Status/Day_15.md
@@ -252,7 +252,15 @@ for i in range(1, n+1):
sum+= i/(i+1)
print(round(sum, 2)) # rounded to 2 decimal point
```
+---
+```python
+'''Solution by: lcastrooliveira
+'''
+def question_59(n):
+ print(round(sum(map(lambda x: x/(x+1), range(1, n+1))), 2))
+question_59(5)
+```
---
[**_go to previous day_**](https://github.com/darkprinx/100-plus-Python-programming-exercises-extended/blob/master/Status/Day_14.md "Day 14")
diff --git a/Status/Day_16.md b/Status/Day_16.md
index a905a49..162a201 100644
--- a/Status/Day_16.md
+++ b/Status/Day_16.md
@@ -59,6 +59,17 @@ def f(n):
n = int(input())
print(f(n))
+```
+---
+```python
+
+'''Solution by: NikolayEm
+'''
+
+n = int(input())
+f = lambda x: f(x-1)+100 if x > 0 else 0
+print(f(n))
+
```
---
@@ -126,6 +137,17 @@ n = int(input())
print(f(n))
```
+---
+```python
+
+'''Solution by: NikolayEm
+'''
+
+n = int(input())
+f = lambda x: 0 if x == 0 else 1 if x == 1 else f(x-1)+f(x-2)
+print(','.join([str(f(x)) for x in range(0, n+1)]))
+
+```
---
# Question 62
@@ -201,7 +223,43 @@ ans = ",".join(fibo) # joining all string element of fibo with ',' character
print(ans)
```
+---
+```python
+
+'''Solution by: popomaticbubble
+'''
+def fibo(n):
+ if n < 2: return n
+ return fibo(n-1)+fibo(n-2)
+
+def print_fiblist(n):
+ fib_list = [(str(fibo(i))) for i in range(0, n+1)]
+ return print(",".join(fib_list))
+n = int(input())
+print_fiblist(n)
+```
+---
+```python
+'''Solution by: lcastrooliveira
+'''
+
+def question_62(n):
+ if n == 0:
+ return [0]
+ if n == 1:
+ return [0, 1]
+ sequence = [0, 1]
+ a, b = 0, 1
+ for x in range(2, n+1):
+ c = a + b
+ sequence.append(c)
+ a = b
+ b = c
+ return sequence
+
+print(question_62(10))
+```
---
# Question 63
diff --git a/Status/Day_17.md b/Status/Day_17.md
index 9fc4ef4..0f1b7e3 100644
--- a/Status/Day_17.md
+++ b/Status/Day_17.md
@@ -125,7 +125,26 @@ print bin_search(li,12)
#to be written
```
-
+**Solution by ulmasovjafarbek: Python 3**
+```python
+def binary_search(lst, item):
+ low = 0
+ high = len(lst) - 1
+
+ while low <= high:
+ mid = round((low + high) / 2)
+
+ if lst[mid] == item:
+ return mid
+ elif lst[mid] > item:
+ high = mid - 1
+ else:
+ low = mid + 1
+ return None
+
+lst = [1,3,5,7,]
+print(binary_search(lst, 9))
+```
---
**Solution by AasaiAlangaram: Python 3**
diff --git a/Status/Day_19.md b/Status/Day_19.md
index 26fd412..0f24321 100644
--- a/Status/Day_19.md
+++ b/Status/Day_19.md
@@ -203,6 +203,38 @@ for sub in subjects:
for obj in objects:
print("{} {} {}".format(sub,verb,obj))
```
+---
+```python
+
+'''Solution by: popomaticbubble
+'''
+import itertools
+subject = ["I", "You"]
+verb = ["Play", "Love"]
+objects = ["Hockey","Football"]
+
+sentence = [subject, verb, objects]
+n = list(itertools.product(*sentence))
+for i in n:
+ print(i)
+```
+---
+```python
+
+'''Solution by: lcastrooliveira
+'''
+from itertools import product
+
+def question_79():
+ subject = ["I", "You"]
+ verb = ["Play", "Love"]
+ object = ["Hockey", "Football"]
+ prod = [p for p in product(range(2), repeat=3)]
+ for combination in prod:
+ print(f'{subject[combination[0]]} {verb[combination[1]]} {object[combination[2]]}')
+
+question_79()
+```
---
diff --git a/Status/Day_20.md b/Status/Day_20.md
index a2c2f23..eeb4349 100644
--- a/Status/Day_20.md
+++ b/Status/Day_20.md
@@ -97,7 +97,7 @@ print(li)
```python
li = [12,24,35,70,88,120,155]
-li = [x for (i,x) in enumerate(li) if i%2!=0]
+li = [x for (i,x) in enumerate(li) if i%2 != 0 and i <= 6]
print li
```
@@ -107,10 +107,19 @@ print li
```python
li = [12,24,35,70,88,120,155]
-li = [li[i] for i in range(len(li)) if i%2 != 0]
+li = [li[i] for i in range(len(li)) if i%2 != 0 and i <= 6]
print(li)
```
+---
+```python
+'''Solution by: popomaticbubble
+'''
+orig_lst = [12,24,35,70,88,120,155]
+indices = [0, 2, 4, 6]
+new_list = [i for (j, i) in enumerate(orig_lst) if j not in indices]
+print(new_list)
+```
---
# Question 83
@@ -137,20 +146,31 @@ li = [x for (i,x) in enumerate(li) if i<3 or 4 4]
print(li)
```
-
---
-
+```python
+"""Solution by: popomaticbubble
+"""
+orig_list = [12,24,35,70,88,120,155]
+new_list = [i for (j, i) in enumerate(orig_list) if j not in range(1,4)]
+print(new_list)
+```
+---
+```python
+"""Solution by: saxenaharsh24
+"""
+lst = [12,24,35,70,88,120,155]
+print([i for i in lst if lst.index(i) not in range(2,5)])
+```
+---
# Question 84
### **Question**
diff --git a/Status/Day_21.md b/Status/Day_21.md
index 17272ac..380354c 100644
--- a/Status/Day_21.md
+++ b/Status/Day_21.md
@@ -19,7 +19,6 @@ li = [12,24,35,70,88,120,155]
li = [x for (i,x) in enumerate(li) if i not in (0,4,5)]
print li
```
-
---
**My Solution: Python 3**
@@ -28,6 +27,14 @@ print li
li = [12,24,35,70,88,120,155]
li = [li[i] for i in range(len(li)) if i not in (0,4,5)]
print(li)
+```
+---
+```python
+'''Solution by: pratikb0501
+'''
+li = [12, 24, 35, 70, 88, 120, 155]
+print(list(j for i, j in enumerate(li) if i != 0 and i != 4 and i != 5))
+
```
---
@@ -212,7 +219,31 @@ aFemale= Female()
print aMale.getGender()
print aFemale.getGender()
```
+---
+```python
+'''Solution by: popomaticbubble
+'''
+class Person(object):
+ def __init__(self):
+ self.gender = "unknown"
+
+ def getGender(self):
+ print(self.gender)
+
+class Male(Person):
+ def __init__(self):
+ self.gender = "Male"
+class Female(Person):
+ def __init__(self):
+ self.gender = "Female"
+
+sharon = Female()
+doug = Male()
+sharon.getGender()
+doug.getGender()
+
+```
---
[**_go to previous day_**](https://github.com/darkprinx/100-plus-Python-programming-exercises-extended/blob/master/Status/Day_20.md "Day 20")
diff --git a/Status/Day_22.md b/Status/Day_22.md
index f7db8db..b9b57b5 100644
--- a/Status/Day_22.md
+++ b/Status/Day_22.md
@@ -64,7 +64,37 @@ for letter in range(ord('a'),ord('z')+1): # ord() gets the ascii value of a c
if cnt > 0:
print("{},{}".format(letter,cnt))
```
-
+---
+```python
+'''Solution by: Utkarsh4697
+'''
+s = 'abcdefgabc'
+for i in sorted(set(s)):
+ print(f'{i}, {s.count(i)}')
+```
+---
+```python
+'''Solution by: popomaticbubble
+'''
+def character_counter(text):
+ characters_list = list(text)
+ char_count = {}
+ for x in characters_list:
+ if x in char_count.keys():
+ char_count[x] += 1
+ else:
+ char_count[x] = 1
+ return char_count
+
+
+def dict_viewer(dictionary):
+ for x, y in dictionary.items():
+ print(f"{x},{y}")
+
+
+text = input("> ")
+dict_viewer(character_counter(text))
+```
---
# Question 91
@@ -189,7 +219,21 @@ print(ns)
import itertools
print list(itertools.permutations([1,2,3]))
```
+---
+```python
+"""Solution by: popomaticbubble
+"""
+from itertools import permutations
+def permuation_generator(iterable):
+ p = permutations(iterable)
+ for i in p:
+ print(i)
+
+
+x = [1,2,3]
+permuation_generator(x)
+```
---
# Question 94
@@ -218,12 +262,40 @@ def solve(numheads,numlegs):
return i,j
return ns,ns
-numheads=35
-numlegs=94
+numheads = 35
+numlegs = 94
solutions=solve(numheads,numlegs)
print solutions
```
+---
+```python
+"""Solution by: popomaticbubble
+"""
+import itertools
+def animal_counter(lst):
+ chickens = 0
+ rabbits = 0
+ for i in lst:
+ if i == 2:
+ chickens += 1
+ elif i == 4:
+ rabbits += 1
+ print(f"Number of chickens is {chickens}\nNumber of rabbits is {rabbits}")
+
+
+def animal_calculator(total_legs, total_heads, legs_of_each_species):
+ combinations = itertools.combinations_with_replacement(legs_of_each_species, total_heads)
+ correct_combos = []
+ for i in list(combinations):
+ if sum(i) == total_legs:
+ correct_combos.append(i)
+ print(correct_combos)
+ for i in correct_combos:
+ animal_counter(i)
+
+animal_calculator(94, 35, legs_of_each_species=[2,4])
+```
---
[**_go to previous day_**](https://github.com/darkprinx/100-plus-Python-programming-exercises-extended/blob/master/Status/Day_21.md "Day 21")
diff --git a/Status/Day_23.md b/Status/Day_23.md
index 05b94ab..d7cf0c6 100644
--- a/Status/Day_23.md
+++ b/Status/Day_23.md
@@ -57,6 +57,25 @@ print(L2)
print(f'The runner up is {L2[-2]}')
```
+---
+```python
+'''Solution by: KailashS3
+'''
+num = int(input())
+scores = list(map(int, input().split(' ')))
+winner = max(scores)
+lst = []
+
+if len(scores) != num:
+ print('length of score is greater than input given')
+else:
+ for score in scores:
+ if winner > score:
+ lst.append(score)
+
+runnerup = max(lst)
+print(runnerup)
+```
---
# Question 96
@@ -109,8 +128,8 @@ if __name__ == '__main__':
---
```python
-'''Solution by: mishrasunny-coder
-'''
+"""Solution by: mishrasunny-coder
+"""
import textwrap
string = input()
@@ -120,8 +139,8 @@ print(textwrap.fill(string,width))
```
---
```python
-'''solution by : Prashanth
-'''
+"""solution by : Prashanth
+"""
from textwrap import wrap
x = str(input(': '))
w = int(input())
@@ -129,7 +148,35 @@ z = list(wrap(x, w))
for i in z:
print(i)
```
-
+---
+```python
+"""solution by : saxenaharsh24
+"""
+import textwrap
+string = input('')
+print('\n'.join(textwrap.wrap(string, width= int(input('')))))
+```
+---
+```python
+"""solution by : popomaticbubble
+"""
+import itertools
+string = input("> ")
+width_length = int(input("What is the width of the groupings? "))
+
+def grouper(string, width):
+ iters = [iter(string)] * width
+ return itertools.zip_longest(*iters, fillvalue='')
+
+def displayer(groups):
+ for x in groups:
+ if x == '':
+ continue
+ else:
+ print(''.join(x))
+
+displayer(grouper(string, width_length))
+```
---
# Question 97
@@ -195,6 +242,22 @@ if __name__ == '__main__':
n = int(input())
print_rangoli(n)
```
+---
+```python
+'''Solution by: suggula jaswanth
+'''
+def rangoli(n):
+ # your code goes here
+ l1=list(map(chr,range(97,123)))
+ x=l1[n-1::-1]+l1[1:n]
+ mid=len('-'.join(x))
+ for i in range(1,n):
+ print('-'.join(l1[n-1:n-i:-1]+l1[n-i:n]).center(mid,'-'))
+ for i in range(n,0,-1):
+ print('-'.join(l1[n-1:n-i:-1]+l1[n-i:n]).center(mid,'-'))
+rangoli(5)
+
+```
---
diff --git a/Status/Day_24.md b/Status/Day_24.md
index 12cc914..e4c6dd9 100644
--- a/Status/Day_24.md
+++ b/Status/Day_24.md
@@ -203,7 +203,24 @@ n = int(input())
sum = rec(n)
print(sum)
```
+---
+```python
+"""Solution by: popomaticbubble
+"""
+def summer(counter, n, current):
+ if n == 0:
+ return 0
+ if counter == n:
+ return current+n
+ else:
+ current = current + counter
+ counter += 1
+ return summer(counter, n, current)
+
+N = int(input("> "))
+print(summer(1, N, 0))
+```
---
[**_go to previous day_**](https://github.com/darkprinx/100-plus-Python-programming-exercises-extended/blob/master/Status/Day_22.md "Day 23")