Timeline: somewhere in the late '70s
Environment: IBM mini with 32mb of memory; programming in COBOL; all batch processing
Task: don't remember what, exactly, the job was supposed to do but to do it ... we had to have two arrays. The arrays were coupled - if one grew we didn't need as much space in the other one and vice-versa. Problem is, COBOL didn't (doesn't?) have variable length arrays and we didn't have fancy stuff like virtual memory. And, of course, as was normal at the time, we didn't have near enough memory to use.
Important fact: using that compiler, COBOL would place things in memory in the exact order they were declared and would never move anything.
Solution:
I took on the impossible task.
I declared array1 dimensioned to fill just about all the free memory we had available. Then, I created array2(1) right after it. I used a forward incrementing index in array1 eating away at the space following it, and then ...
and then ...
and then ...
and then ...
and then ...
I set up a negative index on array2 to use up the space above array2. Lordie, I love COBOL. It actually worked but after typing the description out I feel a little bit dirty. I do remember that the code to watch for a collision between the two arrays was somwhat non-intuitive. Complicated arithmetic in COBOL is, uh, different.
WTFs:
1) Nobody else there could come up with such an elegant solution. So there, I win.
2) COBOL allowed negative array indexes (indicies?). In fact, COBOL didn't give a flying fark about what the index was, you had to sort of police that yourself. Or not. Element # 4,782,487,999,104? Just a moment, I'll truncate, strip sign bits, and figure out exactly where in this data centre this is. Hmmm ... seems to be value 42.
3) The guy that had to maintain that code after I left the company probably had a massive breakdown and never programmed again.
4) I'm still proud of actually getting away with it and making it work.