mikkelbjoernmikkelbjoern -4 years ago
1006 0
Python

terning.py

#Mikkel Goldschmidt, Nørre Gymnasium
#Opgave 1: Terning


#Opsætter array indeholdende arrays med der beskriver terninger: [A,B,C,D,E,F]
N = int(input())
terninger = []

for i in range(N):
    terning = input()
    terning = terning.split()
    for sideN in range(6):
        terning[sideN] = int(terning[sideN])
    terninger.append(terning)

for case in range(6):
    score = 0
    def terningPoint(d, i): #d er et array der beskriver ternigen, i beskriver det tal som skal vende nedad
        global score
        sideNr = d.index(i)

        if sideNr in [0,5]:
            score += max(d[1],d[2],d[3],d[4])

        elif sideNr in [1,3]:
            score += max(d[0],d[2],d[4],d[5])

        elif sideNr in [2,4]:
            score += max(d[0],d[1],d[3],d[5])

        #Retunerer modstående side
        if sideNr == 0:
            return d[5]

        elif sideNr == 1:
            return d[3]

        elif sideNr == 2:
            return d[4]

        elif sideNr == 3:
            return d[1]

        elif sideNr == 4:
            return d[2]

        elif sideNr == 5:
            return d[0]

    upside = case + 1
    for i in range(N):
        upside = terningPoint(terninger[i],upside)

    print(score)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download