Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import os.path
- test_cases = [[(b"""19
- 24
- 23
- 25
- 22
- 40
- 57
- 14
- 12
- 23
- """, "34"),
- (b"""1
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- """, "1"),
- (b"""-4
- -3
- -2
- -1
- 0
- 1
- 2
- 3
- 4
- 5
- """, "0"),
- (b"""0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- """, "0"),
- (b"""1
- 11
- 111
- 2
- 22
- 222
- 3
- 333
- 33
- 123
- """, "167") ],
- [(b"abc de f gh hij klmn opqrs", "opqrs"),
- (b"qwerty asdf zxc", "qwerty"),
- (b"aaa bbb ccc", "aaa"),
- (b"a v z", "a"),
- (b"testestestestestestestestestestestestestestestestsetset", "testestestestestestestestestestestestestestestestsetset")],
- [(b"123456789", "97531"),
- (b"5000 rubley menshe 100 dollarov no bolshe 1300 yen", "5311"),
- (b"ne imei 100 rubley a imey horoshih druzey", "1"),
- (b"9 zaytcev sobraly 99 morkovok ostalas 1", "9991"),
- (b"7", "7")],
- [(b"abcde", "zcded"),
- (b"qWeRtY", "rXdSuX"),
- (b"asdf JKL", "zteg KLM"),
- (b"Clannad Kanon Air", "Dmzooze Lzono Zhs"),
- (b"test", "udtu")],
- [(b"a", "a"),
- (b"a b c", "a b c"),
- (b"test estt stte ttes", "t"),
- (b"abc baC xyz YxZ", "c z"),
- (b"A AND B", "a d b")]]
- def test_task(tests, task_name):
- scores = []
- for test in tests:
- task = subprocess.Popen(["python", task_name], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
- res, err = task.communicate(test[0])
- if res.decode("utf-8").rstrip() == test[1]:
- scores.append(4)
- else:
- scores.append(0)
- return scores
- if __name__ == "__main__":
- total = 0
- for i in range(0, 5):
- file_task = "task{i}.py".format(i=i+1)
- if os.path.exists(file_task) and len(test_cases) > i:
- res = test_task(test_cases[i], file_task)
- total += sum(res)
- print("{task}: {res}. Total: {sum}".format(task=file_task, res=res, sum=sum(res)))
- else:
- print("{task} not found".format(task=file_task))
- print("Total: {total}".format(total=total))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement