Problem:


三目並べ

三目並べは，３ &times; ３のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです（図1〜図3 を参照）

図１：○の勝ち
図２：× の勝ち
図３：引き分け

三目並べは、○と×が交互にマス目を埋めていき、どちらかが一列揃ったときにゲーム終了となります。そのため、図 4 のように、○と×が両方とも一列そろっている場合はありえない局面です。ありえない局面が入力されることはありません。

図４：ありえない局面

三目並べの盤面を読み込んで、勝敗の結果を出力するプログラムを作成して下さい。

Input

入力は複数のデータセットからなります。各データセットとして、盤面を表す１つの文字列が１行に与えられます。
盤面の文字列は、○、×、空白をそれぞれ半角英小文字の o、x、s であらわし、下図のマス目の順に並んでいます。

データセットの数は 50 を超えません。

Output

データセットごとに、○が勝ちなら半角英小文字の o を、×が勝ちなら半角英小文字の x を、引き分けならば半角英小文字の d を１行に出力してください。

Sample Input

ooosxssxs
xoosxsosx
ooxxxooxo

Output for the Sample Input

o
x
d



Sample input:
ooosxssxs
xoosxsosx
ooxxxooxo


Sample output:
o
x
d

Submission status: Wrong Answer

Solution code:
import sys

for s in sys.stdin:
    if s[::4] == "ooo" : print "o"; continue
    if s[::4] == "xxx" : print "x"; continue
    if s[2:8:2] == "ooo" : print "o"; continue
    if s[2:8:2] == "xxx" : print "x"; continue
    for i in xrange(3):
        if s[i::3] == "ooo" : print "o"; break
        if s[i::3] == "xxx" : print "x"; break
        if s[3*i:3*i+3] == "ooo" : print "o"; break
        if s[3*i:3*i+3] == "xxx" : print "x"; break
    else: print "d"

Submission status: Wrong Answer

Solution code:
import sys

for s in sys.stdin:
    if s[::4] == "ooo" : print "o"; continue
    elif s[::4] == "xxx" : print "x"; continue
    elif s[2:8:2] == "ooo" : print "o"; continue
    elif s[2:8:2] == "xxx" : print "x"; continue
    else :
        for i in xrange(3):
            if s[i::3] == "ooo" : print "o"; break
            if s[i::3] == "xxx" : print "x"; break
            if s[3*i:3*i+3] == "ooo" : print "o"; break
            if s[3*i:3*i+3] == "xxx" : print "x"; break
        else: print "d"

Submission status: Wrong Answer

Solution code:
import sys

for s in sys.stdin:
    if s[::4] == "ooo" : print "o"; continue
    elif s[::4] == "xxx" : print "x"; continue
    elif s[2:8:2] == "ooo" : print "o"; continue
    elif s[2:8:2] == "xxx" : print "x"; continue
    else :
        for i in xrange(3):
            if s[i::3] == "ooo" : print "o"; break
            elif s[i::3] == "xxx" : print "x"; break
            elif s[3*i:3*i+3] == "ooo" : print "o"; break
            elif s[3*i:3*i+3] == "xxx" : print "x"; break
        else: print "d"

Submission status: Wrong Answer

Solution code:
import sys

for s in sys.stdin:
    if s[::4] == "ooo" : print "o"
    elif s[::4] == "xxx" : print "x"
    elif s[2:8:2] == "ooo" : print "o"
    elif s[2:8:2] == "xxx" : print "x"
    else :
        for i in xrange(3):
            if s[i::3] == "ooo" : print "o"; break
            elif s[i::3] == "xxx" : print "x"; break
            elif s[3*i:3*i+3] == "ooo" : print "o"; break
            elif s[3*i:3*i+3] == "xxx" : print "x"; break
            else:
                if i == 2: print "d"

Submission status: Wrong Answer

Solution code:
import sys

for s in sys.stdin:
    if s[::4] == "ooo" : print "o"; continue
    if s[::4] == "xxx" : print "x"; continue
    if s[2:8:2] == "ooo" : print "o"; continue
    if s[2:8:2] == "xxx" : print "x"; continue
    if s[0::3] == "ooo" : print "o"; continue
    if s[0::3] == "xxx" : print "x"; continue
    if s[0:3] == "ooo" : print "o"; continue
    if s[0:3] == "xxx" : print "x"; continue
    if s[3:6] == "ooo" : print "o"; continue
    if s[3:6] == "xxx" : print "x"; continue
    if s[6:9] == "ooo" : print "o"; continue
    if s[6:9] == "xxx" : print "x"; continue
    if s[0::3] == "ooo" : print "o"; continue
    if s[0::3] == "xxx" : print "x"; continue
    if s[1::3] == "ooo" : print "o"; continue
    if s[1::3] == "xxx" : print "x"; continue
    if s[2::3] == "ooo" : print "o"; continue
    if s[2::3] == "xxx" : print "x"; continue
    print "d"

Submission status: Wrong Answer

Solution code:
def aaa(O, X):
    if O == 3:
        print 'o'
        return True
    elif O == 3:
        print 'x'
        return True

while True:
    try:
        line = raw_input()
        ttt = []
        while line:
            lis = []
            for i in range(3):
                lis.append(line[i])
            else:
                ttt.append(lis)
            line = line[3:]
            
        flag = False
        for y in range(3):
            O = 0
            X = 0
            for x in range(3):
                if ttt[y][x] == 'o':
                    O += 1
                elif ttt[y][x] == 'x':
                    X += 1
            else:
                if aaa(O, X): flag = True
            if flag == True: break
        if flag == True: continue
        
        for x in range(3):
            O = 0
            X = 0
            for y in range(3):
                if ttt[y][x] == 'o':
                    O += 1
                elif ttt[y][x] == 'x':
                    X += 1
            else:
                if aaa(O, X): flag = True
            if flag == True: break
        if flag == True: continue
                
        for i in range(3):
            O = 0
            X = 0
            if ttt[i][i] == 'o':
                O += 1
            elif ttt[i][i] == 'x':
                X += 1
        if aaa(O, X): continue
            
        for i in range(3):
            O = 0
            X = 0
            if ttt[i][2-i] == 'o':
                O += 1
            elif ttt[i][2-i] == 'x':
                X += 1
        if aaa(O, X):
            continue
        else:
            print 'd'
    except EOFError:
        break

Submission status: Wrong Answer

Solution code:
import sys
for line in sys.stdin.readlines():
  l = [s for s in line.replace('\n','')]
  answer = 'd'
  for i in range(3):
    if l[i] == l[i+3] == l[i+6]:
      if l[i] == 'o':
        answer = 'o'
      else:
        answer = 'x'
  for i in range(0,8,3):
    if l[i] == l[i+1] == l[i+2]:
      if l[i] == 'o':
        answer = 'o'
      else:
        answer = 'x'
  if l[0] == l[4] == l[8] or l[2] == l[4] == l[6]:
    if l[4] == 'o':
      answer = 'o'
    else:
      answer = 'x'
  print(answer)

Submission status: Wrong Answer

Solution code:
def sol(a):
    if len(set(a))==1:
        return a.pop()
    else:
        return ''
while 1:
    try:
        n=raw_input()
        f=1 
        for i in range(0,7,3):
            if sol(list(n[i:i+3])):
                print sol(list(n[i:i+3]))
                f=0
        for i in range(3):
            if sol(list(n[i]+n[i+3]+n[i+6])):
                print sol(list(n[i]+n[i+3]+n[i+6]))
                f=0
        if f and (sol(list(n[0]+n[4]+n[8])) or sol(list(n[2]+n[4]+n[6]))):
            print sol(list(n[0]+n[4]+n[8]))+sol(list(n[2]+n[4]+n[6]))
            f=0
        if f:
            print 'd'

    except:
        break

Submission status: Wrong Answer

Solution code:
while True:
    try:
        Res = list(map(str,input()))

        for i in range(0,7,3):
            if Res[i] == Res[i + 1] == Res[i + 2]:
                print(Res[i])
                break
        for j in range(3):
            if Res[j] == Res[j + 3] == Res[j + 6]:
                print(Res[i])
                break
        if Res[0] == Res[4] == Res[8]:
            print(Res[0])
        elif Res[2] == Res[4] == Res[6]:
            print(Res[2])
        else:
            print("d")
    except EOFError:
        break

Submission status: Wrong Answer

Solution code:
while True:
    try:
        count = 0
        Res = list(map(str,input()))

        for i in range(0,7,3):
            if Res[i] == Res[i + 1] == Res[i + 2]:
                print(Res[i])
                count = 1
                break
        for j in range(3):
            if Res[j] == Res[j + 3] == Res[j + 6]:
                print(Res[i])
                count = 1
                break
        if count == 0:
            if Res[0] == Res[4] == Res[8]:
                print(Res[0])
            elif Res[2] == Res[4] == Res[6]:
                print(Res[2])
            else:
                print("d")
    except :
        break

Submission status: Wrong Answer

Solution code:
while True:
    try:
        count = 0
        Res = list(map(str,input()))

        for i in range(0,7,3):
            if Res[i] == Res[i + 1] == Res[i + 2]:
                print(Res[i])
                count = 1
                break
        for j in range(3):
            if Res[j] == Res[j + 3] == Res[j + 6]:
                print(Res[i])
                count = 1
                break
        if count == 0:
            if Res[0] == Res[4] == Res[8]:
                print(Res[0])
            elif Res[2] == Res[4] == Res[6]:
                print(Res[2])
            else:
                print("d")
    except EOFError:
        break

Submission status: Wrong Answer

Solution code:
while True:
    try:
        count = 0
        Res = list(map(str,input()))

        for i in range(0,7,3):
            if Res[i] == Res[i + 1] == Res[i + 2]:
                if Res[i] != "s":
                    print(Res[i])
                    count = 1
                    break
        for j in range(3):
            if Res[j] == Res[j + 3] == Res[j + 6]:
                if Res[i] != "s":
                    print(Res[i])
                    count = 1
                    break
        if count == 0:
            if Res[4] != "s":
                if Res[0] == Res[4] == Res[8]:
                    print(Res[0])
                elif Res[2] == Res[4] == Res[6]:
                    print(Res[2])
                else:
                    print("d")
            else:
                print("d")
    except EOFError:
        break

Submission status: Wrong Answer

Solution code:
c = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]

while True:
    try:
        S = input()
    except EOFError:
        break
    for i in c:
        o = True
        x = True
        for j in i:
            if S [j] == 'o':
                x = False
            else:
                o = False
        if o:
            print('o')
            break
        elif x:
            print('x')
            break
    else:
        print('d')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0066
"""
import sys


def prepare_board(size=3):
    return [[1]*size for _ in range(size)]


def check_horizontal(status):
    dp = prepare_board()
    for y in range(len(status)):
        for x in range(1, len(status[0])):
            if status[y][x] == status[y][x-1]:
                dp[y][x] = dp[y][x-1] + 1
                if dp[y][x] == 3:
                    return status[y][x]
    return 'd'


def check_vertical(status):
    dp = prepare_board()
    for y in range(1, len(status)):
        for x in range(len(status[0])):
            if status[y][x] == status[y-1][x]:
                dp[y][x] = dp[y-1][x] + 1
                if dp[y][x] == 3:
                    return status[y][x]
    return 'd'


def check_diagonal(status):
    # ????????????????????????????§??????????????????§??????
    dp = prepare_board()
    for y in range(1, len(status)):
        for x in range(1, len(status[0])):
            if status[y][x] == status[y-1][x-1]:
                dp[y][x] = dp[y-1][x-1] + 1
                if dp[y][x] == 3:
                    return status[y][x]

    # ????????????????????????????§??????????????????§??????
    dp = prepare_board()
    for y in range(1, len(status)):
        for x in range(len(status[0])-2, -1, -1):
            if status[y][x] == status[y-1][x+1]:
                dp[y][x] = dp[y-1][x+1] + 1
                if dp[y][x] == 3:
                    return status[y][x]
    return 'd'


def solve(status):
    result = check_horizontal(status)
    if result != 'd':
        return result
    result = check_vertical(status)
    if result != 'd':
        return result
    return check_diagonal(status)


def main(args):
    for line in sys.stdin:
        # ??\???????????????3x3?????¶????????????????????????????§£?????¢??°?????????
        status = []
        line = line.strip()
        status.append(list(line[:3]))
        status.append(list(line[3:6]))
        status.append(list(line[6:]))
        result = solve(status)

        # ?????????????¨?
        print(result)

if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

Solution code:
board = input()
board_list = [(a + b + c) for (a, b, c) in zip(board[::3], board[1::3],
              board[2::3])]


def check(num):
    if board_list[num][0] == board_list[num][1] == board_list[num][2]:
        if board_list[num][0] == 'o':
            return 'o'
        elif board_list[num][0] == 'x':
            return 'x'
    if board_list[0][num] == board_list[1][num] == board_list[2][num]:
        if board_list[0][num] == 'o':
            return 'o'
        elif board_list[0][num] == 'x':
            return 'x'
    if board_list[0][0] == board_list[1][1] == board_list[2][2]:
        if board_list[0][0] == 'o':
            return 'o'
        elif board_list[0][0] == 'x':
            return 'x'
    if board_list[0][2] == board_list[1][1] == board_list[2][0]:
        if board_list[0][0] == 'o':
            return 'o'
        elif board_list[0][0] == 'x':
            return 'x'
    return 'd'


for i in range(3):
    result = check(i)
    if result != "d":
        break
print(result)

Submission status: Wrong Answer

Solution code:


def check(num):
    if board_list[num][0] == board_list[num][1] == board_list[num][2]:
        if board_list[num][0] == 'o':
            return 'o'
        elif board_list[num][0] == 'x':
            return 'x'
    if board_list[0][num] == board_list[1][num] == board_list[2][num]:
        if board_list[0][num] == 'o':
            return 'o'
        elif board_list[0][num] == 'x':
            return 'x'
    if board_list[0][0] == board_list[1][1] == board_list[2][2]:
        if board_list[0][0] == 'o':
            return 'o'
        elif board_list[0][0] == 'x':
            return 'x'
    if board_list[0][2] == board_list[1][1] == board_list[2][0]:
        if board_list[0][0] == 'o':
            return 'o'
        elif board_list[0][0] == 'x':
            return 'x'
    return 'd'

if __name__ == '__main__':

    board = input()
    board_list = [(a + b + c) for (a, b, c) in zip(board[::3], board[1::3],
                  board[2::3])]


    for i in range(3):
        result = check(i)
        if result != "d":
            break
    print(result)

Submission status: Wrong Answer

Solution code:
import sys
board = []
for line in sys.stdin:
    line = line.rstrip('\r\n')
    board.append(str(line))
board_list = []


def make_list(num):
    for i in range(num):
        for (a, b, c) in zip(board[i][::3], board[i][1::3], board[i][2::3]):
            board_list.append(a + b + c)


def check(num):
    if board_list[num][0] == board_list[num][1] == board_list[num][2]:
        if board_list[num][0] == 'o':
            return 'o'
        elif board_list[num][0] == 'x':
            return 'x'
    if board_list[0][num] == board_list[1][num] == board_list[2][num]:
        if board_list[0][num] == 'o':
            return 'o'
        elif board_list[0][num] == 'x':
            return 'x'
    if board_list[0][0] == board_list[1][1] == board_list[2][2]:
        if board_list[0][0] == 'o':
            return 'o'
        elif board_list[0][0] == 'x':
            return 'x'
    if board_list[0][2] == board_list[1][1] == board_list[2][0]:
        if board_list[0][0] == 'o':
            return 'o'
        elif board_list[0][0] == 'x':
            return 'x'
    return 'd'


make_list(3)
for j in range(3):
    for i in range(3):
        result = check(i)
        if result != "d":
            print(result)
            del board_list[0:3]
            break
    if result == "d":
        print(result)
        del board_list[0:3]

Submission status: Wrong Answer

Solution code:
import sys
board = []
for line in sys.stdin:
    line = line.rstrip('\n')
    board.append(str(line))
    if len(board) == 3:
        break
board_list = []


def make_list(num):
    for i in range(num):
        for (a, b, c) in zip(board[i][::3], board[i][1::3], board[i][2::3]):
            board_list.append(a + b + c)


def check(num):
    if board_list[num][0] == board_list[num][1] == board_list[num][2]:
        if board_list[num][0] == 'o':
            return 'o'
        elif board_list[num][0] == 'x':
            return 'x'
    if board_list[0][num] == board_list[1][num] == board_list[2][num]:
        if board_list[0][num] == 'o':
            return 'o'
        elif board_list[0][num] == 'x':
            return 'x'
    if board_list[0][0] == board_list[1][1] == board_list[2][2]:
        if board_list[0][0] == 'o':
            return 'o'
        elif board_list[0][0] == 'x':
            return 'x'
    if board_list[0][2] == board_list[1][1] == board_list[2][0]:
        if board_list[0][0] == 'o':
            return 'o'
        elif board_list[0][0] == 'x':
            return 'x'
    return 'd'


make_list(3)
for j in range(3):
    for i in range(3):
        result = check(i)
        if result != "d":
            print(result)
            del board_list[0:3]
            break
    if result == "d":
        print(result)
        del board_list[0:3]

Submission status: Wrong Answer

Solution code:
while True:
    try:
        s = input()
        if (s[0] == s[4] and s[0] == s[8]) or (s[2] == s[4] and s[2] == s[6]):
            print(s[4])
            continue
        for i in range(3):
            if s[i] == s[i + 3] and s[i] == s[i + 6]:
                print(s[i])
                break
            elif s[3*i] == s[3*i + 1] and s[3*i] == s[3*i + 2]:
                print(s[3*i])
                break
        else:
            print("d")
    except:
        break

Submission status: Wrong Answer

Solution code:
while True:
    try:
        s = input()
        if s[4] != "s":
            if (s[0] == s[4] and s[0] == s[8]) or (s[2] == s[4] and s[2] == s[6]):
                print(s[4])
                continue
        for i in range(3):
            if s[i] != "s" and s[i] == s[i + 3] and s[i] == s[i + 6]:
                print(s[i])
                break
            elif s[i] != "s" and s[3*i] == s[3*i + 1] and s[3*i] == s[3*i + 2]:
                print(s[3*i])
                break
        else:
            print("d")
    except:
        break

Submission status: Wrong Answer

Solution code:
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

table = [[0 for i in range(3)] for j in range(3)]

N = list(get_input())
for l in range(len(N)):
    S = N[l]
    ans = "d"

    for i in range(9):
        if S[i] == "o":
            table[i // 3][i % 3] = 1
        elif S[i] == "x":
            table[i // 3][i % 3] = -1

    for i in range(3):
        s = 0
        for j in range(3):
            s += table[i][j]
        if s == 3:
            ans = "o"
        elif s == -3:
            ans = "x"

    for i in range(3):
        s = 0
        for j in range(3):
            s += table[j][i]
        if s == 3:
            ans = "o"
        elif s == -3:
            ans = "x"

    s = table[0][0] + table[1][1] + table[2][2]
    if s == 3:
        ans = "o"
    elif s == -3:
        ans = "x"

    s = table[0][2] + table[1][1] + table[2][0]
    if s == 3:
        ans = "o"
    elif s == -3:
        ans = "x"

    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
board = []
board_list = []
result = []
for line in sys.stdin:
    line = line.rstrip('\n')
    board.append(line)
l_num = len(board)
print(board)


def check(num):
    if board_list[num][0] == board_list[num][1] == board_list[num][2]:
        if board_list[num][0] == 'o':
            return 'o'
        elif board_list[num][0] == 'x':
            return 'x'
    if board_list[0][num] == board_list[1][num] == board_list[2][num]:
        if board_list[0][num] == 'o':
            return 'o'
        elif board_list[0][num] == 'x':
            return 'x'
    if board_list[0][0] == board_list[1][1] == board_list[2][2]:
        if board_list[0][0] == 'o':
            return 'o'
        elif board_list[0][0] == 'x':
            return 'x'
    if board_list[0][2] == board_list[1][1] == board_list[2][0]:
        if board_list[0][0] == 'o':
            return 'o'
        elif board_list[0][0] == 'x':
            return 'x'
    return'd'


for i in board:
    board_list = [(a + b + c) for (a, b, c) in zip(i[::3], i[1::3], i[2::3])]
    print(board_list)
    for j in range(3):
        if check(j) != "d":
            result.append(check(j))
            break
        elif j == 2:
            result.append(check(j))

for i in result:
    print(i)

Submission status: Wrong Answer

Solution code:
import sys
board = []
board_list = []
result = []
for line in sys.stdin:
    line = line.rstrip('\n')
    board.append(line)
l_num = len(board)
print(board)


def check(num):
    if board_list[num][0] == board_list[num][1] == board_list[num][2]:
        if board_list[num][0] == 'o':
            return 'o'
        elif board_list[num][0] == 'x':
            return 'x'
    if board_list[0][num] == board_list[1][num] == board_list[2][num]:
        if board_list[0][num] == 'o':
            return 'o'
        elif board_list[0][num] == 'x':
            return 'x'
    if board_list[0][0] == board_list[1][1] == board_list[2][2]:
        if board_list[0][0] == 'o':
            return 'o'
        elif board_list[0][0] == 'x':
            return 'x'
    if board_list[0][2] == board_list[1][1] == board_list[2][0]:
        if board_list[0][0] == 'o':
            return 'o'
        elif board_list[0][0] == 'x':
            return 'x'
    return'd'


for i in board:
    board_list = [(a + b + c) for (a, b, c) in zip(i[::3], i[1::3], i[2::3])]
    print(board_list)
    for j in range(3):
        if check(j) != "d":
            print(check(j))
            break
        elif j == 2:
            print(check(j))

Submission status: Wrong Answer

Solution code:
import sys
board = []
board_list = []
result = []
for line in sys.stdin:
    line = line.rstrip('\n')
    board.append(line)
l_num = len(board)

def check(num):
    if board_list[num][0] == board_list[num][1] == board_list[num][2]:
        if board_list[num][0] == 'o':
            return 'o'
        elif board_list[num][0] == 'x':
            return 'x'
    if board_list[0][num] == board_list[1][num] == board_list[2][num]:
        if board_list[0][num] == 'o':
            return 'o'
        elif board_list[0][num] == 'x':
            return 'x'
    if board_list[0][0] == board_list[1][1] == board_list[2][2]:
        if board_list[0][0] == 'o':
            return 'o'
        elif board_list[0][0] == 'x':
            return 'x'
    if board_list[0][2] == board_list[1][1] == board_list[2][0]:
        if board_list[0][0] == 'o':
            return 'o'
        elif board_list[0][0] == 'x':
            return 'x'
    return'd'


for i in board:
    board_list = [(a + b + c) for (a, b, c) in zip(i[::3], i[1::3], i[2::3])]
    for j in range(3):
        if check(j) != "d":
            print(check(j))
            break
        elif j == 2:
            print(check(j))

Submission status: Wrong Answer

Solution code:
import sys
board = []
board_list = []
result = []
for line in sys.stdin:
    line = line.rstrip('\n')
    board.append(line)


def check(num):
    if board_list[num][0] == board_list[num][1] == board_list[num][2]:
        if board_list[num][0] == 'o':
            return 'o'
        elif board_list[num][0] == 'x':
            return 'x'
    if board_list[0][num] == board_list[1][num] == board_list[2][num]:
        if board_list[0][num] == 'o':
            return 'o'
        elif board_list[0][num] == 'x':
            return 'x'
    if board_list[0][0] == board_list[1][1] == board_list[2][2]:
        if board_list[0][0] == 'o':
            return 'o'
        elif board_list[0][0] == 'x':
            return 'x'
    if board_list[0][2] == board_list[1][1] == board_list[2][0]:
        if board_list[0][0] == 'o':
            return 'o'
        elif board_list[0][0] == 'x':
            return 'x'
    return'd'


for i in board:
    board_list = [(a + b + c) for (a, b, c) in zip(i[::3], i[1::3], i[2::3])]
    for j in range(3):
        if check(j) != "d":
            result.append(check(j))
            break
        elif j == 2:
            result.append(check(j))

for i in result:
    print(i)

Submission status: Wrong Answer

Solution code:
def check(s):
  for i in (0, 3, 6): #横
    if s[i] == s[i + 1] and s[i + 1] == s[i + 2]:
      print(s[i])
      return

  for i in (0, 1, 2): #縦
    if s[i] == s[i + 3] and s[i + 3] == s[i + 6]:
      print(s[i])
      return

  if s[0] == s[4] and s[4] == s[8]: #斜め1
      print(s[0])
      return

  if s[2] == s[4] and s[4] == s[6]: #斜め2
      print(s[0])
      return

  print("d")  #それ以外なら引き分け

while True:
  try:
    check(input())

  except EOFError:
    break

Submission status: Wrong Answer

Solution code:
def check(s):
  for i in (0, 3, 6): #横
    if s[i] == s[i + 1] and s[i + 1] == s[i + 2]:
      print(s[i])
      return

  for i in (0, 1, 2): #縦
    if s[i] == s[i + 3] and s[i + 3] == s[i + 6]:
      print(s[i])
      return

  if s[0] == s[4] and s[4] == s[8]: #斜め1
      print(s[0])
      return

  if s[2] == s[4] and s[4] == s[6]: #斜め2
      print(s[2])
      return

  print("d")  #それ以外なら引き分け

while True:
  try:
    check(input())

  except EOFError:
    break

Submission status: Wrong Answer

Solution code:
import sys
def ttt(o):
    if o[0]==o[4]==o[8] or o[2]==o[4]==o[6]:
        return o[4]
    for i in range(3):
        if o[i*3]==o[i*3+1]==o[i*3+2]:
            return o[i*3]
        if o[i]==o[i+3]==o[i+6]:
            return o[i]
    return "d"
[print(ttt(j)) for j in [i for i in sys.stdin]]

Submission status: Wrong Answer

Solution code:
import sys
for line in sys.stdin.readlines():
    result="d"
    for i in xrange(3):
        if not line[3*i]=="s" and line[3*i]==line[3*i+1] and line[3*i]==line[3*i+2]:
            result=line[3*i]
        if not line[i]=="s" and line[i]==line[i+3] and line[i]==line[i+6]:
            result=line[i]
    if not line[0]=="s" and line[0]==line[4] and line[0]==line[8]:
        result=line[0]
    if not line[2]=="s" and line[0]==line[4] and line[0]==line[6]:
        result=line[2]
    print result

Submission status: Wrong Answer

Solution code:
def get_winner(s):
	for p in ['o','x']:
		for i in xrange(3):
			win_h=True
			win_v=True
			for j in xrange(3):
				if s[i*3+j]!=p:
					win_h=False
				if s[j*3+i]!=p:
					win_v=False
			if win_h or win_v:
				return p
		if p==s[0]==s[4]==s[8] or p==s[2]==s[4]==s[5]:
			return p
	return 'd'

while 1:
	try:
		s=raw_input()
		print get_winner(s)
	except  EOFError:
		break

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

condition = ('ooo', 'xxx')
for line in stdin:
    if line[:3] in condition:
        win = line[0]
    elif line[3:6] in condition:
        win = line[3]
    elif line[6:] in condition:
        win = line[6]
    elif line[0::3] in condition:
        win = line[0]
    elif line[1::3] in condition:
        win = line[1]
    elif line[2::3] in condition:
        win = line[2]
    elif line[0::4] in condition:
        win = line[0]
    elif line[2:7:2] in condition:
        win = line[2]
    else:
        win = 'd'
    print(win)

Submission status: Wrong Answer

Solution code:
import sys
ans = ['xxx      ','   xxx   ','x  x  x  ',' x  x  x ','  x  x  x','x   x   x','  x x x  ']
for s in sys.stdin:
	s = s.strip()
	o = ''.join(['x' if c == 'o' else ' ' for c in s])
	x = ''.join(['x' if c == 'x' else ' ' for c in s])
	if o in ans:
		print 'o'
	elif x in ans:
		print 'x'
	else:
		print 'd'

Submission status: Wrong Answer

Solution code:
import sys
ans = ['xxx      ','   xxx   ','      xxx','x  x  x  ',' x  x  x ','  x  x  x','x   x   x','  x x x  ']
for s in sys.stdin:
	s = s.strip()
	o = ''.join(['x' if c == 'o' else ' ' for c in s])
	x = ''.join(['x' if c == 'x' else ' ' for c in s])
	if o in ans:
		print 'o'
	elif x in ans:
		print 'x'
	else:
		print 'd'

Submission status: Wrong Answer

Solution code:
import sys
for s in sys.stdin:
    c="d"
    for i in range(3):
        j=i*3
        if (s[i]==s[i+3]==s[i+6])or(s[j]==s[j+1]==s[j+2]):
            c=s[i]
            break
    else:
        if s[0]==s[4]==s[8] or s[2]==s[4]==s[6]: c=s[4]
    print c

Submission status: Wrong Answer

Solution code:
import sys
x=["ooo","xxx"]
for s in sys.stdin:
    c="d"
    for i in range(3):
        j=i*3
        if s[i::3]in x:
            c=s[i]
            break
        if s[j:j+3]in x:
            c=s[j]
            break
    else:
        if s[0::4] in x or s[2:7:2] in x: c=s[4]
    print c

Submission status: Wrong Answer

Solution code:
while True:
    try:
        a = raw_input()
        if a[::4] == "ooo" or a[::-4] == "ooo":
            print "o"
        elif a[::4] == "xxx" or a[::-4] == "xxx":
            print "x"
        else:
            for i in range(3):
                if a[i:3*(i+1)] == "ooo" or a[i::3] == "ooo":
                    print "o"
                    break
                elif a[i:3*(i+1)] == "xxx" or a[i::3] == "xxx":
                    print "x"
                    break
                elif i == 2:
                    print "d"
    except:
        break

Submission status: Wrong Answer

Solution code:
while True:
    try:
        a = raw_input()
        print a[2:8:2]
        if a[::4] == "ooo" or a[2:8:2] == "ooo":
            print "o"
        elif a[::4] == "xxx" or a[2:8:2] == "xxx":
            print "x"
        else:
            for i in range(3):
                if a[i:3*(i+1)] == "ooo" or a[i::3] == "ooo":
                    print "o"
                    break
                elif a[i:3*(i+1)] == "xxx" or a[i::3] == "xxx":
                    print "x"
                    break
                elif i == 2:
                    print "d"
    except:
        break

Submission status: Wrong Answer

Solution code:
while True:
    try:
        a = raw_input()
        print a[2:8:2]
        if a[::4] == "ooo" or a[2:8:2] == "ooo":
            print "o"
        elif a[::4] == "xxx" or a[2:8:2] == "xxx":
            print "x"
        else:
            for i in range(3):
                if a[3*i:3*(i+1)] == "ooo" or a[i::3] == "ooo":
                    print "o"
                    break
                elif a[3*i:3*(i+1)] == "xxx" or a[i::3] == "xxx":
                    print "x"
                    break
                elif i == 2:
                    print "d"
    except:
        break

Submission status: Wrong Answer

Solution code:
ls = ["o","x"]
while True:
    try:
        a = raw_input()
        for c in ls:
            if a[::4] == c*3 or a[2:8:2] == c*3:
                print c
            else:
                for i in range(3):
                    if a[3*i:3*(i+1)] == c*3 or a[i::3] == c*3:
                        print c
                        break
                    elif i == 2:
                        print "d"
    except:
        break

Submission status: Wrong Answer

Solution code:
ls = ["o","x"]
while True:
    try:
        a = raw_input()
        for c in ls:
            if a[::4] == c*3 or a[2:8:2] == c*3:
                print c
                break
            else:
                for i in range(3):
                    if a[3*i:3*(i+1)] == c*3 or a[i::3] == c*3:
                        print c
                        break
                    elif i == 2:
                        print "d"
    except:
        break