• Gramma (unregistered)

    Oh isn't that just precious.

  • Thg (unregistered) in reply to Pragmatopian
    Pragmatopian:
    a system used daily by scores of users daily

    Evidently not a system to check for duplicated modifiers!

    Evidently not a system to check for duplicated modifiers, Evidently!

  • Dave (unregistered) in reply to Anonymous Organ Donor
    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
    Sorry... But... it's "My eyes! The goggles do nothing!"
  • Charles400 (unregistered)

    Dan Brown just cracked the code. Buried inside is Carmen Electra's phone number.

  • (cs) in reply to Daan
    Daan:
    See? It looks just like the Homeworld Hiigaran mothership.

    I thought this too, and I didn't even play Homeworld that much!

  • bnx (unregistered) in reply to Anonymous Organ Donor
    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

    "My eyes! The googles do nothing!"

    http://en.wikipedia.org/wiki/Radioactive_Man_%28The_Simpsons_episode%29

  • Tiresias (unregistered)

    Kinda ASCII art :-)

  • (cs)

    I was going to say that it is a Duff's Device, except bigger and better, but:

    If m(1) = 0 Then GoTo i2 
      For i1 = 1 To m(1) 
    i2: If m(2) = 0 Then GoTo i3 
    etc
    

    Isn't this in effect the same as

    For i1 = 0 To m(1)
    

    etc.?

  • SR (unregistered) in reply to Tiresias
    Tiresias:
    Kinda ASCII art :-)

    A load of Jackson Pollocks maybe

  • Patrick (unregistered) in reply to Dave
    Dave:
    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
    Sorry... But... it's "My eyes! The goggles do nothing!"

    THANK You! I really HATE it when people get it wrong like that!

  • undefined (unregistered)

    TRWTF is C++ as target language. Why they need to rewrite application to worser language than original?

  • c-- (unregistered)

    c++ version: http://pastebin.com/f39ca0e55

  • anon (unregistered)

    The time has come for an obfuscated VB contest... It's too easy to "[http://www.ioccc.org/years.html]do it in C[/url]"

  • (cs) in reply to Zylon
    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.

    This is more like a "Duff Beer Device".

  • (cs)

    The coder was OBVIOUSLY an artist trying to create an ASCII right-parenthesis )

  • Your Name (unregistered)

    Looks like automatically translated code that someone ran through an automatic formatter.

  • (cs) in reply to Rodnas
    Rodnas:
    Oh my god it is full of code
    :) thanks for that, i lol'd
  • (cs) in reply to SR
    SR:
    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.

    Prehapes this is what can happen if you follow TDD to the extreme...

    Keep writing if statements till all tests cases pass.

  • anon (unregistered)

    The only true bug I can find is that after the line "kom = kom+1" there should be a line reading

    If m(16)=0 Then GoTo n16

    so that "Next i16" is skipped if "For i16 ..." is skipped.

    If m(1)=0, then i1 is never initialised; presumably the full code initialises i1, ..., i16 (and kom) to something sensible.

    I think the code is supposed to do this:

    Select all permutations of 16 numbers where the nth number is between 1 and m(n) (unless m(n)=0, in which case the nth number is equal to some default value), subject to the constraint that none of the numbers chosen be equal (unless m(n)=0, in which case the default value is chosen whether or not it is equal to one of i1, ..., i[n-1]; but none of i[n+1], ..., i16 can be equal to the default value (unless they also take their default value)).

    The format used suggests that m(n) should be between 0 and 99 inclusive.

  • PinkFloyd (unregistered)

    I remember this code from the old days, now you would simply use the getDate() method!

  • c0rnh0l10 (unregistered) in reply to Patrick
    Patrick:
    This is a key generator for either licensing or encryption.
    The perfect copy protection: This code is simply too ugly to be incorporated in a keymaker.
  • PinkFloyd (unregistered) in reply to csdx

    The real WTF are these guy's actually trying out where things are incorrect in the code! How much time are you wasting with that! You are fired!

  • Anonymous (unregistered) in reply to Anonymous Organ Donor
    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
    Then your six year old must be a retard because you are completely wrong. Muphry, anyone?
  • (cs) in reply to MC
    MC:
    If you scroll up and down really fast you can see a sailboat!
    You dumb bastard, it's a schooner not a sailboat!
  • Pink Floyd (unregistered) in reply to Martin
    Martin:
    You can turn any recursive algorithm into an iterative one without any assumptions. You just need to maintain your own stack.
    I'm alright, Jack, keep your hands off my stack.
  • Patrick (unregistered)

    OK, so curiosity got the better of me and I looked again in the comments for a better solution. Nada. Apparently no-one else could read it. So here it is:

    Private Sub Dude(ByVal depth As Integer, ByRef m() As Integer, ByRef i() As Integer, ByRef combination As Collection)
    	For i(depth) = 0 To m(depth)
    		For u = 0 To depth - 1
    			If i(u) = i(depth) Then Exit Sub
    		Next
    		If depth = UBound(m) Then
    			Dim s As String
    			s = ""
    			For c = depth To 0 Step -1
    				s = s + Format(i(c), "00")
    			Next
    			combination.Add(s)
    		Else
    			Dude(depth + 1, m, i, combination)
    		End If
    	Next
    	i(depth) = m(depth)
    End Sub
    
    Private Sub CalculateTheNumbers(ByVal numbers As Integer, ByVal maxnumber As Integer, ByRef combination As Collection)
    	Dim m() As Integer
    	Dim i() As Integer
    	ReDim m(numbers - 1)
    	ReDim i(numbers - 1)
    	For d = 0 To numbers - 1
    		m(d) = maxnumber
    	Next
    	Dude(0, m, i, combination)
    End Sub
    
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    	Dim combination As New Collection
    	CalculateTheNumbers(16, 20, combination)
    	For Each c In combination
    		ListBox1.Items.Add(c)
    	Next
    End Sub
    

    I kept it in VB6 just because, but it would have been easier in something else.

    Having seen the result, it looks like it's a lottery number generator. 16 two-digit numbers with no duplicates and only in ascending order.

  • highphilosopher (unregistered) in reply to undefined
    undefined:
    TRWTF is C++ as target language. Why they need to rewrite application to worser language than original?

    Ok, I don't think anyone LIKES c++, but worse than VB??? Really? You Really think so?

  • some other dude (unregistered) in reply to BD
    BD:
    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.

    awww how cute! you get all offended when someone pokes fun at the only stuff you know!

    your insecurity is showing.

  • Anonymous (unregistered) in reply to Patrick
    Patrick:
    OK, so curiosity got the better of me and I looked again in the comments for a better solution. Nada. Apparently no-one else could read it. So here it is: <snipped code>

    Having seen the result, it looks like it's a lottery number generator. 16 two-digit numbers with no duplicates and only in ascending order.

    A lottery with 16 numbers? Doesn't sound very likely to me. Lotteries don't usually go above 8 numbers or so because more numbers makes it appear to be less fair to numerically challenged individuals (ie. all lottery players). Obviously, the actual chance of winning is also dependant on the size of the set (the maximum value of each ball). But remember, these are lottery players, ie. idiots.

  • Anonymous (unregistered) in reply to undefined
    undefined:
    TRWTF is C++ as target language. Why they need to rewrite application to worser language than original?
    I nominate this comment for the "most incompetent troll of the day" award. So painfully obvious.
  • Henning Makholm (unregistered) in reply to anon
    anon:
    Select all permutations of 16 numbers where the nth number is between 1 and m(n) (unless m(n)=0, in which case the nth number is equal to some default value), subject to the constraint that none of the numbers chosen be equal (unless m(n)=0,
    No -- subject to the constraint that the numbers are decreasing except for zeroes. Whenever a match with something is fount, that entire level of loop is broken out of, so no in ever gets a value that is higher than any of its predecessors.

    I'm assuming that the in's start out zero or undefined. (Anything else would be too horrible).

    Then all of the long disjunctions can be replaced by comparing once against "the i of the innermost enclosing loop where m(.) is nonzero". And then the entire thing can be made infinitely more readable by using recursion instead of nesting.

  • Patrick (unregistered) in reply to Anonymous
    Anonymous:
    Patrick:
    Having seen the result, it looks like it's a lottery number generator. 16 two-digit numbers with no duplicates and only in ascending order.
    A lottery with 16 numbers? Doesn't sound very likely to me. Lotteries don't usually go above 8 numbers or so because more numbers makes it appear to be less fair to numerically challenged individuals (ie. all lottery players). Obviously, the actual chance of winning is also dependant on the size of the set (the maximum value of each ball). But remember, these are lottery players, ie. idiots.

    "looks like". Can you think of any other reason to keep the numbers in ascending order (other than "by accident", of course)?

    But, since we don't know the initial values of the m array, it's entirely possible it has a completely unrelated purpose. We also don't know where that data ends up. That's another thing, was that function even being used at all, or was it just a relic of something used only once?

  • Bim Job (unregistered) in reply to Patrick
    Patrick:
    OK, so curiosity got the better of me and I looked again in the comments for a better solution. Nada. Apparently no-one else could read it. So here it is:
    Private Sub Dude(ByVal depth As Integer, ByRef m() As Integer, ByRef i() As Integer, ByRef combination As Collection)
    	For i(depth) = 0 To m(depth)
    		For u = 0 To depth - 1
    			If i(u) = i(depth) Then Exit Sub
    		Next
    		If depth = UBound(m) Then
    			Dim s As String
    			s = ""
    			For c = depth To 0 Step -1
    				s = s + Format(i(c), "00")
    			Next
    			combination.Add(s)
    		Else
    			Dude(depth + 1, m, i, combination)
    		End If
    	Next
    	i(depth) = m(depth)
    End Sub
    
    Private Sub CalculateTheNumbers(ByVal numbers As Integer, ByVal maxnumber As Integer, ByRef combination As Collection)
    	Dim m() As Integer
    	Dim i() As Integer
    	ReDim m(numbers - 1)
    	ReDim i(numbers - 1)
    	For d = 0 To numbers - 1
    		m(d) = maxnumber
    	Next
    	Dude(0, m, i, combination)
    End Sub
    
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    	Dim combination As New Collection
    	CalculateTheNumbers(16, 20, combination)
    	For Each c In combination
    		ListBox1.Items.Add(c)
    	Next
    End Sub
    

    I kept it in VB6 just because, but it would have been easier in something else.

    Having seen the result, it looks like it's a lottery number generator. 16 two-digit numbers with no duplicates and only in ascending order.

    I believe you are under a misapprehension. This algorithm is clearly intended for implementation in ValSpeak. Here's my first shot at it:
    Private Sub DudeInValley depth As If, like m() As If, like I() As If, like duh! As If)
    For why?
    So totally, for why?
    What-ever!
    Like, Next
    Like, Next

    As if, Deep
    	Like, Dim
    	For why?
    		I know, right?
    	Else something
    OK?
    Deep, like, deep
    

    Dude, duh!

    ‘ Totes …

    Major Dude (like numers As If, like maxnumber, duh!, like What-ever, like, So Totally) Like, Dim I – As If Like , Dim M – As If

    OK, Dim M As If, or something
    Dude, Dim M, totally
    
    Worst. Code. Evah!
    Dude(0, m, i, combination)
    

    Why?

    A suitable abstraction of Greenspun's Tenth Law should turn this into perfectly acceptable Common Lisp.

  • (cs) in reply to Patrick
    Patrick:
    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.
    I thought the same thing when I saw the innermost part assembling the two-digit blocks.
    Patrick:
    The code could be a lot cleaner than that, though.
    ...which would soundly destroy any security gained through this obscurity.
  • A Gould (unregistered) in reply to md5sum
    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...

    I can sympathize: if you can't figure out what the hell it's doing, or why, but you know you need it, what else do you do? (And you don't always have the time necessary to puzzle it out).

    All you can do it move the code over, and put big WARNING comments around it.

  • Patrick (unregistered) in reply to Bim Job
    Bim Job:
    This algorithm is clearly intended for implementation in ValSpeak.
    HAHA. That almost looks like a real language. VB Valgol.

    And yes, it's deliberately bad code inspired by previous WTFs, thanks for noticing.

  • Sanderman (unregistered)

    TRWTF is commenters flaming on C++. Just because you can't understands some of it's more complex aspects is no reason to depict it as being worse than VB, which one of the most abused languages in existance.

    Another WTF is that they choose to refactor the app to C++ while a higher abstracted and more maintainable language like java and (shudder) .NET and possibly python and ruby are much more suited to business logic.

    Using C or C++ is pretty much overkill for anything that doesn't require high performance. On the other hand, C is great for drivers and C++ is great for simulations, games and other high performance computing.

  • (cs) in reply to highphilosopher
    highphilosopher:
    undefined:
    TRWTF is C++ as target language. Why they need to rewrite application to worser language than original?

    Ok, I don't think anyone LIKES c++, but worse than VB??? Really? You Really think so?

    Oh, definitely. C++ may not be the worst programming language ever created, but without a doubt it's the worst ever to be taken seriously.

  • (cs) in reply to Patrick
    Patrick:
    Bim Job:
    This algorithm is clearly intended for implementation in ValSpeak.
    HAHA. That almost looks like a real language. VB Valgol.

    And yes, it's deliberately bad code inspired by previous WTFs, thanks for noticing.

    Valgol kinda reminds me of LOLCODE (another esoteric language)

    e.g http://en.wikipedia.org/wiki/LOLCODE

    HAI CAN HAS STDIO? IM IN YR LOOP UPPIN YR VAR TIL BOTHSAEM VAR AN 10 VISIBLE SUM OF VAR AN 1 IM OUTTA YR LOOP KTHXBYE
  • (cs) in reply to highphilosopher
    highphilosopher:
    undefined:
    TRWTF is C++ as target language. Why they need to rewrite application to worser language than original?

    Ok, I don't think anyone LIKES c++, but worse than VB??? Really? You Really think so?

    There are only two kinds of languages: the ones people complain about and the ones nobody uses. Bjarne Stroustrup

  • (cs) in reply to Zylon
    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.

    Which is sadder: that you spent time and effort making a Star Trek: The Motion Picture reference, or that I understood it?

  • Franz Kafka (unregistered) in reply to Mz Name?
    Mz Name?:
    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.

    I was thinking about an english teacher, myself.

  • Gary (unregistered)

    This is the first time I've commented on this site. I had to. This code made me say "WTF" out loud. It's a good thing no one heard me.

    This is truly awful. I thought getting 30 tons of coal delivered was hilarious, but this is better. Anyone who can code like this should be able to do it simpler.

    How does code like this get past a peer review?

  • (cs) in reply to Someone You Know
    Someone You Know:
    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.

    Which is sadder: that you spent time and effort making a Star Trek: The Motion Picture reference, or that I understood it?

    The saddest thing is that either could be considered sad on a forum that should be populated by geeks, rather than clone-stamped corporate code monkeys.

  • (cs) in reply to Mason Wheeler

    Ugh. How predictable... people get bored and stoop to pointless language bashing.

    Anyway: 1) Surely he didn't paste the VB code into his C++ code, but rather translated it from one to the other (perhaps without understanding it).

    1. Wouldn't "svn blame" do what he needed? Then again, they were probably using (shudder) Visual SourceSafe.
  • mh (unregistered) in reply to Mike Caron
    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?

    #define! Let's implement VB6 in the C++ preprocessor!

  • (cs)

    Dijkstra was understating - looking at that, "harmful" doesn't begin to describe it.

    Visual SourceSafe.

    I would like to tell myself you made that name up, but it does sound like an actual MS product.

  • (cs) in reply to Dave
    Dave:
    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
    Sorry... But... it's "My eyes! The goggles do nothing!"

    This comment is the winner. I would like to add one internet to your score. I am laughing out loud.

  • Zapp Brannigan (unregistered) in reply to DCRoss
    DCRoss:
    MC:
    If you scroll up and down really fast you can see a sailboat!
    You dumb bastard, it's a schooner not a sailboat!
    I don't see it. It looks like a booby to me.
  • fred (unregistered) in reply to ounos

    I poked out my eyes out, jut so could be sure not to see that code more

Leave a comment on “The "Who Knows?" Code”

Log In or post as a guest

Replying to comment #292133:

« Return to Article