코딩도장

코딩도장

변경이력

돌아가기
3 6개 문자 추가 40개 문자 삭제

2016年06月27日 14:33

Flair Sizz

```{.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:해당 반복가능한 객체를 반복.
```{.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:해당 반복가능한 객체를 반복.
2 333개 문자 추가 131개 문자 삭제

2016年06月27日 13:35

Flair Sizz

```{.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 T in cycle('AB'): exec(code[i = (0 if T == 'A' else 1) exec(main_code[i]) if eval('check({})'.format(T.lower())): print(T + ' wins'); break print(''.join(x+'\n' if i%3 == 2 else x for i, x in enumerate_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 T in cycle('AB'): exec(code[i = (0 if T == 'A' else 1) exec(main_code[i]) if eval('check({})'.format(T.lower())): print(T + ' wins'); break print(''.join(x+'\n' if i%3 == 2 else x for i, x in enumerate_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 T in cycle('AB'): exec(code[i = (0 if T == 'A' else 1) exec(main_code[i]) if eval('check({})'.format(T.lower())): print(T + ' wins'); break print(''.join(x+'\n' if i%3 == 2 else x for i, x in enumerate_code[i]): break if a + b == draw: print('draw'); break output(res) output(res))) ``` 이진수로 풀어보았습니다. 반복되는 코드를 없애다 보니 문자열이 난무하네요. 파이썬 3.5.1 + itertools.cycle:해당 반복가능한 객체를 반복.
1 Original

2016年06月27日 13:10

Flair Sizz

```{.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)) 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') while __name__ == '__main__': game = 2**9 res = nums a, b = 0, 0 for T in cycle('AB'): exec(code[0 if T == 'A' else 1]) if eval('check({})'.format(T.lower())): print(T + ' wins'); break print(''.join(x+'\n' if i%3 == 2 else x for i, x in enumerate(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)) 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') while __name__ == '__main__': game = 2**9 res = nums a, b = 0, 0 for T in cycle('AB'): exec(code[0 if T == 'A' else 1]) if eval('check({})'.format(T.lower())): print(T + ' wins'); break print(''.join(x+'\n' if i%3 == 2 else x for i, x in enumerate(res))) ``` 이진수로 풀어보았습니다. 반복되는 코드를 없애다 보니 문자열이 난무하네요. 파이썬 3.5.1 + itertools.cycle:해당 반복가능한 객체를 반복.
코딩도장

코딩도장은 프로그래밍 문제풀이를 통해서 코딩 실력을 수련(Practice)하는 곳입니다.

코딩도장 © 2014 · 문의 [email protected]
피드백 · 개인정보취급방침 · RSS

AltStyle によって変換されたページ (->オリジナル) /