-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandthm.jl
56 lines (42 loc) · 995 Bytes
/
randthm.jl
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
51
52
53
54
55
56
f = open("teoremi.txt","r")
thm = readlines(f)
l = length(thm)
# limits for the extraction
lo, hi = 1, l
# lo, hi = parse.(Int, split(readline(stdin), " "))
######### Generation of t #########
cr=open("counts.txt", "r")
counts=readlines(cr)
counts=split.(counts, r"[.] ")
c=[parse(Int64, counts[i][2]) for i=1:l ]
close(cr)
media=0.0
for i in 1:l
global media+=c[i]
end
media=media/l
t = rand(lo:hi)
while abs(c[t]-media)>3
global t = rand(lo:hi)
end
#########################
println( "$(thm[t])" )
close(f)
cw=open("counts.txt", "w")
new=c[t]+1
for i in 1:l
if i==t
print(cw, "$i. $new\n")
else
print(cw, "$i. $(c[i])\n")
end
end
close(cw)
auguri=["Buona fortuna!",
"Buona dimostrazione, e non usare come scusa il fatto che ti manchi spazio sul margine del foglio.",
"Buon lavoro!",
"Dai che è semplice questo.",
"Cvd.", "Qed.", "Triviale.",
"Buono studio!"]
la=length(auguri)
print(auguri[t%la+1])