```{.python}
from itertools import cycle
nums = ''.join(str(x) for x in range(1,10))
pw = lambda : print('Wrong input')
av_pos = lambda res : 'available pos: '+ ', '.join(x for x in res if x not in ('A', 'B')) +'\n'
inpt = lambda fr, res: int(input(av_pos(res) + fr + ' : '))-1
check = lambda b: any(True if x == b&x else False for x in (448, 56, 7, 292, 146, 73, 273, 84))
output = lambda res: print(''.join(x+'\n' if i%3 == 2 else x for i, x in enumerate(res)))
main_code = list(compile('''while 1:\n {0} = inpt('{0}', res); n = 1 << {0}\n if (1 << {0}) & game == 1: pw(); continue\n else: break\ngame += n; {1} += n; res = res[:{0}] + '{0}' + res[{0}+1:]'''.format(T, T.lower()), '<string>', 'exec') for T in 'AB')
check_code = list(compile('check({})'.format(T.lower()), '<string>', 'eval') for T in 'AB')
while __name__ == '__main__':
game = 2**9; draw = game-1
res = nums
a, b = 0, 0
for Ti in cycle('AB'):
i = (0 if T == 'A' else(0, 1)):
exec(main_code[i])
if eval(check_code[i]): break
if a + b == draw: print('draw'); break
output(res)
output(res)
```
이진수로 풀어보았습니다. 반복되는 코드를 없애다 보니 문자열이 난무하네요. 파이썬 3.5.1
+
itertools.cycle:해당 반복가능한 객체를 반복.
```{.python}
from itertools import cycle
nums = ''.join(str(x) for x in range(1,10))
pw = lambda : print('Wrong input')
av_pos = lambda res : 'available pos: '+ ', '.join(x for x in res if x not in ('A', 'B')) +'\n'
inpt = lambda fr, res: int(input(av_pos(res) + fr + ' : '))-1
check = lambda b: any(True if x == b&x else False for x in (448, 56, 7, 292, 146, 73, 273, 84))
output = lambda res: print(''.join(x+'\n' if i%3 == 2 else x for i, x in enumerate(res)))
main_code = list(compile('''while 1:\n {0} = inpt('{0}', res); n = 1 << {0}\n if (1 << {0}) & game == 1: pw(); continue\n else: break\ngame += n; {1} += n; res = res[:{0}] + '{0}' + res[{0}+1:]'''.format(T, T.lower()), '<string>', 'exec') for T in 'AB')
check_code = list(compile('check({})'.format(T.lower()), '<string>', 'eval') for T in 'AB')
while __name__ == '__main__':
game = 2**9; draw = game-1
res = nums
a, b = 0, 0
for Ti in cycle('AB'):
i = (0 if T == 'A' else(0, 1)):
exec(main_code[i])
if eval(check_code[i]): break
if a + b == draw: print('draw'); break
output(res)
output(res)
```
이진수로 풀어보았습니다. 반복되는 코드를 없애다 보니 문자열이 난무하네요. 파이썬 3.5.1
+
itertools.cycle:해당 반복가능한 객체를 반복.