Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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)



"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?


Not 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...


I would call this "PHP hacker solution" :)


Yeah, 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.


Would 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: