Comment On The "Who Knows?" Code

When Vladimir first received his orders, the blood drained from his face. He was to take the legacy VB5 application, a system used daily by scores of users daily, and uplift it to C++. [expand full text]
« PrevPage 1 | Page 2 | Page 3 | Page 4 | Page 5Next »

Re: The "Who Knows?" Code

2009-12-02 09:03 • by Vince (unregistered)
wtf

Re: The "Who Knows?" Code

2009-12-02 09:04 • by Piet (unregistered)
If statements are the answer to all problems. If it's not working, you aren't using enough.

Re: The "Who Knows?" Code

2009-12-02 09:04 • by Rodnas (unregistered)
Oh my god it is full of code

Re: The "Who Knows?" Code

2009-12-02 09:06 • by Rene (unregistered)
The person who produced this code is a true genius!

Re: The "Who Knows?" Code

2009-12-02 09:06 • by frits (unregistered)
That is a work of art.

Re: The "Who Knows?" Code

2009-12-02 09:06 • by Alargule (unregistered)
At least it's properly indented.

Re: The "Who Knows?" Code

2009-12-02 09:07 • by Osno (unregistered)
So, is some brave soul going to run that and see what it does?

Re: The "Who Knows?" Code

2009-12-02 09:09 • by Grovesy
292060 in reply to 292059
Easy, just look at the unit tests, they should tell you what the code does.

Re: The "Who Knows?" Code

2009-12-02 09:09 • by Pragmatopian (unregistered)
a system used daily by scores of users daily


Evidently not a system to check for duplicated modifiers!

Re: The "Who Knows?" Code

2009-12-02 09:10 • by ounos
I didn't want to see this. Life is meaningless now. I want to die.

Re: The "Who Knows?" Code

2009-12-02 09:10 • by Inhibeo (unregistered)
My guess? This is an incredibly clever quine.

Re: The "Who Knows?" Code

2009-12-02 09:11 • by ounos
Please don't tell me this is looking for duplicates!!!

Re: The "Who Knows?" Code

2009-12-02 09:12 • by Steenbergh (unregistered)
OMG!!! And I thought the code here was bad...

Re: The "Who Knows?" Code

2009-12-02 09:13 • by CaptainOblivious
if m(1) = m(2) = m(3) = ... = m(15) = 15, then this code would find all permutations of the numbers 1 through 15, wouldn't it?

Re: The "Who Knows?" Code

2009-12-02 09:14 • by rocco (unregistered)
Basic code full of GoTo statements and layers of embedded loops with exits... and no comments. VB doesn't need to be this way. *sigh* It makes me sad to see justification for the anti-VB rants.

Re: The "Who Knows?" Code

2009-12-02 09:15 • by md5sum
TRWTF is that apparently Vladmir had the incredible, once-in-a-lifetime opportunity to do a full rewrite of a legacy application, and just sent it to hell by copying and pasting the code that he didn't know what did into the shiny new app...

Re: The "Who Knows?" Code

2009-12-02 09:15 • by DOA
292069 in reply to 292060
Grovesy:
Easy, just look at the unit tests, they should tell you what the code does.
Funniest comment this week.

Re: The "Who Knows?" Code

2009-12-02 09:17 • by Zapp Brannigan (unregistered)
I bet a dime this was done by a COBOL programmer learning VB.

Re: The "Who Knows?" Code

2009-12-02 09:17 • by MC (unregistered)
If you scroll up and down really fast you can see a sailboat!

Re: The "Who Knows?" Code

2009-12-02 09:17 • by PSX (unregistered)
Wait... *jump into* a for loop? But... ha- ... whu- ... how is this even possible?

Re: The "Who Knows?" Code

2009-12-02 09:19 • by Name (unregistered)
I hope the developer followed the arrow created by that code.

Exit Stage Right.

Re: The "Who Knows?" Code

2009-12-02 09:20 • by Wladimir (unregistered)
I'm not the submitter but this seems to generate all possible combinations of i1,i2,i3 where i1,i2,i3 are natural numbers between 1 and m(1),m(2),m(3) respectively. Only that there aren't a just three but 16 variables. Let's hope that most m() values are zero, the number of combinations grows exponentially. Otherwise - yes, some people never get recursion. And - sure, you can "flatten" every recursive algorithm assuming the depth is limited.

Re: The "Who Knows?" Code

2009-12-02 09:22 • by Crash Magnet (unregistered)
The guy who wrote this is a genius. This is a prime example why you should never let a genius anywhere near your code.

Re: The "Who Knows?" Code

2009-12-02 09:25 • by Ren
This looks awesome. But we'd need the m(x) values to make sense, sorry :(

Could the original poster come clean about the approximate return values of the m() function?

Re: The "Who Knows?" Code

2009-12-02 09:25 • by Martin (unregistered)
292077 in reply to 292074
"And - sure, you can "flatten" every recursive algorithm assuming the depth is limited."

You can turn any recursive algorithm into an iterative one without any assumptions. You just need to maintain your own stack.

Re: The "Who Knows?" Code

2009-12-02 09:29 • by csdx (unregistered)
I got as far as figuring that it loops over i1 through i16, and before each loop it's checking to see if the number it's using as a max value m(1)-m(16) is 0, if it is, it skips the for statement (and the next statement at the end). Then it does some sort of checking to make sure some things don't equal each other and then creates a combination array that the sum of everything. Why it does any of this is still a mystery.

Re: The "Who Knows?" Code

2009-12-02 09:29 • by - (unregistered)
292079 in reply to 292068
md5sum:
TRWTF is that apparently Vladmir had the incredible, once-in-a-lifetime opportunity to do a full rewrite of a legacy application, and just sent it to hell by copying and pasting the code that he didn't know what did into the shiny new app...


See above for truth.

Crash Magnet:
The guy who wrote this is a genius. This is a prime example why you should never let a genius anywhere near your code.


Yeah, I hate smart peop... Wait, no, it's you I hate.

Re: The "Who Knows?" Code

2009-12-02 09:32 • by highphilosopher (unregistered)
292080 in reply to 292072
PSX:
Wait... *jump into* a for loop? But... ha- ... whu- ... how is this even possible?


It's VB man, you can jump in anywhere you want.


So I was sitting there getting ready to read TDWTF when just as I clicked the title of the latest post, Marcy Playground's "Vampires of New York" started on grooveshark <shamelessplug>LOVE GROOVESHARK!!!</shamelessplug>, at the same time I read the first sentence...

"When Vladimir first received his orders, the blood drained from his face."

Between the "Vampires of New York" song, the name VLAD-imir and the reference to draining blood I got the funniest image in my head of a somewhat comical vampire programmer named Vladimir (obviously a cover name). In retrospect, explaining a funny image in your head does not work well in a WTF comment post does it?

Captcha: genitus -- Not touching this one with a ten foot pole.

Re: The "Who Knows?" Code

2009-12-02 09:34 • by Prosthetic Lips (unregistered)
292081 in reply to 292072
PSX:
Wait... *jump into* a for loop? But... ha- ... whu- ... how is this even possible?


He jumps into the for loop, but then jumps OUT using the same condition. Even though m(x) is zero, he still assumes a minimum of 1. I think my first revision would be to find some way around the goto's with maybe a "... to max(m(1), 1)" instead, and see how it cleans up the code.

catcha: amet - using it in a sentence, "It's good to be amet" (baseball team).

Re: The "Who Knows?" Code

2009-12-02 09:36 • by Mike Caron (unregistered)
Surely I'm not the only one who is wondering how he managed to paste a bunch of BASIC into a C++ source file and still have it work, am I?

Then again, no one said it still compiled...

Re: The "Who Knows?" Code

2009-12-02 09:38 • by Patrick (unregistered)
It generates combinations of numbers, in sixteen two-digit blocks, where no two blocks are alike. It then stores them in a collection, presumably to be retrieved at random. This is a key generator for either licensing or encryption.

The code could be a lot cleaner than that, though.

Re: The "Who Knows?" Code

2009-12-02 09:40 • by csdx (unregistered)
292085 in reply to 292066
if m(1) = m(2) = m(3) = ... = m(15) = 15, then this code would find all permutations of the numbers 1 through 15, wouldn't it?

Actually with everything at 15, the code would basically do nothing. At each for loop, there's an if statement checking if the current iteration is equal to any other iteration, and exiting the loop if it does. So with only 15 possible values (1-15) there isn't any way the code will ever get to the innermost statement since there are 16 variables which need to be unique to get there.

If m(1) =...= m(15) = 16, then I beleive this should return the sum of the numbers of 1 through 16. It just would have to execute something on the order of 16^16 loops to do so.

Re: The "Who Knows?" Code

2009-12-02 09:40 • by Crash Magnet (unregistered)
292086 in reply to 292079

[quote user="Crash Magnet"]The guy who wrote this is a genius. This is a prime example why you should never let a genius anywhere near your code.
[/quote]

Yeah, I hate smart peop... Wait, no, it's you I hate.[/quote]

You need genius to solve problems nobody else can. I don't hate 'em. In fact, they are fun people to be around.

As for your feeling for me, get in line.

Re: The "Who Knows?" Code

2009-12-02 09:43 • by Daan (unregistered)
Ahh... this code brings back good memories.

See? It looks just like the Homeworld Hiigaran mothership. Good times were had with her.

Re: The "Who Knows?" Code

2009-12-02 09:46 • by Stark (unregistered)
I was trying to follow along, but after I got past i10, I began to feel a little i11.

Re: The "Who Knows?" Code

2009-12-02 09:48 • by artie (unregistered)
292089 in reply to 292071
it's not a sailboat, it's a schooner. Stupid!

Re: The "Who Knows?" Code

2009-12-02 09:48 • by jim (unregistered)
292090 in reply to 292082
Well, obviously he must have spent an afternoon porting it, line for line, trying not to introduce any bugs.



also: shouldn't he have just checked the VC commit log?

Re: The "Who Knows?" Code

2009-12-02 09:48 • by Neville Flynn (unregistered)
The goggles, they don't work!!

Re: The "Who Knows?" Code

2009-12-02 09:48 • by noone (unregistered)
1. I guarantee that there is at least one bug in this code.

2. +1 for using "uplift". :-)

captcha: saepius. Opposite of sapient. See code above.

Re: The "Who Knows?" Code

2009-12-02 09:48 • by Oded (unregistered)
Its not that bad. Its just a (very) weird way of printing all the possible combinations of 1..m(1..16) (resulting in a two dimensional matrix). with the caveat that m(n) might be 0 so you have to take that into consideration.

On the face of it it looks like some sort of scorecard generator for a "lotto" style betting game.

Re: The "Who Knows?" Code

2009-12-02 09:52 • by Zylon
My god... it's as if Duff's Device fell into a black hole, merged with an alien AI, then came back to Earth centuries later demanding to speak with its creator.

Re: The "Who Knows?" Code

2009-12-02 09:54 • by OMG (unregistered)
292095 in reply to 292082
Mike Caron:
Surely I'm not the only one who is wondering how he managed to paste a bunch of BASIC into a C++ source file and still have it work, am I?


I was wondering this as well, but my working hypothesis is that the current verison of Migrantsoft(R) Vicious(C) Student(C)(R)(TM) lets you paste in code from any Migrantsoft(C) language, and translates it to Mangled(TM) C+/-(R) at runtime. Happy happy joy joy that I get to stay blissfully unaware of such horrors.

Re: The "Who Knows?" Code

2009-12-02 09:55 • by BSDGuy (unregistered)
292096 in reply to 292088
You lost me at:


If m(1) = 0 Then GoTo i2
For i1 = 1 To m(1)
....
Next...


At first I was like...oh, just use a case statement, but the motive of the code is...somewhere.

TRWTF is that buddy-boy copied and pasted code that he doesn't understand...that makes less sense than this code.

Then again, this code reminds me of Jolitz's TCP stack code! Fast, but WTF does it do?

Re: The "Who Knows?" Code

2009-12-02 09:56 • by Anonymous Organ Donor (unregistered)
292097 in reply to 292091
Neville Flynn:
The goggles, they don't work!!

The goggles, they don't work???
Sorry... But... it's "The goggles, they do nothing!" - it's painful, like having my 6 year old use bad grammar, I have to correct her

Re: The "Who Knows?" Code

2009-12-02 09:56 • by SR (unregistered)
292098 in reply to 292060
:oD Now you owe me a fresh coffee and a new monitor.

Re: The "Who Knows?" Code

2009-12-02 09:56 • by SR (unregistered)
292099 in reply to 292060
I meant:

Grovesy:
Easy, just look at the unit tests, they should tell you what the code does.


:oD Now you owe me a fresh coffee and a new monitor.

Re: The "Who Knows?" Code

2009-12-02 09:59 • by blindio (unregistered)
292100 in reply to 292076
Ren:
This looks awesome. But we'd need the m(x) values to make sense, sorry :(

Could the original poster come clean about the approximate return values of the m() function?


I think, actually, that m is an array. so it's just someone stepping through an array and as soon as a non-zero value repeats it exits the loop, if all values are 0 than it formats the values of the i values as two digit numbers. it's really quite.... magnificent, like car accidents on CHiPs.

They appear to be using the for loops to assign the value at each position in the m array to the i values. Looks like someone didn't understand arrays maybe?

Re: The "Who Knows?" Code

2009-12-02 10:16 • by Rootbeer
Real WTFs:

1. Giving the same developers that wrote bad VB5 code the task of rewriting it in C++, and expecting the result to be anything other than equally-bad C++ code.

2. The source control system that can tell you who has made changes to the code, but not which changes they made.


Re: The "Who Knows?" Code

2009-12-02 10:16 • by BD (unregistered)
292102 in reply to 292095
OMG:
Migrantsoft(R) Vicious(C) Student(C)(R)(TM) lets you paste in code from any Migrantsoft(C) language, and translates it to Mangled(TM) C+/-(R)

Oh, aren't you just precious.

Re: The "Who Knows?" Code

2009-12-02 10:17 • by Mz Name? (unregistered)
292103 in reply to 292097
Anonymous Organ Donor:
Neville Flynn:
The goggles, they don't work!!

The goggles, they don't work???
Sorry... But... it's "The goggles, they do nothing!" - it's painful, like having my 6 year old use bad grammar, I have to correct her


Maybe a psychotherapist can help you to stop suffering from that pain.

« PrevPage 1 | Page 2 | Page 3 | Page 4 | Page 5Next »

Add Comment