• Nitpicker (unregistered)

    The sad thing is, there's actually 14 cases...

    Case 0 through Case 12 = 13 Case Else = 14

    I only had to read it through 4 times to see it too.... I still couldn't figure out a rational reason why tho'.

  • Nobody (unregistered) in reply to Nitpicker
    Nitpicker:
    The sad thing is, there's actually 14 cases...

    Case 0 through Case 12 = 13 Case Else = 14

    I only had to read it through 4 times to see it too.... I still couldn't figure out a rational reason why tho'.

    Seems to me that case 0 will never be hit, though, since the MinNumber passed to the random function is hard-coded to 1. Unless, of course, I'm missing something.... Just one more WTF in the pile.....

  • (cs) in reply to XioPod
    XioPod:
    thirteenth!!!1!!11
    SIXTYYY FOOOUUURRR!11!!1!
  • (cs) in reply to Andreas
    Andreas:
    Harking back to the time when I cared about such things: the least significant bits of a certain class of pseudo random generators are less random that the full stream (If you really want to know, read Knuth's "The Art of Computer Programming", Vol 2)
    Absolutely. Back when I was learning to program in C in the mid 1980's I once wrote a program which needed to simulate a random coin toss. I used the standard library rand function something like so:
    int n ;
    n = rand () % 2 ;
    

    I couldn't figure out why I only ever got two different sets of results until I started printing the results of my "random" number generator. There were only two sequences:

    0, 1, 0, 1, 0, 1....

    and

    1, 0, 1, 0, 1, 0....

    That's when I realised the importance of large odd primes in computer science.

  • Say what? (unregistered)

    Usually these code fragments induce a good laugh, or a smack to the face while mumbling "oh my God"...

    This one actually made my mouth fall open, while scrolling back and forward trying to understand what the author was thinking, and my mind went simply numb.

    It still is.

  • I'm a humbler guy than you will ever be (unregistered) in reply to DWalker59
    DWalker59:
    Wonko the sane: Strange dice have you, with no spots on one side... but why would the side with no spots (which is obviously heavier) come up on top so much of the time?

    Ponder this, we must.

    Er, perhaps this is just a joke that I'm not getting, but I think the reason zeroes are turning up is that there is a modulus in there. R1*R2 % 6 will turn up as zero when one of the two comes out as six as well as when one is two or four and the other is three. That's 11 + 4 = 15 occurences, just like he posted.

  • (cs) in reply to DWalker59
    DWalker59:
    Wonko the sane: Strange dice have you, with no spots on one side... but why would the side with no spots (which is obviously heavier) come up on top so much of the time?

    Ponder this, we must.

    The side with no spots is the lightest, because it doesn't have that paint weighing it down like the others do.

  • dag (unregistered)

    Apart from the WTFiness regarding the random number generation I especially appreciate that he swapped the order of arguments from the .NET function, then inserted code for the 'error' case (min > max)...

  • (cs) in reply to Wonko the sane
    Wonko the sane:
    and the results were 1's - 2 2's - 6 3's - 5 4's - 6 5's - 2 0's - 15

    Not an even mix is it...

    Roll it 100,000 times and get back to us.

  • (cs)

    Once I discovered a similar code in a PHP project I had to maintain:

        $zufall = rand(1,10);
        if (($zufall==1) or ($zufall==10)){ ?>
            Partner
           <? }elseif (($zufall==2) or ($zufall==9)){ ?>
            Partner
           <? }elseif (($zufall==3) or ($zufall==8)){ ?>
            Partner
           <? }elseif (($zufall==4) or ($zufall==7)){ ?>
            Partner
           <? }elseif (($zufall==5) or ($zufall==6)){ ?>
            Partner
        <? } ?>
    

    If you draw only one ball out of the urn, it will surely be more ramdom, when you have all numbers twice in it. Besides, it makes much sense to link # to target=_blank.

  • (cs)

    You are all missing the true genious of this code.

    The more randomness exists not in the RandomNumber method nor the number of cases generated. No, the trick which there will be some benefit reading lies in the shuffling of case statements. 13 cases, with two possible values gives 8192 possible permutations of which this is one. Nothing could be more random than that.

  • Your Name (unregistered) in reply to jeremypnet
    jeremypnet:
    That's when I realised the importance of large odd primes in computer science.

    Once discovered, large even primes could become very important as well.

  • (cs) in reply to chrome
    chrome:
    Wonko the sane:
    and the results were 1's - 2 2's - 6 3's - 5 4's - 6 5's - 2 0's - 15

    Not an even mix is it...

    Roll it 100,000 times and get back to us.

    I would expect a table along these lines: 1's - 5555 2's - 16667 3's - 13889 4's - 16667 5's - 5555 0's - 41667

  • (cs) in reply to Cowbert
    Cowbert:
    How do we know this wasn't originally built with 13 different images that were supposed to be rotating, but gradually got replaced down to 2? (Think banner ad rotation).

    Captcha: ingenium (is this the new version of 'brillant'?)

    Because we READ the whole article.

  • anony-mouse (unregistered)

    Is there something I don't understand about the code? I read thirteen cases and and else... making fourteen chances.

  • Flotter (unregistered)

    TRWTF is of course

    Dim r As New Random(System.DateTime.Now.Millisecond)

    That should only be done once. If you generate two (or more) numbers whithin a millisecond they will all be the same (that doesn't seem very random to me).

  • Godot (unregistered) in reply to Proko
    Proko:
    Well, I know a guy who tried to explain that using: (random(max_number)*random(max_number)) mod max_number is much more random usage then simply random(max_number). He didn't even care when one other guy proved mathematicly, that he was totally wrong.

    Math is rigged obviously. ;)

    (And this guy a "genious". Doh!)

  • Proko (unregistered) in reply to Wonko the sane

    Yeah, that was the point and that was why we argued with him about it. If that equation would be working and simply would have taken little more time, then it would have been ok( couple of milliseconds, who actually cares so much, specially when I presume he's code is not good in other parts either). But it didn't work because the distribution of number is not even close equal. 0 is always most probable result.

  • EPE (unregistered)

    Obviously, they should have used a crypto hardware random number generator: after all, having a really random header image is critical for a website.

  • EPE (unregistered)

    Obviously, they should have used a crypto hardware random number generator: after all, having a really random header image is critical for a website.

  • EPE (unregistered)

    Obviously, they should have used a crypto hardware random number generator: after all, having a really random header image is critical for a website.

  • Paolo G (unregistered) in reply to Your Name
    Your Name:
    jeremypnet:
    That's when I realised the importance of large odd primes in computer science.

    Once discovered, large even primes could become very important as well.

    2 is a large even prime when when you're doing non-standard analysis.

  • Ilya Ehrenburg (unregistered) in reply to Paolo G
    Paolo G:
    Your Name:
    jeremypnet:
    That's when I realised the importance of large odd primes in computer science.

    Once discovered, large even primes could become very important as well.

    2 is a large even prime when when you're doing non-standard analysis.

    But 2 is an odd prime. It's in fact the oddest prime of all.
  • (cs) in reply to alegr
    alegr:
    Ever heard of triple DES?

    Ever heard of triple or even quadruple ROT13?

  • Roger (unregistered) in reply to ARG
    ARG:
    13 is not random enough. Only 13! Should have done 26 then it would be even more random... oh hold on...
    Don't be silly. 26 isn't a prime!
    Hey, go back to high school. It's two times a prime! That's a lot better!
  • Me (unregistered)

    So, 14 cases for a two case problem, and two of the cases wouldn't come up. Case 0 won't come up because he specified a minimum of 1. Case Else won't come up because he specified a maximum of 0, and the maxvalue is exclusive in the Random.Next(int,int) function, so he generates a number between 1 and 12.

    At least with both of those errors, the chances of returning either image are 6:12, or 50%. So, oddly enough, it does appear to work as intended, if seemingly by pure accident.

    Granted, Me.hl_logo.ImageUrl = IIf(CBool(RandomNumber(0, 2)), "~/sysimages/header.jpg", "~/sysimages/header2.jpg") (presuming I remember VB.Net correctly) would accomplish the same thing in a single line, but of course, how can that beat accomplishing the same task in 32 lines (readability issues aside for you pedants out there)?

  • Thunder (unregistered) in reply to Wonko the sane

    Right. Do that a thousand times, and see if you say the same thing.

  • Thunder (unregistered)

    The best thing about DWTF comments is that they consistently reveal so many people capable of WTF's so much worse than the one originally posted.

  • (cs) in reply to lolwtf
    lolwtf:
    DWalker59:
    Wonko the sane: Strange dice have you, with no spots on one side... but why would the side with no spots (which is obviously heavier) come up on top so much of the time?

    Ponder this, we must.

    The side with no spots is the lightest, because it doesn't have that paint weighing it down like the others do.

    Most dice that I have seen, have concave depressions drilled out where the paint goes. Maybe the paint is supposed to weigh the same as the material that's drilled out...

  • Avish (unregistered)

    I especially like how the different cases are pseudo-uniformly distributed between the two images, so that successive random numbers cases will get different results, thus ensuring true randomness.

  • (cs) in reply to Wonko the sane
    Wonko the sane:
    Proko:
    Well, I know a guy who tried to explain that using: (random(max_number)*random(max_number)) mod max_number is much more random usage then simply random(max_number). He didn't even care when one other guy proved mathematicly, that he was totally wrong.

    I've just tested this with dice...

    OK used a table of 1-6, and 1-6 all combinations...

    and the results were 1's - 2 2's - 6 3's - 5 4's - 6 5's - 2 0's - 15

    Not an even mix is it...

    If you have a dice which has no spots (usually little cavities) on one side, chances are that it is not fully balanced and that, therefore, it should more often fall on the opposite side (the one with one spot on it at the top). Hence, it is not logic at all that you have a ±40% probability to fall on the side with one spot at the bottom). This can only work if your dices are manipulated/tampered.

  • (cs) in reply to T_PAAMAYIM_NEKUDOTAYIM
    T_PAAMAYIM_NEKUDOTAYIM:
    XioPod:
    thirteenth!!!1!!11
    SIXTYYY FOOOUUURRR!11!!1!

    LAAAAAAAAAAAAAAAASSSSSST!

  • (cs) in reply to Aranxo
    Aranxo:
    Once I discovered a similar code in a PHP project I had to maintain:
        $zufall = rand(1,10);
        if (($zufall==1) or ($zufall==10)){ ?>
            Partner
           <? }elseif (($zufall==2) or ($zufall==9)){ ?>
            Partner
           <? }elseif (($zufall==3) or ($zufall==8)){ ?>
            Partner
           <? }elseif (($zufall==4) or ($zufall==7)){ ?>
            Partner
           <? }elseif (($zufall==5) or ($zufall==6)){ ?>
            Partner
        <? } ?>
    

    If you draw only one ball out of the urn, it will surely be more ramdom, when you have all numbers twice in it. Besides, it makes much sense to link # to target=_blank.

    Oh, those Krauts!

  • (cs) in reply to Your Name
    Your Name:
    jeremypnet:
    That's when I realised the importance of large odd primes in computer science.

    Once discovered, large even primes could become very important as well.

    Only Schneier can do that.

  • (cs) in reply to chrismcb
    chrismcb:
    chrome:
    Wonko the sane:
    and the results were 1's - 2 2's - 6 3's - 5 4's - 6 5's - 2 0's - 15

    Not an even mix is it...

    Roll it 100,000 times and get back to us.

    I would expect a table along these lines: 1's - 5555 2's - 16667 3's - 13889 4's - 16667 5's - 5555 0's - 41667

    Where TF do the 0's come from? Do you randomly NOT throw a dice? Or does it fall off the (wooden) table? How come there is never a 6? On my dices there is always a "6". Maybe it's just bad luck.

  • (cs) in reply to EPE
    EPE:
    Obviously, they should have used a crypto hardware random number generator: after all, having a really random header image is critical for a website.

    That makes 3 random comments

  • Olivier de Rivoyre (unregistered) in reply to Wonko the sane
    Wonko the sane:
    OK used a table of 1-6, and 1-6 all combinations...

    and the results were 1's - 2 2's - 6 3's - 5 4's - 6 5's - 2 0's - 15

    This results come from the 36 possible dices results:

    Dice1 Dice2 Result=Mod(d1*d2, 6) 1 1 => 1 2 1 => 2 3 1 => 3 4 1 => 4 5 1 => 5 6 1 => 0 1 2 => 2 2 2 => 4 3 2 => 0 4 2 => 2 5 2 => 4 6 2 => 0 1 3 => 3 2 3 => 0 3 3 => 3 4 3 => 0 5 3 => 3 6 3 => 0 1 4 => 4 2 4 => 2 3 4 => 0 4 4 => 4 5 4 => 2 6 4 => 0 1 5 => 5 2 5 => 4 3 5 => 3 4 5 => 2 5 5 => 1 6 5 => 0 1 6 => 0 2 6 => 0 3 6 => 0 4 6 => 0 5 6 => 0 6 6 => 0

  • Nick Masao (unregistered)

    This guy is effing crazy!

  • dave (unregistered)

    Absolutely hilarious and scary at the same time. It's dipshits like this that make me worry when I board an airplane about whether any morons were involved in coding the systems software.

  • Martin (unregistered)

    Did anyone else notice that the randomizer includes 14 cases, not 13 as noted in the article and subsequent comments?

    There's a WTF right there.

  • Srki (unregistered)

    Random numbers are always a good chance for math illiteral people to show their incompetence.

  • eviljimjafar (unregistered) in reply to Srki
    Srki:
    Random numbers are always a good chance for math illiteral people to show their incompetence.

    As opposed to just plain illiterATE?

Leave a comment on “More Randomer”

Log In or post as a guest

Replying to comment #:

« Return to Article