Skip to content

Commit 33e112a

Browse files
committed
solved(python): baekjoon 6064
1 parent 6d2e970 commit 33e112a

4 files changed

Lines changed: 76 additions & 0 deletions

File tree

baekjoon/python/6064/__init__.py

Whitespace-only changes.

baekjoon/python/6064/main.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import sys
2+
3+
read = lambda: sys.stdin.readline().rstrip()
4+
5+
6+
class Problem:
7+
def __init__(self):
8+
self.m, self.n, self.x, self.y = map(int, read().split(" "))
9+
10+
def solve(self) -> None:
11+
print(self.find())
12+
13+
def find(self) -> int:
14+
for value in range(self.x, self.m * self.n + 1, self.m):
15+
if value % self.n == self.y or (self.n == self.y and value % self.n == 0):
16+
return value
17+
18+
return -1
19+
20+
21+
if __name__ == "__main__":
22+
for _ in range(int(read())):
23+
Problem().solve()

baekjoon/python/6064/sample.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[
2+
{
3+
"input": [
4+
"3",
5+
"10 12 3 9",
6+
"10 12 7 2",
7+
"13 11 5 6"
8+
],
9+
"expected": [
10+
"33",
11+
"-1",
12+
"83"
13+
]
14+
}
15+
]

baekjoon/python/6064/test_main.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import json
2+
import os.path
3+
import sys
4+
import unittest
5+
from io import StringIO
6+
from unittest.mock import patch
7+
8+
from parameterized import parameterized
9+
10+
from main import Problem
11+
12+
13+
def load_sample(filename: str):
14+
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), filename)
15+
16+
with open(path, "r") as file:
17+
return [(case["input"], case["expected"]) for case in json.load(file)]
18+
19+
20+
class TestCase(unittest.TestCase):
21+
@parameterized.expand(load_sample("sample.json"))
22+
def test_case(self, case: str, expected: list[str]):
23+
# When
24+
with (
25+
patch("sys.stdin.readline", side_effect=case),
26+
patch("sys.stdout", new_callable=StringIO) as output,
27+
):
28+
for _ in range(int(sys.stdin.readline().rstrip())):
29+
Problem().solve()
30+
31+
result = output.getvalue().rstrip()
32+
33+
# Then
34+
self.assertEqual("\n".join(expected), result)
35+
36+
37+
if __name__ == "__main__":
38+
unittest.main()

0 commit comments

Comments
 (0)