Rezultati

Up. imeNalogaJezikRezultatČas oddaje
jayzcrew-2018 Puzzle Python 3 0/100Napačen odgovor (WA) 19. apr '18 @ 19:30

Test Točke Porabljen spomin Porabljen čas Status
#1 0/10 8,320 MiB 0,000 s Napačen odgovor
#2 0/10 8,320 MiB 0,000 s Napačen odgovor
#3 0/10 8,418 MiB 0,000 s Napačen odgovor
#4 0/10 8,395 MiB 0,000 s Napačen odgovor
#5 0/10 8,352 MiB 0,000 s Napačen odgovor
#6 0/10 8,320 MiB 0,000 s Napačen odgovor
#7 0/10 8,316 MiB 0,000 s Napačen odgovor
#8 0/10 8,320 MiB 0,000 s Napačen odgovor
#9 0/10 8,320 MiB 0,000 s Napačen odgovor
#10 10/10 8,418 MiB 0,000 s OK

Ocenjevani program (puzzle.py):
import sys

puzzle = []
for _ in range(9):
    ad = input().strip()
    puzzle.append(ad)

def compat(a,b):
    return a != b and a.lower() == b.lower()

def rotat(x):
    all = []
    for i in range(4):
        all.append(x[i:]+ x[:i])

    return all

END = False
sol = []

def search(done, remain):
    global END
    global sol
    if len(done) == 9:
        sol = done
        END = True
    if END:
        return

    for p in remain:
        for rot in rotat(p):
            if len(done) == 1:
                if compat(rot[0], done[0][2]):
                    done.append(rot)
                    remain.remove(p)
                    search(done, remain)
                    remain.append(p)
                    done = done[:-1]
            if len(done) == 2:
                if compat(rot[0], done[1][2]):
                    done.append(rot)
                    remain.remove(p)
                    search(done, remain)
                    remain.append(p)
                    done = done[:-1]
            if len(done) == 3:
                if compat(rot[1], done[2][3]):
                    done.append(rot)
                    remain.remove(p)
                    search(done, remain)
                    remain.append(p)
                    done = done[:-1]
            if len(done) == 4:
                if compat(rot[1], done[1][3]) and compat(rot[2], done[3][0]):
                    done.append(rot)
                    remain.remove(p)
                    search(done, remain)
                    remain.append(p)
                    done = done[:-1]
            if len(done) == 5:
                if compat(rot[1], done[0][3]) and compat(rot[2], done[4][0]):
                    done.append(rot)
                    remain.remove(p)
                    search(done, remain)
                    remain.append(p)
                    done = done[:-1]
            if len(done) == 6:
                if compat(rot[1], done[5][3]):
                    done.append(rot)
                    remain.remove(p)
                    search(done, remain)
                    remain.append(p)
                    done = done[:-1]
            if len(done) == 7:
                if compat(rot[0], done[6][2]) and compat(rot[1], done[4][3]):
                    done.append(rot)
                    remain.remove(p)
                    search(done, remain)
                    remain.append(p)
                    done = done[:-1]
            if len(done) == 8:
                if compat(rot[0], done[7][2]) and compat(rot[1], done[3][3]):
                    done.append(rot)
                    remain.remove(p)
                    search(done, remain)
                    remain.append(p)
                    done = done[:-1]


for p in puzzle:
    for r in rotat(p):
        miss = puzzle[:]
        miss.remove(p)
        search([r], miss)
        if END:
            sol[3:6] = sol[3:6][::-1]

            print(' {0}  {1}  {2} '.format(sol[0][1], sol[1][1], sol[2][1]))
            print('{0} {1}{2} {3}{4} {5}'.format(sol[0][0], sol[0][2], sol[1][0], sol[1][2], sol[2][0], sol[2][2]))
            print(' {0}  {1}  {2} '.format(sol[0][3], sol[1][3], sol[2][3]))
            print(' {0}  {1}  {2} '.format(sol[3][1], sol[4][1], sol[5][1]))
            print('{0} {1}{2} {3}{4} {5}'.format(sol[3][0], sol[3][2], sol[4][0], sol[4][2], sol[5][0], sol[5][2]))
            print(' {0}  {1}  {2} '.format(sol[3][3], sol[4][3], sol[5][3]))
            print(' {0}  {1}  {2} '.format(sol[6][1], sol[7][1], sol[8][1]))
            print('{0} {1}{2} {3}{4} {5}'.format(sol[6][0], sol[6][2], sol[7][0], sol[7][2], sol[8][0], sol[8][2]))
            print(' {0}  {1}  {2} '.format(sol[6][3], sol[7][3], sol[8][3]))


            sys.exit(0)