CSES - Datatähti 2018 loppu - Results
Submission details
Task:Merkkijono
Sender:Kurns
Submission time:2018-01-18 13:12:51 +0200
Language:Python2
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.00 sdetails
#20.00 sdetails
#30.00 sdetails
#40.00 sdetails
#50.00 sdetails

Code

# -*- coding: utf-8 -*-
"""
Created on Thu Jan 18 12:48:56 2018

@author: guest407
"""

UI = raw_input()
lista = []
operaatiot = []
siirrot = 0

for x in range(0, len(UI)):
    lista.append(UI[x])
    
print(lista)

def arvo(x):
    if x == "a":
        return 0
    if x == "b":
        return 1
    if x == "c":
        return 2
    if x == "d":
        return 3
    if x == "e":
        return 4
    if x == "f":
        return 5
    if x == "g":
        return 6
    if x == "h":
        return 7
    if x == "i":
        return 8
    if x == "j":
        return 9
    if x == "k":
        return 10
    if x == "l":
        return 11
    if x == "m":
        return 12
    if x == "n":
        return 13
    if x == "o":
        return 14
    if x == "p":
        return 15
    if x == "q":
        return 16
    if x == "r":
        return 17
    if x == "s":
        return 18
    if x == "t":
        return 19
    if x == "u":
        return 20
    if x == "v":
        return 21
    if x == "w":
        return 22
    if x == "x":
        return 23
    if x == "y":
        return 24
    if x == "z":
        return 25
        
def swap(i1, i2):
    ai1 = str(lista[int(i1)])
    ai2 = str(lista[int(i2)])
    lista[i2] = ai1
    lista[i1] = ai2
    operaatiot.append("SWAP")
    
def vikaekaksi():
    vika = str(lista[-1])
    lista.insert(0,vika)
    del[lista[-1]]
    operaatiot.append("MOVE")

  
while lista[0] != "a" and lista[-1] != "z":
    if arvo(lista[0]) > arvo(lista[1]):
        swap(0,1)
        siirrot += 1
    elif arvo(lista[-1]) < arvo(lista[0]):
        vikaekaksi()
    print(lista)
        
print siirrot

for x in range(0, len(operaatiot())):
    print(operaatiot[x])

Test details

Test 1

Verdict:

input
ABCDEFGHIJKLMNOPQRSTUVWXYZ

correct output
0

user output
(empty)

Test 2

Verdict:

input
ZYXWVUTSRQPONMLKJIHGFEDCBA

correct output
923
MOVE
MOVE
SWAP
MOVE
...

user output
(empty)

Test 3

Verdict:

input
RPJMFWBHYQOTXUAENLDGZISCVK

correct output
611
SWAP
MOVE
MOVE
SWAP
...

user output
(empty)

Test 4

Verdict:

input
GWJSPBHANMXYFLKIDORVUCEZQT

correct output
659
MOVE
SWAP
MOVE
SWAP
...

user output
(empty)

Test 5

Verdict:

input
BJYNFLKEIUCZMQHRAXOGWPSDTV

correct output
624
MOVE
SWAP
MOVE
SWAP
...

user output
(empty)