Skip to content

Commit d648e99

Browse files
W3HW
1 parent 168fc6b commit d648e99

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

‎Week03/pyramid_umut_turk.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def calculate_pyramid_height(b_num):
2+
a, b = 1, 0
3+
while b < b_num:
4+
b += a+1
5+
a += 1
6+
7+
8+
return a-1
9+
10+
if __name__ == "__main__":
11+
print(calculate_pyramid_height(15))

‎Week03/sequences.py‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
def remove_duplicates(a_list):
2+
my_list = a_list[:]
3+
x = 1
4+
for i in my_list:
5+
for j in my_list[x:]:
6+
if i == j:
7+
my_list.remove(i)
8+
x -=1
9+
break
10+
x +=1
11+
12+
return my_list
13+
def list_counts(a_list):
14+
my_list = a_list[:]
15+
a = remove_duplicates(my_list)
16+
my_dict = dict.fromkeys(a)
17+
for i in a:
18+
x = 0
19+
for j in a_list:
20+
if i == j:
21+
x += 1
22+
my_dict[i] = x
23+
24+
return my_dict
25+
def reverse_dict(a_dict):
26+
my_dict = {}
27+
a_list = list(a_dict)
28+
b_list = list(a_dict.values())
29+
x = 0
30+
while x < len(a_list):
31+
print(1)
32+
my_dict[b_list[x]] = a_list[x]
33+
x += 1
34+
35+
return my_dict
36+
37+
if __name__ == "__main__":
38+
print(remove_duplicates([1,5,4,4,4,6,41,54,54,41,6]))
39+
print(list_counts([1,5,5,4,4,4,6,6,6,41,41,41,41,41,54,54,54,54,54,54,54,54,41,6]))
40+
print(reverse_dict(list_counts([1,5,5,4,4,4,6,6,6,41,41,41,41,41,54,54,54,54,54,54,54,54,41,6])))

0 commit comments

Comments
 (0)