def solution(N: int) -> (int, int):
N1, N2 = [], []
for i in str(N):
if int(i) & 1 == 0:
N1.append(i)
else:
N2.append(i)
if not N2: N2 = ['0']
if not N1: N1 = ['0']
dict1 = (int(''.join(i for i in N1)), int(''.join(i for i in N2)))
return dict1
def solution(N: int) -> (int, int):
NE = []
NO = []
[NE.append(i) if int(i)%2 == 0 else NO.append(i) for i in str(N)]
NE.append("0") if NE==[] else NE
NO.append("0") if NO==[] else NO
return tuple((int("".join(NE)),int("".join(NO))))
assert solution(126453) == (264, 153)
assert solution(3012) == (2, 31)
assert solution(4628) == (4628, 0)
def solution(n: int) -> (int, int):
# your code here
ne = ""
no = ""
n_str = str(n)
for i in n_str:
if int(i) % 2 == 0:
ne += ne.join(i)
else:
no += no.join(i)
if ne == "" and no != "":
return 0, int(no)
elif ne != "" and no == "":
return int(ne), 0
else:
return int(ne), int(no)
assert solution(126453) == (264, 153)
assert solution(3012) == (2, 31)
assert solution(4628) == (4628, 0)
def solution(N: int) -> (int, int):
# 0301 奇数偶数
NE = ''
NO = ''
for i in str(N):
if int(i) % 2 == 1:
NO += NO.join(i)
else:
NE += NE.join(i)
if NE == '':
NE = 0
if NO == '':
NO = 0
print(NE, NO)
return (int(NE), int(NO))
assert solution(126453) == (264, 153)
assert solution(3012) == (2, 31)
assert solution(4628) == (4628, 0)
def solution(N: int) -> (int, int):
NE, NO = [], []
for i in str(N):
if int(i) % 2 == 0:
NO.append(i)
else:
NE.append(i)
if not NO: NO = ['0']
if not NE: NE = ['0']
Result = (int("".join(list(i for i in NO))), int("".join(list(i for i in NE))))
return Result
assert solution(126453) == (264, 153)
assert solution(3012) == (2, 31)
assert solution(4628) == (4628, 0)
def solution(n: int) -> (int, int):
ne = no = 0
i = j = 0
while n != 0:
x = n % 10
n = n // 10
if x % 2 == 0:
ne += x * 10 ** i
i += 1
else:
no += x * 10 ** j
j += 1
return ne, no
assert solution(126453) == (264, 153)
assert solution(3012) == (2, 31)
assert solution(4628) == (4628, 0)
def solution(N: int) -> (int, int):
s = []
n = []
for i in range(len(str(N))):
if str(N)[i] in '2468':
s.append(str(N)[i])
elif str(N)[i] in '13579':
n.append(str(N)[i])
return int(''.join(s)) if s else 0, int(''.join(n)) if n else 0
assert solution(126453) == (264, 153)
assert solution(3012) == (2, 31)
assert solution(4628) == (4628, 0)
def solution(N: int) -> (int, int):
# your code here
NE = ''
NO = ''
str_N = str(N)
for i in str_N:
if int(i)%2 == 0 :
NE = NE+i
elif int(i)%2 == 1:
NO = NO+i
if NE == '':
NE = 0
if NO == '':
NO = 0
return (int(NE),int(NO))
assert solution(126453) == (264, 153)
assert solution(3012) == (2, 31)
assert solution(4628) == (4628, 0)