From 0529cbf6f276b769022c0cd50b006b8de99c9383 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Mon, 1 May 2017 18:52:55 +0200 Subject: Added two new files --- python/bicicletta.py | 26 ++++++++++++++++++++++++++ python/crittografa.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 python/bicicletta.py create mode 100644 python/crittografa.py diff --git a/python/bicicletta.py b/python/bicicletta.py new file mode 100644 index 0000000..d3c181a --- /dev/null +++ b/python/bicicletta.py @@ -0,0 +1,26 @@ +posBici = [] +m = [0, 0] + +with open('input.txt', 'r') as fin: + info = fin.readline().split(' ') + + for i in range(int(info[0])): + posBici.append(int(fin.readline())) + + for i in range(int(info[1])): + passo = fin.readline().split(' ') + + for j in range(int(info[0])): + if posBici[j] == passo[0]: + m[0] = j + + if posBici[j] == passo[1]: + m[1] = j + + + posBici[m[0]] = passo[1] + posBici[m[1]] = passo[0] + + +with open('output.txt', 'w') as fout: + fout.write(str(posBici[0])) diff --git a/python/crittografa.py b/python/crittografa.py new file mode 100644 index 0000000..f853527 --- /dev/null +++ b/python/crittografa.py @@ -0,0 +1,34 @@ +consonantiMax = [ + 'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Z', 'B'] +consonantiMin = [consonantiMax[i].lower() for i in range(len(consonantiMax))] # consonanti minuscole +vocaliMax = ['A', 'E', 'I', 'O', 'U', 'Y', 'A'] +vocaliMin = [vocaliMax[i].lower() for i in range(len(vocaliMax))] +numeriList = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'] + +nuovaParola = [] + +def converti(lettera): + if lettera in consonantiMax: + nuovaParola.append(consonantiMax[consonantiMax.index(lettera)+1]) + elif lettera in consonantiMin: + nuovaParola.append(consonantiMin[consonantiMin.index(lettera)+1]) + elif lettera in vocaliMax: + nuovaParola.append(vocaliMax[vocaliMax.index(lettera) + 1]) + elif lettera in vocaliMin: + nuovaParola.append(vocaliMin[vocaliMin.index(lettera) + 1]) + elif lettera in numeriList: + nuovaParola.append(numeriList[numeriList.index(lettera) + 1]) + else: + nuovaParola.append(lettera) + +with open('input.txt', 'r') as fin: + parole = fin.read(999999) + + +for i in parole: + converti(i) + + +with open('output.txt', 'w') as fout: + for i in nuovaParola: + fout.write(i) \ No newline at end of file -- cgit v1.2.3-18-g5258