Compare commits
6
Commits
58b85d23dd
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d8e66cc05 | ||
|
|
72f33ca843 | ||
|
|
39b258ffec | ||
|
|
524581e2fc | ||
|
|
6be0a0233e | ||
|
|
ef3034a966 |
@@ -0,0 +1,9 @@
|
|||||||
|
def remove_duplicate_chars(s: str) -> str:
|
||||||
|
result = ""
|
||||||
|
for char in s:
|
||||||
|
if char not in result:
|
||||||
|
result += char
|
||||||
|
return result
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print(f"remove_duplicate_chars('abacabad') → {remove_duplicate_chars('abacabad')}")
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
def most_frequent_value(d: dict) -> tuple:
|
||||||
|
frequency = {}
|
||||||
|
for value in d.values():
|
||||||
|
if value in frequency:
|
||||||
|
frequency[value] += 1
|
||||||
|
else:
|
||||||
|
frequency[value] = 1
|
||||||
|
max_value = None
|
||||||
|
max_count = 0
|
||||||
|
for value, count in frequency.items():
|
||||||
|
if count > max_count:
|
||||||
|
max_count = count
|
||||||
|
max_value = value
|
||||||
|
return(max_value, max_count)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print(most_frequent_value({"a": 1, "b": 2, "c": 1, "d": 3}))
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
def gcd(a: int, b: int) -> int:
|
||||||
|
result = []
|
||||||
|
for i in range(1, min(a, b) + 1):
|
||||||
|
if a % i == 0 and b % i == 0:
|
||||||
|
result.append(i)
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
return max(result)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print(gcd(18, 24))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user