39 lines
1.3 KiB
Plaintext
39 lines
1.3 KiB
Plaintext
Module CheckThis {
|
|
Function CombinationsStep (a, nn) {
|
|
c1=lambda (&f, &a) ->{=car(a) : a=cdr(a) : f=len(a)=0}
|
|
m=len(a)
|
|
c=c1
|
|
n=m-nn+1
|
|
p=2
|
|
while m>n {
|
|
c1=lambda c2=c,n=p, z=(,) (&f, &m) ->{if len(z)=0 then z=cdr(m)
|
|
=cons(car(m),c2(&f, &z)):if f then z=(,) : m=cdr(m) : f=len(m)+len(z)<n
|
|
}
|
|
c=c1
|
|
p++
|
|
m--
|
|
}
|
|
=lambda c, a (&f) ->c(&f, &a)
|
|
}
|
|
treated=(85, 88, 75, 66, 25, 29, 83, 39, 97)
|
|
placebo=(68, 41, 10, 49, 16, 65, 32, 92, 28, 98)
|
|
treat=treated#sum()
|
|
double total=1
|
|
for i=len(placebo)+1 to len(placebo) +len(treated):total*=i:next i
|
|
for i=len(placebo)-1 to 1: total/=i:next i
|
|
d=total div 10**int(log(total))
|
|
k=false
|
|
StepA=CombinationsStep(cons(treated, placebo),len(treated))
|
|
long counter=0
|
|
long gt=0
|
|
While not k
|
|
if StepA(&k)#sum()>treat then gt++
|
|
counter++: if counter mod d=0 then Print over str$(counter/total," #0.0%"):Refresh
|
|
End While
|
|
print over str$(counter/total," #0.0%")
|
|
print
|
|
lt=total-gt
|
|
print Format$("less or equal={0:1}%, greater={1:1}%, total={2}",lt/total*100, gt/total*100, total)
|
|
}
|
|
CheckThis
|