4 ms·
Maybe an easier solution would be to append all the answers, take a hash (e.g. sha1), then convert the last 2 digits from hex to decimal, and mod 10. 1 liner.
by alexandercrohde 7y ago
Maybe an easier solution would be to append all the answers, take a hash (e.g. sha1), then convert the last 2 digits from hex to decimal, and mod 10.
1 liner.
--
EDIT: I lied, this doesn't work, it biases towards 1-5. I guess you could convert to decimal, and divide by (FFFFFFFFFFFFF / 10)
- vzaliva 7y agoI would call this "PHP hacker solution" :)
- alexandercrohde 7y agoYeah, there's a few types of "great solutions" in engineering. There are those that run really fast (big O) and those that can be written really fast. 99% of the time the job calls for engineers who can come up with the second type of solution.
- LeoPanthera 7y ago"But, let’s say you have to do this without access to coins, computers, radioactive material, or other such access to traditional (pseudo) random number generators. All you have is a room of people." Can you do a SHA1 in your head?
- guan 7y agoNot quite in his head, but Ken Shirriff did SHA-256 with pencil and paper: http://www.righto.com/2014/09/mining-bitcoin-with-pencil-and-paper.html http://www.righto.com/2014/09/mining-bitcoin-with-pencil-and...
- FabHK 7y agoWould be slightly biased, though (256 is not divisible by 10, you'd have to reject if >=250, say). EDIT: and don't forget to add 1.