Skip to content

Commit 17cf42a

Browse files
committed
Solve string problems
1 parent 7fe7bf4 commit 17cf42a

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

baekjoon/11720/neva/11720.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from sys import stdin
2+
3+
stdin.readline()
4+
print(sum(map(int, list(stdin.readline().strip()))))

baekjoon/1316/neva/1316.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from sys import stdin
2+
3+
words_num = int(stdin.readline())
4+
5+
def is_group_word(word):
6+
pre = ''
7+
pre_chars = []
8+
for char in word:
9+
if pre != char:
10+
if char not in pre_chars:
11+
pre_chars.append(char)
12+
else:
13+
return False
14+
pre = char
15+
return True
16+
17+
cnt_group_word = 0
18+
for _ in range(words_num):
19+
if is_group_word(stdin.readline().strip()):
20+
cnt_group_word += 1
21+
22+
print(cnt_group_word)

baekjoon/3029/neva/3029.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from sys import stdin
2+
3+
now_h, now_m, now_s = map(int, stdin.readline().strip().split(':'))
4+
throw_h, throw_m, throw_s = map(int, stdin.readline().strip().split(':'))
5+
6+
now_time = now_h * 3600 + now_m * 60 + now_s
7+
throw_time = throw_h * 3600 + throw_m * 60 + throw_s
8+
wait_time = throw_time - now_time
9+
10+
if wait_time < 0:
11+
wait_time += 86400
12+
elif wait_time == 0:
13+
wait_time = 86400
14+
15+
wait_h = wait_time // 3600
16+
wait_time -= wait_h * 3600
17+
wait_m = wait_time // 60
18+
wait_time -= wait_m * 60
19+
wait_s = wait_time
20+
21+
print("%02d:%02d:%02d" % (wait_h, wait_m, wait_s))

baekjoon/9046/neva/9046.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from sys import stdin
2+
3+
string_num = int(stdin.readline())
4+
5+
for _ in range(string_num):
6+
chars = {}
7+
string = list(stdin.readline().strip())
8+
9+
for char in string:
10+
if char in chars:
11+
chars[char] += 1
12+
elif ' ' != char:
13+
chars[char] = 1
14+
15+
max_values = [k for k, v in chars.items() if max(chars.values()) == v]
16+
17+
if 1 < len(max_values):
18+
print("?")
19+
else:
20+
print(max_values[0])

0 commit comments

Comments
 (0)