Skip to content

Commit cd225b5

Browse files
committed
[Feat] Add Solutions of popomaticbubble
Branch: master
1 parent e0c3fa7 commit cd225b5

File tree

3 files changed

+104
-2
lines changed

3 files changed

+104
-2
lines changed

Status/Day_22.md

+66-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,30 @@ for i in sorted(set(s)):
7373
print(f'{i}, {s.count(i)}')
7474
```
7575
---
76+
```python
77+
'''Solution by: popomaticbubble
78+
'''
79+
def character_counter(text):
80+
characters_list = list(text)
81+
char_count = {}
82+
for x in characters_list:
83+
if x in char_count.keys():
84+
char_count[x] += 1
85+
else:
86+
char_count[x] = 1
87+
return char_count
88+
89+
90+
def dict_viewer(dictionary):
91+
for x, y in dictionary.items():
92+
print(f"{x},{y}")
7693

7794

95+
text = input("> ")
96+
dict_viewer(character_counter(text))
97+
```
98+
---
99+
78100
# Question 91
79101

80102
### **Question**
@@ -197,7 +219,21 @@ print(ns)
197219
import itertools
198220
print list(itertools.permutations([1,2,3]))
199221
```
222+
---
223+
```python
224+
"""Solution by: popomaticbubble
225+
"""
226+
from itertools import permutations
227+
228+
def permuation_generator(iterable):
229+
p = permutations(iterable)
230+
for i in p:
231+
print(i)
200232

233+
234+
x = [1,2,3]
235+
permuation_generator(x)
236+
```
201237
---
202238

203239
# Question 94
@@ -226,12 +262,40 @@ def solve(numheads,numlegs):
226262
return i,j
227263
return ns,ns
228264

229-
numheads=35
230-
numlegs=94
265+
numheads = 35
266+
numlegs = 94
231267
solutions=solve(numheads,numlegs)
232268
print solutions
233269
```
270+
---
271+
```python
272+
"""Solution by: popomaticbubble
273+
"""
274+
import itertools
234275

276+
def animal_counter(lst):
277+
chickens = 0
278+
rabbits = 0
279+
for i in lst:
280+
if i == 2:
281+
chickens += 1
282+
elif i == 4:
283+
rabbits += 1
284+
print(f"Number of chickens is {chickens}\nNumber of rabbits is {rabbits}")
285+
286+
287+
def animal_calculator(total_legs, total_heads, legs_of_each_species):
288+
combinations = itertools.combinations_with_replacement(legs_of_each_species, total_heads)
289+
correct_combos = []
290+
for i in list(combinations):
291+
if sum(i) == total_legs:
292+
correct_combos.append(i)
293+
print(correct_combos)
294+
for i in correct_combos:
295+
animal_counter(i)
296+
297+
animal_calculator(94, 35, legs_of_each_species=[2,4])
298+
```
235299
---
236300

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

Status/Day_23.md

+21
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,27 @@ string = input('')
157157
print('\n'.join(textwrap.wrap(string, width= int(input('')))))
158158
```
159159
---
160+
```python
161+
"""solution by : popomaticbubble
162+
"""
163+
import itertools
164+
string = input("> ")
165+
width_length = int(input("What is the width of the groupings? "))
166+
167+
def grouper(string, width):
168+
iters = [iter(string)] * width
169+
return itertools.zip_longest(*iters, fillvalue='')
170+
171+
def displayer(groups):
172+
for x in groups:
173+
if x == '':
174+
continue
175+
else:
176+
print(''.join(x))
177+
178+
displayer(grouper(string, width_length))
179+
```
180+
---
160181
# Question 97
161182

162183
### **Question**

Status/Day_24.md

+17
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,24 @@ n = int(input())
203203
sum = rec(n)
204204
print(sum)
205205
```
206+
---
207+
```python
208+
"""Solution by: popomaticbubble
209+
"""
210+
def summer(counter, n, current):
211+
if n == 0:
212+
return 0
213+
if counter == n:
214+
return current+n
215+
else:
216+
current = current + counter
217+
counter += 1
218+
return summer(counter, n, current)
206219

220+
221+
N = int(input("> "))
222+
print(summer(1, N, 0))
223+
```
207224
---
208225

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

0 commit comments

Comments
 (0)