File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ def calculate_pyramid_height (number_of_blocks ):
2+ height = 0
3+
4+ while number_of_blocks >= (height + 1 ):
5+ height += 1
6+ number_of_blocks -= height
7+
8+ return height
Original file line number Diff line number Diff line change 1+ def remove_duplicates (seq : list ) -> list :
2+ """
3+ This function removes duplicates from a list.
4+ """
5+ return list (set (seq ))
6+
7+
8+ def list_counts (seq : list ) -> dict :
9+ """
10+ This function counts the number of occurrences of each item in a list.
11+ """
12+ counts = {}
13+ for item in seq :
14+ if item in counts :
15+ counts [item ] += 1
16+ else :
17+ counts [item ] = 1
18+ return counts
19+
20+
21+ def reverse_dict (d : dict ) -> dict :
22+ """
23+ This function reverses the keys and values of a dictionary.
24+ """
25+ return {value : key for (key , value ) in d .items ()}
You can’t perform that action at this time.
0 commit comments