|
Post by tenochtitlanuk on Jul 5, 2023 11:57:37 GMT -5
Someone posting on Rosetta Code with a LB solution included the following line..
rd=gn=bl=int(rnd(1)*255)
Multiple attributions are available in some languages, written this way. Not in LB. What do you think LB makes of it...??
|
|
|
Post by tsh73 on Jul 5, 2023 13:50:32 GMT -5
I pretty sure it does not assign anything but outer variable Inner used in comparison, resulting in 0 (false) or 1 (true) But in what order? This test
x=1:y=1:z=1 '1'1'1 x=1:y=2:z=2 '0'1'0 x=2:y=2:z=1 '1'0'1 print print (x=y)=z print x=(y=z) print x=y=z
suggests that x=y=z evaluates as (x=y)=z
So we get rd=((gn=bl)=int(rnd(1)*255)) (gn=bl) is 0 or 1 int(rnd(1)*255)) is 0 or 1 with probability 1/256
So rd is 1 with probability 1/256, else 0 gn,bl is not changed, and is not affect random result (! ha ! nice obsfucation)
Let's test it
N=1000000 for i = 1 to N rd=gn=bl=int(rnd(1)*255) if rd then s=s+1 'print i, rd next print s, N/s
I got on a test run
4047 247.096615 - pretty close I think. (other runs sure will differ)
|
|
|
Post by tenochtitlanuk on Jul 6, 2023 12:26:02 GMT -5
Yup. I did a similar test-
ifor i =1 to 1024 rd=gn=bl=int(rnd(1)*255) if rd =0 then print "0"; else print: print rd next
|
|