CSES - Datatähti 2018 alku - Results
Submission details
Task:Merkkijono
Sender:eetu02
Submission time:2017-10-12 15:17:48 +0300
Language:Python3
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.06 sdetails
#2ACCEPTED0.06 sdetails
#3ACCEPTED0.09 sdetails
#4ACCEPTED0.06 sdetails
#5ACCEPTED0.10 sdetails
#6ACCEPTED0.07 sdetails
#7ACCEPTED0.06 sdetails
#8ACCEPTED0.08 sdetails
#9ACCEPTED0.07 sdetails
#10ACCEPTED0.07 sdetails

Code

# -*- coding: utf-8 -*-
"""
Created on Thu Oct  5 15:23:24 2017

@author: eetu.pakkanen
"""

#  DATATÄHTI ALKU 2018 --- MERKKIJONO



def etsi_alku(merkkijono):
    
    for indeksi in range(len(merkkijono)-1):
        if merkkijono[indeksi] == merkkijono[indeksi + 1]:
            return indeksi
    return -1

def etsi_loppu(merkkijono, loppu):
    
    for indeksi in range(loppu, len(merkkijono)-1):
        if merkkijono[indeksi] == merkkijono[indeksi+1]:
            loppu = loppu+1
        else:
            break
    return loppu+ 1


def delete(merkkijono):
    while len(merkkijono) > 0:
        alku = etsi_alku(merkkijono)
        if alku < 0:
            break
        loppu = etsi_loppu(merkkijono, alku)   
        merkkijono = merkkijono[:alku] + merkkijono[loppu:]
    return merkkijono


if __name__ == "__main__":
    
    print(delete(input()))

Test details

Test 1

Verdict: ACCEPTED

input
ABABABABABABABABABABABABABABAB...

correct output
ABABABABABABABABABABABABABABAB...

user output
ABABABABABABABABABABABABABABAB...

Test 2

Verdict: ACCEPTED

input
AABBAABBAABBAABBAABBAABBAABBAA...

correct output
(empty)

user output
(empty)

Test 3

Verdict: ACCEPTED

input
ABABABABABABABABABABABABABABAB...

correct output
(empty)

user output
(empty)

Test 4

Verdict: ACCEPTED

input
BBABABBBBBAABBBABABABBBBAAABAB...

correct output
BAB

user output
BAB

Test 5

Verdict: ACCEPTED

input
ACDCBBACDBBBACAACBBDBADBAABABA...

correct output
ACDCACDADBADABACACDCADADABABCA...

user output
ACDCACDADBADABACACDCADADABABCA...

Test 6

Verdict: ACCEPTED

input
EETFHIJOGACDHMGVFJCMETMZDEITTR...

correct output
TFHIJOGACDHMGVFJCMETMZDEIROTET...

user output
TFHIJOGACDHMGVFJCMETMZDEIROTET...

Test 7

Verdict: ACCEPTED

input
GOONLAHLYPRFCZKIKSJWAWWYJJPCDB...

correct output
GNLAHLYPRFCZKIKSJWAYPCDNWYMRCE...

user output
GNLAHLYPRFCZKIKSJWAYPCDNWYMRCE...

Test 8

Verdict: ACCEPTED

input
PISHWMOTCDDZFRMYMOMYDYYGJZIQHS...

correct output
PISHWMOTCZFRMYMOMYDGJZIQHSVAOK...

user output
PISHWMOTCZFRMYMOMYDGJZIQHSVAOK...

Test 9

Verdict: ACCEPTED

input
QUVVTPXAMWWODFXRONJODPGBTCISGM...

correct output
QUTPXAMODFXRONJODPGBTCISGMVRBW...

user output
QUTPXAMODFXRONJODPGBTCISGMVRBW...

Test 10

Verdict: ACCEPTED

input
POXHAHYEZTLYNFSLABODMRNKDSKROZ...

correct output
POXHAHYEZTLYNFSLABODMRNKDSKROZ...

user output
POXHAHYEZTLYNFSLABODMRNKDSKROZ...