12 lines
226 B
Text
12 lines
226 B
Text
func entropy s$ .
|
|
len d[] 255
|
|
for c$ in strchars s$
|
|
d[strcode c$] += 1
|
|
.
|
|
for cnt in d[] : if cnt > 0
|
|
prop = cnt / len s$
|
|
entr -= prop * log prop 2
|
|
.
|
|
return entr
|
|
.
|
|
print entropy "1223334444"
|