CSES - Datatähti 2023 alku - Results
Submission details
Task:Lista
Sender:Ihminen
Submission time:2022-11-13 21:40:59 +0200
Language:PyPy3
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttimescore
#10.00 s0details

Code

import math
import time
import msvcrt

listaSummat = [58667, 68283, 64141, 69169, 67564, 63729, 57461, 50514, 49078, 41270, 33328, 33181, 22058, 16443, 19680, 28220, 46548, 54913, 59232, 53046, 33801, 21281, 18002, 16852, 14723, 25344, 41021, 42314, 32321, 24947, 40411, 64014, 68201, 65541, 70605, 61078, 34269, 18058, 19618, 21052, 19631, 18710, 23940, 32377, 41888, 39379, 28622, 30106, 38148, 44813, 37202, 31083, 48031, 70527, 66942, 53957, 49584, 49344, 39057, 28039, 34540, 30821, 25220, 19045, 22785, 23319, 34534, 40534, 29218, 45518, 61947, 65846, 73052, 76934, 75406, 75832, 75281, 72261, 67047, 64983, 54868, 36847, 23436, 25757, 34897, 36784, 25072, 22286, 34411, 43688, 41562, 30050, 38453, 54494, 49373, 38474, 42651, 51908, 67251, 79645]
käytetytNumerot = [770, 550, 1469, 1022, 1500, 1262, 864, 1090, 1091, 668, 1407, 732, 395, 626, 1802, 974, 1119, 1480, 527, 1510, 1782, 1848, 1683, 1629, 1929, 1382, 1964, 1467, 1781, 1275, 1244, 1081, 1654, 1743, 1144, 1899, 1002, 1785, 1873, 1689, 1944, 2022, 1989, 189, 1657, 1876, 2011, 1788, 1977, 1976, 1674, 1578, 1688, 1922, 1963, 1530, 1501, 300, 1875, 346, 1987, 704, 1932, 495, 1486, 1356, 1890, 1690, 1750, 1369, 1569, 1742, 1640, 1320, 1879, 1973, 943, 1201, 1357, 2002, 521, 484, 1045, 1843, 1871, 1870, 1934, 1956, 1891, 1943, 1949, 1861, 1953, 1921, 1957, 1952, 2001, 1893, 1884, 1560, 1540, 1534, 1521, 1502, 1443, 1478, 1465, 1464, 1546, 1552, 1439, 1466, 1477, 1489, 1765, 1481, 1468, 1491, 1493, 1482, 1200, 1101, 878, 1678, 1659, 1874, 1766, 1911, 1679, 1912, 1696, 1784, 1856, 1643, 1043, 1111, 1340, 1289, 1199, 1291, 1234, 1432, 1057, 1444, 1433, 1422, 1141, 1414, 1202, 1303, 1314, 1190, 1254, 1354, 1106, 1397, 1248, 980, 1042, 1011, 1089, 777, 707, 1351, 1206, 1007, 1018, 1207, 1230, 1235, 1279, 1151, 1181, 1173, 1094, 1103, 1092, 1120, 1050, 1121, 1146, 1165, 1034, 1456, 1457, 1461, 1431, 1434, 1435, 1789, 1000, 1001, 1003, 1013, 999, 1019, 1015, 1021, 981, 1014, 1004, 1017, 992, 782, 799, 765, 785, 775, 766, 755, 744, 733, 722, 789, 790, 691, 724, 560, 360, 910, 1005, 432, 496, 800, 801, 802, 803, 804, 805, 700, 901, 865, 746, 747, 748, 749, 751, 783]
summa = 0
aloitusluku = 0
nykyinenVäli = 1
käynissä = True


def tarkistaEtteiSana(t):
    väli = str(t)
    if väli.isnumeric():
        return True
    else:
        return False


print(käytetytNumerot)

def summaaVäli(aloituskohta, välinNumero):
    global käytetytNumerot
    global summa
    summa = 0
    if aloituskohta + 43 <= len(käytetytNumerot):
        print("Tarpeeksi numeroita koko välin summaamiseen")
        for i in range(aloituskohta, aloituskohta + 43):
            summa += käytetytNumerot[i]
    else:
        print("Ei tarpeeksi numeroita koko välin summaamiseen")
        for i in range(aloituskohta, len(käytetytNumerot)):
            summa += käytetytNumerot[i]

    print("välin summa on " + str(summa) + " tarvitaan siis vielä " + str(listaSummat[välinNumero - 1] - summa) + " lisää")

def näytäVäli(aloituskohta):
    global käytetytNumerot
    if aloituskohta + 43 < len(käytetytNumerot):
        for i in range(aloituskohta, aloituskohta + 43):
            print(str(käytetytNumerot[i]) + " ", end=' ')
        print("\n")
    else:
        for i in range(aloituskohta, len(käytetytNumerot)):
            print(str(käytetytNumerot[i]) + " ", end=' ')
        print("\n")

def näytäAlku(aloituskohta, väli):
    global käytetytNumerot
    if aloituskohta < len(käytetytNumerot):
        print("Välin " + str(väli) + " Aloittavassa kohdassa on numero " + str(käytetytNumerot[aloituskohta]))
    else:
        print("Välin " + str(väli) + " Aloittavassa kohdassa ei ole mitään. Väli ei siis ole vielä alkanut.")

def montaMahtuu(aloituskohta, väli):
    if aloituskohta + 43 <= len(käytetytNumerot):
        print("Väliin " + str(väli) + " ei mahdu enään yhtään uutta lukua")
    else:
        print("Väliin " + str(väli) + " mahtuu vielä " + str((aloituskohta + 43) - len(käytetytNumerot)) + " numeroa")

summaaVäli(0, 1)

class Testi(object):

    def __init__(self, *args, **kwargs):
        pass

    def __enter__(self, *args, **kwargs):
        pass

    def __exit__(self, type, value, traceback):
        print(käytetytNumerot)


with Testi() as t:
    while käynissä == True:
        komento = input()
        Ei = False
        splitattuKomento = komento.split()
        if splitattuKomento[0] == "lisää":
            if tarkistaEtteiSana(splitattuKomento[1]):
                numero = int(splitattuKomento[1])
            else:
                print("Argumentit eivät olleet numeroita. Yritä uudelleen")
                continue
            print(numero)
            for l in range(len(käytetytNumerot)):
                if (käytetytNumerot[l] == numero):
                    print("numero " + str(numero) + " on jo käytetty.")
                    Ei = True
                    break
            if Ei == False:
                käytetytNumerot.append(numero)
                print("lisätty")

        elif splitattuKomento[0] == "korvaa":
            Ei = True
            if tarkistaEtteiSana(splitattuKomento[1]):
                korvattaNumero = int(splitattuKomento[1])
            else:
                print("Argumentit eivät olleet numeroita. Yritä uudelleen")
                continue
            if tarkistaEtteiSana(splitattuKomento[2]):
                numeroJollaKorvataan = int(splitattuKomento[2])
            else:
                print("Argumentit eivät olleet numeroita. Yritä uudelleen")
                continue

            for z in range(len(käytetytNumerot)):
                if (käytetytNumerot[z] == numeroJollaKorvataan):
                    Ei = True
                    break
                Ei = False
            if Ei == True:
                print("Numero " + str(numeroJollaKorvataan) + " on jo käytetty. Yritä uudelleen toisella numerolla")
            else:
                for h in range(len(käytetytNumerot)):
                    if käytetytNumerot[h] == korvattaNumero:
                        käytetytNumerot[h] = numeroJollaKorvataan
                        print("korvattiin numero " + str(korvattaNumero) + " numerolla " + str(numeroJollaKorvataan))
                        Ei = False
                        break
                if Ei == True:
                    print("numeroa " + str(korvattaNumero) + " ei ole listassa. Mitä oikein ajattelet?")


        elif splitattuKomento[0] == "summa":
            if tarkistaEtteiSana(splitattuKomento[1]):
                välinNumero = int(splitattuKomento[1])
            else:
                print("Argumentit eivät olleet numeroita. Yritä uudelleen")
                continue
            aloituskohta = (välinNumero - 1) * 20
            summaaVäli(aloituskohta, välinNumero)

        elif splitattuKomento[0] == "näytä":
            if tarkistaEtteiSana(splitattuKomento[1]):
                välinNumero = int(splitattuKomento[1])
            else:
                print("Argumentit eivät olleet numeroita. Yritä uudelleen")
                continue
            aloituskohta = (välinNumero - 1) * 20
            näytäVäli(aloituskohta)

        elif splitattuKomento[0] == "vaihda":
            if tarkistaEtteiSana(splitattuKomento[1]):
                vaihdettavanumero = int(splitattuKomento[1])
            else:
                print("Argumentit eivät olleet numeroita. Yritä uudelleen")
                continue
            if tarkistaEtteiSana(splitattuKomento[2]):
                toinenvaihdettavanumero = int(splitattuKomento[2])
            else:
                print("Argumentit eivät olleet numeroita. Yritä uudelleen")
                continue

            Ei = True
            for h in range(len(käytetytNumerot)):
                if käytetytNumerot[h] == vaihdettavanumero:
                    Ei = False
                    for k in range(len(käytetytNumerot)):
                        if käytetytNumerot[k] == toinenvaihdettavanumero:
                            käytetytNumerot[k] = vaihdettavanumero
                            käytetytNumerot[h] = toinenvaihdettavanumero
                            print("Vaihdettiin numero " + str(vaihdettavanumero) + " numerolla " + str(toinenvaihdettavanumero))
                            Ei = False
                            break
                        Ei = True
                    if Ei == True:
                        print("numeroa " + str(toinenvaihdettavanumero) + " ei löytynyt käytetyistä numeroista. Mitä yrität tehdä?")
                        Ei = False
                        break
                    else:
                        break
            if Ei == True:
                print("vaihdettavaa numeroa " + str(vaihdettavanumero) + " ei löytynyt käytetyistä numeroista. Mitä yrität tehdä?")

        elif splitattuKomento[0] == "alkaa":
            if tarkistaEtteiSana(splitattuKomento[1]):
                merkittyVäli = int(splitattuKomento[1])
            else:
                print("Argumentit eivät olleet numeroita. Yritä uudelleen")
                continue

            aloituskohta = (merkittyVäli - 1) * 20
            näytäAlku(aloituskohta, merkittyVäli)

        elif splitattuKomento[0] == "paikanna":

            if tarkistaEtteiSana(splitattuKomento[1]):
                haettavaNumero = int(splitattuKomento[1])
            else:
                print("Argumentit eivät olleet numeroita. Yritä uudelleen")
                continue
            Ei = True
            for f in range(len(käytetytNumerot)):
                if haettavaNumero == käytetytNumerot[f]:
                    print("Paikannettava numero on " + str(f + 1) + " käytetyissä numeroissa.", end=' ')
                    if f != 0 and f != len(käytetytNumerot) - 1:
                        print("Sen takana on luku " + str(käytetytNumerot[f - 1]) + " ja edessä on luku " + str(käytetytNumerot[f + 1]))
                    elif f != 0:
                        print("Sen takana on luku " + str(käytetytNumerot[f - 1]))
                    else:
                        print("Sen edessä on luku " + str(käytetytNumerot[f + 1]))

                    Ei = False
                    break



            if Ei == True:
                print("Numeroa " + str(haettavaNumero) + " ei löytynyt käytetyistä numeroista. Mitä yrität?")

        elif splitattuKomento[0] == "vie":
            väliKäytetyt = käytetytNumerot.copy()
            for o in range(1, 2024):
                Ei = False
                for t in range(len(väliKäytetyt)):
                    if o == väliKäytetyt[t]:
                        Ei = True
                        break
                if Ei == False:
                    väliKäytetyt.append(o)
            for u in range(len(väliKäytetyt)):
                print(väliKäytetyt[u], end=' ')
            print("\n")

        elif splitattuKomento[0] == "mahtuu":
            if tarkistaEtteiSana(splitattuKomento[1]):
                välinNumero = int(splitattuKomento[1])
            else:
                print("Argumentit eivät olleet numeroita. Yritä uudelleen")
                continue

            aloituskohta = (välinNumero - 1) * 20
            montaMahtuu(aloituskohta, välinNumero)





















Test details

Test 1

Verdict:

input
58667 68283 64141 69169 67564 ...

correct output
688 488 1060 602 1171 471 322 ...

user output
import math
import time
import msvcrt

listaSummat = [58667, 68283, 6...