-
Notifications
You must be signed in to change notification settings - Fork 2
/
8958.py
41 lines (29 loc) · 1.1 KB
/
8958.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# [ 백준 ] 8958번: OX퀴즈
def solution() -> None:
import sys
input = sys.stdin.readline
for _ in range(int(input())):
answer, consecutive_count = 0, 0
for result in input():
if result == "O":
consecutive_count += 1
answer += consecutive_count
else:
consecutive_count = 0
print(answer)
if __name__ == "__main__":
from io import StringIO
from unittest.mock import patch
def test_example_case(input: list[str]) -> str:
with patch("sys.stdin.readline", side_effect=input):
with patch("sys.stdout", new_callable=StringIO) as test_stdout:
solution()
return test_stdout.getvalue()
case: dict[str, list[str] | str] = {
"input": [
"5", "OOXXOXXOOO", "OOXXOOXXOO", "OXOXOXOXOXOXOX",
"OOOOOOOOOO", "OOOOXOOOOXOOOOX"
],
"output": "10\n9\n7\n55\n30\n"
}
assert case["output"] == test_example_case(input=case["input"])