8000 Corretto soluzioni · mathcoding/programming@8bdf206 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8bdf206

Browse files
committed
Corretto soluzioni
1 parent 4b31d22 commit 8bdf206

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

latex/esercitazioni/es_5.pdf

0 Bytes
Binary file not shown.

scripts/Soluzioni_es_5.py

+4Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,15 @@ def ContaCaratteri(s):
9797
D = {} # Costruttore di un dizionario vuoto
9898
for c in s: # Ciclo su tutti caratteri della stringa
9999
if c in D:
100-
D[c] += 1
100+
D[c] = D[c] + 1 # Equivalente a Ds[c] += 1
101101
else:
102102
D[c] = 1
103103
return D
104104

105105
def CalcolaFrequenza(D):
106106
F = {}
107+
# Commento su builtin 'sum'
108+
# Link: https://docs.python.org/3/library/functions.html#sum
107109
tot = sum(D.values())
108110
# Soluzione semplice
109111
for key in D:
@@ -136,7 +138,7 @@ def ComputeTables(Ls):
136138
for key in sorted(Ls): # Lista di chiavi, ordine sulle chiavi
137139
char2int[key] = idx
138140
int2char[idx] = key
139-
idx = idx + 1
141+
idx = idx + 1 # Equivalente a idx += 1
140142
return char2int, int2char
141143

142144
#-----------------------------------------------

0 commit comments

Comments
 (0)
0