summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorSanto Cariotti <sancn@live.com>2017-05-01 18:52:55 +0200
committerSanto Cariotti <sancn@live.com>2017-05-01 18:52:55 +0200
commit0529cbf6f276b769022c0cd50b006b8de99c9383 (patch)
treeab14d08e13dcd352d142587d78685592bf2d3a33 /python
parent1e82950a94ccaf4909611ca92fbe5c1de60b8533 (diff)
Added two new files
Diffstat (limited to 'python')
-rw-r--r--python/bicicletta.py26
-rw-r--r--python/crittografa.py34
2 files changed, 60 insertions, 0 deletions
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