forked from adnanaziz/EPIJudge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheven_odd_array.py
36 lines (27 loc) · 914 Bytes
/
even_odd_array.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
import collections
import functools
from typing import List
from test_framework import generic_test
from test_framework.test_failure import TestFailure
from test_framework.test_utils import enable_executor_hook
def even_odd(A: List[int]) -> None:
# TODO - you fill in here.
return
@enable_executor_hook
def even_odd_wrapper(executor, A):
before = collections.Counter(A)
executor.run(functools.partial(even_odd, A))
in_odd = False
for a in A:
if a % 2 == 0:
if in_odd:
raise TestFailure('Even elements appear in odd part')
else:
in_odd = True
after = collections.Counter(A)
if before != after:
raise TestFailure('Elements mismatch')
if __name__ == '__main__':
exit(
generic_test.generic_test_main('even_odd_array.py',
'even_odd_array.tsv', even_odd_wrapper))