Urinal protocol vulnerability

19 11 2009

When a guy goes into the bathroom, which urinal does he pick?  Most guys are familiar with the International Choice of Urinal Protocol.  It’s discussed at length elsewhere, but the basic premise is that the first guy picks an end urinal, and every subsequent guy chooses the urinal which puts him furthest from anyone else peeing.  At least one buffer urinal is required between any two guys or Awkwardness ensues.

Let’s take a look at the efficiency of this protocol at slotting everyone into acceptable urinals.  For some numbers of urinals, this protocol leads to efficient placement.  If there are five urinals, they fill up like this:

The first two guys take the end and the third guy takes the middle one.  At this point, the urinals are jammed — no further guys can pee without Awkwardness.  But it’s pretty efficient; over 50% of the urinals are used.

On the other hand, if there are seven urinals, they don’t fill up so efficiently:

There should be room for four guys to pee without Awkwardness, but because the third guy followed the protocol and chose the middle urinal, there are no options left for the fourth guy (he presumably pees in a stall or the sink).

For eight urinals, the protocol works better:

So a row of eight urinals has a better packing efficiency than a row of seven, and a row of five is better than either.

This leads us to a question: what is the general formula for the number of guys who will fill in N urinals if they all come in one at a time and follow the urinal protocol? One could write a simple recursive program to solve it, placing one guy at a time, but there’s also a closed-form expression.  If f(n) is the number of guys who can use n urinals, f(n) for n>2 is given by:

The protocol is vulnerable to producing inefficient results for some urinal counts.  Some numbers of urinals encourage efficient packing, and others encourage sparse packing.  If you graph the packing efficiency (f(n)/n), you get this:

This means that some large numbers of urinals will pack efficiently (50%) and some inefficiently (33%).  The ‘best’ number of urinals, corresponding to the peaks of the graph, are of the form:

The worst, on the other hand, are given by:

So, if you want people to pack efficiently into your urinals, there should be 3, 5, 9, 17, or 33 of them, and if you want to take advantage of the protocol to maximize awkwardness, there should be 4, 7, 13, or 25 of them.

These calculations suggest a few other hacks.  Guys: if you enter a bathroom with an awkward number of vacant urinals in a row, rather than taking one of the end ones, you can take one a third of the way down the line.  This will break the awkward row into two optimal rows, turning a worst-case scenario into a best-case one. On the other hand, say you want to create awkwardness.  If the bathroom has an unawkward number of urinals, you can pick one a third of the way in, transforming an optimal row into two awkward rows.

And, of course, if you want to make things really awkward, I suggest printing out this article and trying to explain it to the guy peeing next to you.

Discussion question: This is obviously a male-specific issue.  Can you think of any female-specific experiences that could benefit from some mathematical analysis, experiences which — being a dude — I might be unfamiliar with?  Alignments of periods with sequences of holidays? The patterns to those playground clapping rhymes? Whatever it is that goes on at slumber parties? Post your suggestions in the comments!

Edit: The protocol may not be international, but I’m calling it that anyway for acronym reasons.

ACK: This was originally published in XKCD http://blag.xkcd.com/2009/09/02/urinal-protocol-vulnerability/





Nifty Tricks !

26 10 2009

Trick 1:Running a simple HTTP / FILE server:

Supposing you have a folder where you have mirrored a repository and now want to use it instead of the on line (Over the Internet) repo.
So, since most Linux…et all OS es have PYTHON by default ,

cd to the mirror folder and execute
$python -m SimpleHTTPServer 9914
NOTE:here 9914 is an arbitrary port number, can be any unused port.

Trick 2:Resuming Torrent Downloads:
Recently because of some reason my ubuntu 8.10 which i was using for a long time, crashed. I had lots of unfinished torrent downloads there.
Not knowing what to do, i took a copy of the incomplete downloads and headed over to 9.04 and then copied them to Transmission Torrent client’s default download location and downloaded the same torrent files, to my amazement the
downloads resumed !





The UI of the Future

21 10 2009

The 10/GUI desktop UI is quite good though not revolutionary (Already existing on mobile phones)
Here is a brief preview of the concept.

10/GUI from C. Miller on Vimeo.





Just got My 9600GT & Corsair SMPS.

20 09 2009

I recently got my 9600GT along with a 450W Corsair SMPS and they are sweeeet ! :-)
Though i am very excited with my new toys here are a few preliminary observations about them:
1.The SMPS has got no fan and so makes ZERO noise.
2.The glxgears in my ubuntu 8.10 box maxed at 8700FPS in contrast to 1200FPS of the built in ATIx1250 Graphics Card.
3.The card comes with a cable to connect to my TV (That’s neat !).
4.The Nvidia drivers for Ubuntu are so good that they pointed out that i had not connected a power cable to my Graphics card :-p (Man this is good !!!).

For now i just feel like getting submerged in the millions of colors and realistic virtual worlds fed by the juice of my Graphics Card.
Haaaaaaaaah !

Kunal Ghosh
(kunalghosh)





Database Project

19 09 2009

The DB Design

The DB Design


We were asked by our Database professor to design and implement a Database for storing details of Practical Exams of our Department as a Mini-Project.
Though we were not given any particular goal, with this design of mine i aim to write an application which will generate the time table given a start date of the Practicals.
I have made following “Application” Design Decisions in this draft (Random Order):
1.Alternate semesters can have labs simultaneously.
2.Clash of Dates ,ie student’s regular and arrears are scheduled on the same day at the same time, are avoided by scheduling the Pracs of higher semesters first.
3.Some labs are subject specific. i.e. we should have Analog Electronics Prac only in a particular lab.

Thats all for this Draft. :-)
Kunal Ghosh
(kunalghosh)





XKCD at its best !

25 06 2009


(PS:ACK, i first saw it at Animesh Bhaiya’s Blog).





Guys check out Microsofts latest offering, and its not Windows !

3 06 2009

Guys i happened to chance upon Microsoft’s project Natal and it sure is impressive. Go have a look for your self: YOUTUBE





Quick Tips: Absolute SVN (subversion) basics.

20 05 2009

The very basic after installing SVN on your computer is to perform
CASE 1: In case you want to use svn offline.
1.svnadmin create /directory/path
NOTE:assuming you were working on some code copy the code to the svn directory.
2. cd /directory/path
3. “svn add .” OR “svn add –force .”
4. svn commit -m ” commit message”

CASE 2: In case you want to use svn with some online repository.
1.svn co http://path (enter username and password if prompted).
NOTE: do STEP 1 even if the SVN repo at the URL is empty
2.copy the files or directories to the Checked Out(svn co …..) directory
3.same as above.
4.same as above.

regards.

kunalghosh
(kunal ghosh)





Quick TIp: Resume svn check outs

20 05 2009

I’ve had power outages while doing svn checkouts ( method to get a local copy of source code on an online repository ), so to resume the checkout, cd to the svn working directory and issue “svn up” (without ” “) to resume the checkout.





Appjet.com Rocks !!

20 05 2009

If you have ever wondered where have all the user friendly web apps gone ? just check out Appjet.com’s recent addition the EtherPad(EtherPad.com, one such app, you’ll have to use it to realize.And if you had seen that before just check out their online IDE, i’m sure you’ll love it.
NOTE: I had blogged about Appjet.com some time back also and since then i’ve seen EtherPad and many other promising updates on the site.

kunalghosh
(kunal ghosh)