Skip to content

Commit 571d411

Browse files
committed
🎨 Update
1 parent d7b8383 commit 571d411

11 files changed

+102
-6
lines changed

easy/32_default_dict.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
from collections import defaultdict
22

3-
d = defaultdict(list)
43

5-
n, m = map(int, input().split())
4+
def run():
5+
d = defaultdict(list)
66

7-
for i in range(1, n + 1):
8-
d[input()].append(str(i))
7+
n, m = map(int, input().split())
98

10-
for i in range(m):
11-
print(" ".join(d[input()]) or -1)
9+
for i in range(1, n + 1):
10+
d[input()].append(str(i))
11+
12+
for i in range(m):
13+
print(" ".join(d[input()]) or -1)
14+
15+
if __name__ == "__main__":
16+
run()

easy/34_exceptions.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def main():
2+
for _ in range(int(input())):
3+
try:
4+
a, b = map(int, input().split())
5+
print(a // b)
6+
except BaseException as e:
7+
print("Error Code:", e)
8+
9+
10+
if __name__ == "__main__":
11+
main()

easy/35_coolections_named_tuple.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from collections import namedtuple
2+
3+
4+
def run():
5+
n, score = int(input()), namedtuple("Score", input().split())
6+
scores = [score(*input().split()).MARKS for i in range(n)]
7+
print("%.2f" % (sum(map(int, scores)) / n))
8+
9+
10+
if __name__ == "__main__":
11+
run()

easy/36_ord_dict.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from collections import OrderedDict
2+
3+
4+
def run():
5+
d = OrderedDict()
6+
7+
for _ in range(int(input())):
8+
item, _, quantity = input().rpartition(" ")
9+
d[item] = d.get(item, 0) + int(quantity)
10+
for item, quantity in d.items():
11+
print(item, quantity)
12+
13+
14+
if __name__ == "__main__":
15+
run()

easy/37_symetric_differece.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def run():
2+
a, b = [set(input().split()) for _ in range(4)][1::2]
3+
print(*sorted(a ^ b, key=int), sep="\n")
4+
5+
if __name__ == "__main__":
6+
run()

easy/38_combinations.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from itertools import combinations
2+
3+
4+
def run():
5+
s, n = input().split()
6+
7+
for i in range(1, int(n) + 1):
8+
for j in combinations(sorted(s), i):
9+
print("".join(j))
10+
11+
if __name__ == "__main__":
12+
run()

easy/39_incorrect_regex.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import re
2+
3+
4+
def is_valid_regex(regex):
5+
try:
6+
re.compile(regex)
7+
except re.error:
8+
return False
9+
return True
10+
11+
12+
if __name__ == "__main__":
13+
for _ in range(int(input())):
14+
print(is_valid_regex(input()))

easy/40_powers.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def main():
2+
a, b, m = [int(input()) for _ in "123"]
3+
print(pow(a, b), pow(a, b, m), sep="\n")
4+
5+
6+
if __name__ == "__main__":
7+
main()

easy/41_mod_vidmod.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def main(a: int, b: int) -> str:
2+
return "{0}\n{1}\n({0}, {1})".format(*divmod(a, b))
3+
4+
5+
if __name__ == "__main__":
6+
print(main(int(input()), int(input())))

easy/42_inter_op.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def main() -> int:
2+
_, a = input(), set(input().split())
3+
_, b = input(), set(input().split())
4+
5+
return len(a.intersection(b))
6+
7+
8+
if __name__ == "__main__":
9+
print(main())

0 commit comments

Comments
 (0)