- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
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'.
Admin
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.....
Admin
Admin
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.
Admin
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.
Admin
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.
Admin
Admin
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)...
Admin
Roll it 100,000 times and get back to us.
Admin
Once I discovered a similar code in a PHP project I had to maintain:
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.
Admin
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.
Admin
Once discovered, large even primes could become very important as well.
Admin
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
Admin
Because we READ the whole article.
Admin
Is there something I don't understand about the code? I read thirteen cases and and else... making fourteen chances.
Admin
TRWTF is of course
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).
Admin
Math is rigged obviously. ;)
(And this guy a "genious". Doh!)
Admin
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.
Admin
Obviously, they should have used a crypto hardware random number generator: after all, having a really random header image is critical for a website.
Admin
Obviously, they should have used a crypto hardware random number generator: after all, having a really random header image is critical for a website.
Admin
Obviously, they should have used a crypto hardware random number generator: after all, having a really random header image is critical for a website.
Admin
2 is a large even prime when when you're doing non-standard analysis.
Admin
Admin
Ever heard of triple or even quadruple ROT13?
Admin
Admin
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)?
Admin
Right. Do that a thousand times, and see if you say the same thing.
Admin
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.
Admin
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...
Admin
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.
Admin
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.
Admin
LAAAAAAAAAAAAAAAASSSSSST!
Admin
Oh, those Krauts!
Admin
Only Schneier can do that.
Admin
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.
Admin
That makes 3 random comments
Admin
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
Admin
This guy is effing crazy!
Admin
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.
Admin
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.
Admin
Random numbers are always a good chance for math illiteral people to show their incompetence.
Admin
As opposed to just plain illiterATE?