-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartSetup.py
50 lines (31 loc) · 923 Bytes
/
startSetup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
expMess = ((66,5,48,62,13,75,29,24,61,42,70,66,62,32,14,81,8,15,78,2,29,13,49,1), (66,5,49,75,54,2,60,29,40,2,55,9,15,59,18,68,3,36,5,47))
def IoC(messages, precalc=True):
mmin = 0
mmax =82
n = [0]*(mmax - mmin + 1)
amount = 0
for m in messages:
amount += len(m)
for c in m:
n[c - mmin] += 1
if amount <= 1:
return 0,0
ic = 0
for i in n:
ic += i*(i-1)
if precalc:
return ic / (amount * (amount - 1) / (mmax - mmin + 1))
return ic , (amount * (amount - 1) / (mmax - mmin + 1))
def DoubleCount(messages):
dc = 0
for m in messages:
for i in range(len(m)-1):
if m[i] == m[i+1]:
dc += 1
return dc
expMess = [list(m) for m in expMess]
for m in expMess:
for i in range(len(m)-1):
m[i] = (m[i] + m[i+1]) % 83
print(expMess)
print(IoC(expMess))