코딩도장

코딩도장

변경이력

돌아가기
2 180개 문자 추가 448개 문자 삭제

2017年09月01日 08:19

piko

```{.python} arr1_1 = [[['1','2','3'],['4','5','6'],['7','8','9']] arr2 = , [['1','4','7'],['2','5','8'],['3','6','9']] arr3 = , [['1','5','9'],['3','5','7'],['.','.','.']]] def f1(): result = ', '.join([', '.join([x1 for x1 in x if x1!='O' and x1!='X']) for x in arr1_1[0]]) return result def f2(nums, typ1): for i1 in range(0, len(arr1_1)): if arr1[i1].count(nums) > 0: arr1[i1][arr1[i1].index(nums)] = typ1 if arr2[i1].count(nums) > 0: arr2[i1][arr2[i1].index(nums)] = typ1 if arr3for i2 in range(0, len(arr1_1[i1])): if arr1_1[i1][i12].count(nums) > 0: arr3[i1][arr3[i1 arr1_1[i1][i2][arr1_1[i1][i2].index(nums)] = typ1 print('\n'.join([' * '.join([x1 for x1 in x]) for x in arr1_1[0]])) def f3(typ1, idx1): if arr1.count([typ1 for xi1 in range(0, 3)]) > 0: print('Win playear is: player ', idx1) return typ1 if arr2.count([typ1 for x in range(0, 3)]) > 0: print('Win playear is: player ', idx1) return typ1 if arr3len(arr1_1)): if arr1_1[i1].count([typ1 for x in range(0, 3)]) > 0: print('Win playear is: player ', idx1) return typ1 return '' def f(): while f1()!='': for idx1, typ1 in enumerate(['X','O']): plys = '' str1 = f1() while True: plys = input('Player '+str(idx1+1)+' - please type a position (available position(s) are ' + str1 + '):') if str1.count(plys) > 0: break f2(plys, typ1) if f3(typ1, str(idx1+1)) != '': return False if f1() == '': print('End..') return True f() ```
```{.python} arr1_1 = [[['1','2','3'],['4','5','6'],['7','8','9']] arr2 = , [['1','4','7'],['2','5','8'],['3','6','9']] arr3 = , [['1','5','9'],['3','5','7'],['.','.','.']]] def f1(): result = ', '.join([', '.join([x1 for x1 in x if x1!='O' and x1!='X']) for x in arr1_1[0]]) return result def f2(nums, typ1): for i1 in range(0, len(arr1_1)): if arr1[i1].count(nums) > 0: arr1[i1][arr1[i1].index(nums)] = typ1 if arr2[i1].count(nums) > 0: arr2[i1][arr2[i1].index(nums)] = typ1 if arr3for i2 in range(0, len(arr1_1[i1])): if arr1_1[i1][i12].count(nums) > 0: arr3[i1][arr3[i1 arr1_1[i1][i2][arr1_1[i1][i2].index(nums)] = typ1 print('\n'.join([' * '.join([x1 for x1 in x]) for x in arr1_1[0]])) def f3(typ1, idx1): if arr1.count([typ1 for xi1 in range(0, 3)]) > 0: print('Win playear is: player ', idx1) return typ1 if arr2.count([typ1 for x in range(0, 3)]) > 0: print('Win playear is: player ', idx1) return typ1 if arr3len(arr1_1)): if arr1_1[i1].count([typ1 for x in range(0, 3)]) > 0: print('Win playear is: player ', idx1) return typ1 return '' def f(): while f1()!='': for idx1, typ1 in enumerate(['X','O']): plys = '' str1 = f1() while True: plys = input('Player '+str(idx1+1)+' - please type a position (available position(s) are ' + str1 + '):') if str1.count(plys) > 0: break f2(plys, typ1) if f3(typ1, str(idx1+1)) != '': return False if f1() == '': print('End..') return True f() ```
```{.python} arr1_1 = [[['1','2','3'],['4','5','6'],['7','8','9']] arr2 = , [['1','4','7'],['2','5','8'],['3','6','9']] arr3 = , [['1','5','9'],['3','5','7'],['.','.','.']]] def f1(): result = ', '.join([', '.join([x1 for x1 in x if x1!='O' and x1!='X']) for x in arr1_1[0]]) return result def f2(nums, typ1): for i1 in range(0, len(arr1_1)): if arr1[i1].count(nums) > 0: arr1[i1][arr1[i1].index(nums)] = typ1 if arr2[i1].count(nums) > 0: arr2[i1][arr2[i1].index(nums)] = typ1 if arr3for i2 in range(0, len(arr1_1[i1])): if arr1_1[i1][i12].count(nums) > 0: arr3[i1][arr3[i1 arr1_1[i1][i2][arr1_1[i1][i2].index(nums)] = typ1 print('\n'.join([' * '.join([x1 for x1 in x]) for x in arr1_1[0]])) def f3(typ1, idx1): if arr1.count([typ1 for xi1 in range(0, 3)]) > 0: print('Win playear is: player ', idx1) return typ1 if arr2.count([typ1 for x in range(0, 3)]) > 0: print('Win playear is: player ', idx1) return typ1 if arr3len(arr1_1)): if arr1_1[i1].count([typ1 for x in range(0, 3)]) > 0: print('Win playear is: player ', idx1) return typ1 return '' def f(): while f1()!='': for idx1, typ1 in enumerate(['X','O']): plys = '' str1 = f1() while True: plys = input('Player '+str(idx1+1)+' - please type a position (available position(s) are ' + str1 + '):') if str1.count(plys) > 0: break f2(plys, typ1) if f3(typ1, str(idx1+1)) != '': return False if f1() == '': print('End..') return True f() ```
1 Original

2017年09月01日 08:05

piko

```{.python} arr1 = [['1','2','3'],['4','5','6'],['7','8','9']] arr2 = [['1','4','7'],['2','5','8'],['3','6','9']] arr3 = [['1','5','9'],['3','5','7'],['.','.','.']] def f1(): result = ', '.join([', '.join([x1 for x1 in x if x1!='O' and x1!='X']) for x in arr1]) return result def f2(nums, typ1): for i1 in range(0, len(arr1)): if arr1[i1].count(nums) > 0: arr1[i1][arr1[i1].index(nums)] = typ1 if arr2[i1].count(nums) > 0: arr2[i1][arr2[i1].index(nums)] = typ1 if arr3[i1].count(nums) > 0: arr3[i1][arr3[i1].index(nums)] = typ1 print('\n'.join([' * '.join([x1 for x1 in x]) for x in arr1])) def f3(typ1, idx1): if arr1.count([typ1 for x in range(0, 3)]) > 0: print('Win playear is: player ', idx1) return typ1 if arr2.count([typ1 for x in range(0, 3)]) > 0: print('Win playear is: player ', idx1) return typ1 if arr3.count([typ1 for x in range(0, 3)]) > 0: print('Win playear is: player ', idx1) return typ1 return '' def f(): while f1()!='': for idx1, typ1 in enumerate(['X','O']): plys = '' str1 = f1() while True: plys = input('Player '+str(idx1+1)+' - please type a position (available position(s) are ' + str1 + '):') if str1.count(plys) > 0: break f2(plys, typ1) if f3(typ1, str(idx1+1)) != '': return False if f1() == '': print('End..') return True f() ```
```{.python} arr1 = [['1','2','3'],['4','5','6'],['7','8','9']] arr2 = [['1','4','7'],['2','5','8'],['3','6','9']] arr3 = [['1','5','9'],['3','5','7'],['.','.','.']] def f1(): result = ', '.join([', '.join([x1 for x1 in x if x1!='O' and x1!='X']) for x in arr1]) return result def f2(nums, typ1): for i1 in range(0, len(arr1)): if arr1[i1].count(nums) > 0: arr1[i1][arr1[i1].index(nums)] = typ1 if arr2[i1].count(nums) > 0: arr2[i1][arr2[i1].index(nums)] = typ1 if arr3[i1].count(nums) > 0: arr3[i1][arr3[i1].index(nums)] = typ1 print('\n'.join([' * '.join([x1 for x1 in x]) for x in arr1])) def f3(typ1, idx1): if arr1.count([typ1 for x in range(0, 3)]) > 0: print('Win playear is: player ', idx1) return typ1 if arr2.count([typ1 for x in range(0, 3)]) > 0: print('Win playear is: player ', idx1) return typ1 if arr3.count([typ1 for x in range(0, 3)]) > 0: print('Win playear is: player ', idx1) return typ1 return '' def f(): while f1()!='': for idx1, typ1 in enumerate(['X','O']): plys = '' str1 = f1() while True: plys = input('Player '+str(idx1+1)+' - please type a position (available position(s) are ' + str1 + '):') if str1.count(plys) > 0: break f2(plys, typ1) if f3(typ1, str(idx1+1)) != '': return False if f1() == '': print('End..') return True f() ```
코딩도장

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

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

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