I had a co-worker who coded his own CMS for a relatively successful web agency (it was the pre-wordpress era). And he coded part of this CMS on paper at a party. Must have been one crazy party :)
it depends, for some critical line of code you can't make mistakes (for example if you are writing something involved with security , or in some worse case if you are programming an airplane consolle). So my point is: you can be drunk while coding but you have to be 100% sober while planning your tests for that code. Accordingly to a lot of studies alchool (also drugs) helps our brain to "think different" so while you are drunk you could find a solution for a problem you were stuck in just because while you are drunk your brain discovers different patterns. However i don't have much experience about this ... i've coded something while i was mildly drunk and i saw no difference.
I have read that sleep deprivation is as bad as getting drunk in terms of the number of IQ points' hit taken, so I would argue that many folks in the industry are effectively coding drunk :-)