>>There are 100 books on the table. Some opened, some closed. The first person comes into the room and closes open books and open closed. The second does the same, but with all even books. The third does it for each 3rd number, etc. 100 people came to the room. The quesiton is: how many open books would be on the table after all 100 people have been in the room?
>
>
Dimension a[100]
>Rand(-1)
>For i=1 To 100
> a[i]=Rand()>0.5
>Endfor
>CountUps("initially")
>
>For i=1 To 100
> For j=1 To 100 Step i
> a[j]=Not a[j]
> Endfor
> If i%5=0
> CountUps("After "+Transform(i))
> Endif
>Endfor
>
>
>Procedure CountUps(c)
>Local N, i
>N=0
>For i=1 To 100
> N = N + Iif(a[i],1,0)
>Endfor
>? c, N
>
>
>It usually gives a number anywhere between 40 and 60, and the initial number of open (i.e. a[i]=.t.) ones is in the same range. So it's either some missing piece of initial conditions, or this is very random.
Nice. Actually, this problem has several right answers, e.g. the exact answer is undetermined without knowing the original state of certain books. At least that's how I solved this problem myself, the person who posted the problem didn't tell the solution yet.
But if we assume that the N was original number of open books, then we have limited small number of right answers.
If it's not broken, fix it until it is.
My Blog