You are viewing a single comment's thread from:

RE: update for beem: create posts more easily and draw pseudo-random numbers

in HiveDevs4 years ago

Your hive draw looks a lot more sophisticated than the one I made.
It should proove to be very useful

I'll have to give it a try soon.

One thing I noticed is you don't add +1 after calculating the modulo.

So it looks like you are calculating from 0 to n-1 with position 1 actually being 0. That or it is impossible for the top number to be called. I know you called .len but I'm not sure exactly how it works (I'm still just really noob).

Sort:  

The following results can be checked with:

beempy draw -d 5 -p 2 -b 43903393 -t 15bc57129f215b93857eeea7935538d56b1a9223 -h sha256 -s ','
keyvalue
block number43903393
trx id15bc57129f215b93857eeea7935538d56b1a9223
block id029de9a1e968a91ef4819726354ca60f8c3fe4bc
previous id029de9a04d988326c0b85e79fd16b69b6817c299
hash typesha256
draws5
participants2
1. draw2
2. draw2
3. draw1
4. draw1
5. draw2

As you can see the last position will also be called.

I'm just added +1 to all numbers. So the number are going from 1 to participants.

That's an easy way to check and to flip a coin.

The following results can be checked with:

beempy draw -d 3 -p 100 -b 43908154 -t 52840f5017464772a9a940a6ecfeb268d0a95def -h sha256 -s ','
keyvalue
block number43908154
trx id52840f5017464772a9a940a6ecfeb268d0a95def
block id029dfc3a5273dd08bd9ada6426205ac7c5d1dd0c
previous id029dfc39a4961c8b6dc21da20c7b8d598e963dc8
hash typesha256
draws3
participants100
1. draw79
2. draw82
3. draw97