Skip to content

Commit 081eb41

Browse files
committed
🎨 Update
1 parent 025c2cc commit 081eb41

File tree

7 files changed

+84
-0
lines changed

7 files changed

+84
-0
lines changed

medium/03_write_func.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def is_leap(year: int) -> bool:
2+
return year % 4 == 0 and (year % 400 == 0 or year % 100 != 0)
3+
4+
5+
if __name__ == "__main__":
6+
print(is_leap(int(input())))

medium/04_time_delta.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from datetime import datetime as dt
2+
3+
4+
def main(date_format: str) -> None:
5+
for _ in range(int(input())):
6+
7+
print(
8+
int(
9+
abs(
10+
(
11+
dt.strptime(input(), date_format)
12+
- dt.strptime(input(), date_format)
13+
).total_seconds()
14+
)
15+
)
16+
)
17+
18+
19+
if __name__ == "__main__":
20+
main("%a %d %b %Y %H:%M:%S %z")

medium/05_no_idea.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def main() -> int:
2+
unused_one, unused_two = input().split()
3+
4+
input_one = input().split()
5+
6+
input_three = set(input().split())
7+
input_four = set(input().split())
8+
9+
return sum([(item in input_three) - (item in input_four) for item in input_one])
10+
11+
12+
if __name__ == "__main__":
13+
print(main())

medium/06_word_order.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from collections import Counter, OrderedDict
2+
3+
4+
# I nned a class that inherits Counter and OrderedDict
5+
class OrderedCounter(Counter, OrderedDict):
6+
pass
7+
8+
9+
def main():
10+
ordered_counter_instance = OrderedCounter(input() for _ in range(int(input())))
11+
12+
print(len(ordered_counter_instance))
13+
print(*ordered_counter_instance.values())
14+
15+
16+
if __name__ == "__main__":
17+
main()

medium/07_compress_string.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from itertools import groupby
2+
3+
4+
def main():
5+
return [(len(list(c)), int(k)) for k, c in groupby(input())]
6+
7+
8+
if __name__ == "__main__":
9+
print(*main())

medium/08_ierables_and_iterators.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from itertools import combinations
2+
3+
4+
def main():
5+
unused_one = int(input())
6+
lst = input().split()
7+
num = int(input())
8+
9+
C = list(combinations(lst, num))
10+
F = filter(lambda c: "a" in c, C)
11+
12+
return "{0:.3}".format(len(list(F)) / len(C))
13+
14+
15+
if __name__ == "__main__":
16+
print(main())

medium/09_trinagle_quest_2.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def main() -> None:
2+
for num in range(1, int(input()) + 1):
3+
print((10 ** num // 9) ** 2)

0 commit comments

Comments
 (0)