Jan
04
2006

How does one flip a coin on the internet?

Real world story:

A “lead developer of Selenium” has been invited to speak at FOSDEM next month.

Both Paul Hammant and I want to go and speak. Both of us can take some claim as “lead developer” of Selenium, only it’s a been awhile since either one of us has committed any code! (I created Selenium in July 2004 with Paul Gross, Paul Hammant was the architect of Selenium’s “driven” interface.) Mike Williams was asked first, but he is unable to attend and referred this to Paul and I. FOSDEM can only guarantee the cost of travel for one person.

Paul suggested a flip of the coin to see who gets to go on FOSDEM’s dime. The “loser” gets to plead with ThoughtWorks management (our employer) to foot the bill for their travel. FOSDEM has agreed to let both of us speak at the meeting, if the coin flip “loser” can pay for his own travel (or get TW to pay for it.)

In simpler times, Paul and I would be in the same office and we would flip a coin, pick a friend to “choose a number between 1 and 100″, or RPS to decide the matter.

Problem is, we’re not in the same office.

Here’s what I proposed to Mike and Paul:

I propose that Mike chooses a number between 1 and 100. Paul and I choose a number and we both email our individual answers to Mike. Mike tells us who won. We trust Mike implicitly to be fair and balanced as referee. The winner is the person with the number closest to Mike’s number without going over. Guessing it correctly is of course, okay. If it results in a tie, then we repeat the process, but this time it’s between 1 and 200. Mike, did I tell how awesome a coder you are?

I have a feeling there’s a Web 2.0 startup company in this idea somewhere. How to flip a coin when both parties can’t be physically present for the coin toss seams to be a general problem just begging for a Django or Ruby on Rails-based solution. Having it based in Chicago and sponsored by 42nouns.com would be a big bonus.

Yes? No? Already exists? Thoughts? To make this Web 2.0, we’d need RSS feeds of the results and anyone can comment on any virtual coin flip about what was at stake and who should have or shouldn’t have won. There’d also be a REST interface to HTTP POST one’s answer from a Ruby/Python/Squeak client.

Or… maybe Paul and I should just both log in and play a 2-person game at partypoker.com to determine the winner?

posted in django, python, rails, selenium by Jason Huggins

8 Comments to "How does one flip a coin on the internet?"

  1. Paul wrote:

    I think I’ll just call in to see you when I’m in the office dood :-)

  2. Jason Huggins wrote:

    Darn your Agile and “The simplest thing that could possibly work” ways!

  3. Bart wrote:

    Here’s a way to virtually flip a coin with cryptography:

    (Take from http://www.everything2.com/index.pl?node_id=1342791 – the same method is also described in the book “Applied Cryptography” by Bruce Schneier)

    This method works well over the phone, or in another circumstance where two parties are physically separated (like over the Internet!).

    Alice and Bob agree on a hash function H which compresses its input to an N-bit result. H should have a result long enough to prevent a mortal from finding two inputs which hash to the same result. It should also be free of shortcuts for doing so. In other words, it should be a cryptographic hash.

    One of the two people picks a random number, hashes it with H(x), and tells y=H(x) to the other party. The recipient of y guesses whether the random input was even or odd. After this, the party who generated the random number reveals this secret number. The recipient can compute H(x) and verify that it equals y, thus, that x is almost certainly the original random number. After this it is obvious to both sides whether the guess was correct.

  4. Peter Hunt wrote:

    This is a way that works for general random numbers.

    Have Alice generate a list of N numbers and encrypt the list with a private key. Alice then sends the list to Bob. Bob can’t look at the list yet, because he doesn’t know the secret key yet. Bob then picks a number between 0 and N-1 and sends it to Alice. Alice replies with the secret key and Bob decrypts the list. The random number is the index in Alice’s list that Bob picked.

  5. Jesper Lyster wrote:

    Or you might just roll some virtual dice to determine the winner http://www.irony.com/mailroll.html

  6. Patrik wrote:

    Since you have at trusted third party, send him a mail each with ‘rock’, ’scissors’ or ‘paper’. That’s how it’s done!

  7. Jason Huggins wrote:

    Great suggestions… Another idea I had was that it would be nice if in Yahoo IM you could simply “right-click” on a friends name in your buddy list, and simply select from a sub-menu of choices such as “Challenge to a coin flip…” or “Challenge to a dice roll”… A simple wizard would walk each “player” through the steps to determine the winner. I guess you can do that now with the “Play a Game…” option, but I’d want a pure game of chance— no skill required. :-)

  8. Dean wrote:

    This looks like it might do the job: http://cgi.cs.duke.edu/~des/vct/vct.cgi

 
Powered by Wordpress and MySQL. Theme by openark.org