views:

618

answers:

11

Hi,

As a programmer, I know sometime all has to write some code which they think -"Thank God! It's done" or "Ohh, how did I write it?"...

Do you have any such piece of code.

+3  A: 

The trickiest thing for me was a ticketing system that allocated seating, choosing seats filling exact gaps and allocating the best seats first. This involved some tricky SQL to get contiguous(sequential) seat number ranges available.

Mark Redman
Smells like NP problem cheat ^^
Clement Herreman
what does that mean?
Mark Redman
@Mark See NP Complete: http://en.wikipedia.org/wiki/Np_complete
mezoid
I dont know so much, NP indicates that no efficient algorithm would exist, but the implementation in the end was pretty sound and straight forward after working out the details.
Mark Redman
A: 

C#:

Console.WriteLine("Hello world!");
Greco
Pointless
tomfanning
+1 with tomfanning, uselles I'd say
Clement Herreman
...if you're Anders Hejlsberg doing that for the first time!
Mark Redman
Read the tagging :)
Greco
You mean the humour tag? Well, it wasn't very funny...
tomfanning
Funny how my rep just took a hit of a few points...
tomfanning
Well, humor is relative like many other things, but OK, you do not have to like it...
Greco
Actually you know, if this was the first ever code you wrote there would be an argument for saying it's the trickiest 'cause you've got to grasp the concept of a programming language to get this far
Cruachan
+4  A: 

I avoid writing tricky code. Not fun, neither to anyone nor to myself six months later.

Developer Art
So you don't code at all?
Sam
I believe in writing tricky code / quick fix in crunch situations, But always get back to it after crunch time and fixit.
Sunny
Wallah - I always want to go back after crunch time to improve tricky/poor code, but all too often crunch time is quickly followed by another crunch time. :(
Bill W
+1  A: 

a python script i wrote to learn python:

it takes a keyboard layout and a text and calculates the way every single finger has to go writing that text.

i think the tricky part here was learning python

knittl
+1  A: 
Traveling Tech Guy
Why? For at least fifteen characters.
Sam
I'm also curious why anyone would want that.
Aistina
I guess adding "don't ask why" doesn't carry any weight any more :)Ok, here's the reason: it was for a natural language compiler, and one of the languages supported was Hebrew - a right-to-left language. For some reason, whenever the text direction on the screen is reverted, the Mainframe reversed every parenthesis in the code. I had to write the code that went and reversed them back. But if someone went back and edited his saved code... the parenthesis reversed right back - and back to square one we went :)
Traveling Tech Guy
Actually, I think the real 'why' question is 'why write this in assembler'. It's a one-liner with tr.
Chris Dodd
Because it ran as a procedure inside a database - written in Assembler.
Traveling Tech Guy
+2  A: 

I don't recall the specifics well, but a couple times I used something of this form:

do {
    switch(foo) {
    case 1:
        break; // syntactically breaks switch, but actually breaks loop
    case 2:
        continue; // as if this were supported by switch
    }
} while(false);
John Zwinck
A: 

The trickiest code I ever wrote was a set of Prolog predicates to generalize a case defined in terms of of constant expressions by turning those constants into variables. One weekend, over 30 hours... good times.

I was the only person who figured out how to do it, so in all subsequent semesters, Dr. Upal just gave people the code. That takes all the fun out of it! LOL.

Kaleb Brasee
A: 

A parser for Mork in Java using regular expressions. It was a bad idea.

mhaller
A: 

I've logged 100+ development hours on this one: http://stackoverflow.com/questions/2550315/

Who'd thunk that adding a button to a report row would be so freaking frustrating >_<

glasnt
A: 

It was a function to implement US Patent 5,873,116. The function in question wound up being about 10 or 15 lines of actual code. It took six months to work through all the different problems that could be caused by the different models of memory caching hardware that were involved.

Julie in Austin
+1  A: 

A program that I wrote to check Tripit and place a graphic that says "Yes Honey, those jeans DO make your butt look fat" in my wife's Chumby stream only when I'm out of town. I did think "Thank God! It's done" but not until I was safely in the hotel. Somebody had to tell her.

T.Rob