Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
30 blind people in experiment
Message
De
24/01/2006 21:37:50
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
Information générale
Forum:
Games
Catégorie:
Casses-têtes
Divers
Thread ID:
01089884
Message ID:
01089995
Vues:
23
>>>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.

The books whose ordinal numbers are prime are sure to change state twice (except book #1). The others will change state as many times as they have factors - counting 1 as a factor. So book 4 will change state three times (for 1, 2, 4); book 12 will do that for 1, 2, 3, 4, 6 and 12 (six flips) etc etc. It's possible to shorten this and first build a list of numbers which have an odd number of factors - as these are the ones which will change state. The difference in the end cannot be larger than the length of this list.

Update: just comment out the lines 3 to 5 in the code above, so a=.f. (all elements), and run the code. You get nine flipped books - so, the difference between the number of open books in the beginning and the end must be that number plus/minus nine.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform