Click here to Skip to main content
15,885,366 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Weird but not so wonderful Pin
W Balboos, GHB3-Nov-14 8:49
W Balboos, GHB3-Nov-14 8:49 
GeneralHow not to do a countdown Pin
PIEBALDconsult28-Oct-14 12:28
mvePIEBALDconsult28-Oct-14 12:28 
GeneralRe: How not to do a countdown Pin
ZurdoDev31-Oct-14 1:54
professionalZurdoDev31-Oct-14 1:54 
GeneralRe: How not to do a countdown Pin
PIEBALDconsult31-Oct-14 3:23
mvePIEBALDconsult31-Oct-14 3:23 
GeneralRe: How not to do a countdown Pin
ZurdoDev31-Oct-14 3:25
professionalZurdoDev31-Oct-14 3:25 
GeneralRe: How not to do a countdown Pin
PIEBALDconsult31-Oct-14 3:32
mvePIEBALDconsult31-Oct-14 3:32 
GeneralRe: How not to do a countdown Pin
Brisingr Aerowing3-Nov-14 15:49
professionalBrisingr Aerowing3-Nov-14 15:49 
GeneralIt's Primes as far as the eye can see! PinPopular
OriginalGriff27-Oct-14 5:06
mveOriginalGriff27-Oct-14 5:06 
This is the whole of a would-be Tip submitted today:
C#
public class Class1
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter a Number");
            int num = int.Parse(Console.ReadLine());
            for (int i = 1; i <=num ; i++)
            {
                if(i==2)
                    Console.WriteLine(2);

                if (i % 2 != 0)
                {
                    Console.WriteLine(i);
                }
            }

         }
    }

No text, no explanation - the author (I can only assume he works for Mindfire, it's about their level) clearly felt that it spoke for itself.

And boy, does it ever! This, ladies-n-gentlemen, is a Prime Number generator according to the author.
So...I tried it...

According to this code, the prime numbers under 26 are:
1
2
3
5
7
9
11
13
15
17
19
21
23
25
Now, call me old fashioned, but in my day, 9, 15 and 21 were divisible by 3, and both 15 and 25 were divisible by 5...

So which is wrong? The Code? Or the Laws of Mathematics? Only the author can tell... Laugh | :laugh:
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

JokeRe: It's Primes as far as the eye can see! Pin
ZurdoDev27-Oct-14 5:13
professionalZurdoDev27-Oct-14 5:13 
GeneralRe: It's Primes as far as the eye can see! Pin
OriginalGriff27-Oct-14 5:27
mveOriginalGriff27-Oct-14 5:27 
GeneralRe: It's Primes as far as the eye can see! Pin
DaveAuld27-Oct-14 6:22
professionalDaveAuld27-Oct-14 6:22 
GeneralRe: It's Primes as far as the eye can see! Pin
ZurdoDev27-Oct-14 6:24
professionalZurdoDev27-Oct-14 6:24 
GeneralRe: It's Primes as far as the eye can see! Pin
PhilLenoir27-Oct-14 8:38
professionalPhilLenoir27-Oct-14 8:38 
GeneralRe: It's Primes as far as the eye can see! Pin
newton.saber27-Oct-14 9:26
newton.saber27-Oct-14 9:26 
GeneralRe: It's Primes as far as the eye can see! Pin
DaveAuld27-Oct-14 10:26
professionalDaveAuld27-Oct-14 10:26 
GeneralRe: It's Primes as far as the eye can see! Pin
Ian Shlasko27-Oct-14 10:31
Ian Shlasko27-Oct-14 10:31 
GeneralRe: It's Primes as far as the eye can see! Pin
DaveAuld27-Oct-14 10:48
professionalDaveAuld27-Oct-14 10:48 
GeneralRe: It's Primes as far as the eye can see! Pin
Ian Shlasko27-Oct-14 10:51
Ian Shlasko27-Oct-14 10:51 
GeneralRe: It's Primes as far as the eye can see! Pin
DaveAuld27-Oct-14 10:54
professionalDaveAuld27-Oct-14 10:54 
GeneralRe: It's Primes as far as the eye can see! Pin
Ian Shlasko27-Oct-14 10:59
Ian Shlasko27-Oct-14 10:59 
GeneralRe: It's Primes as far as the eye can see! Pin
newton.saber27-Oct-14 11:02
newton.saber27-Oct-14 11:02 
GeneralRe: It's Primes as far as the eye can see! Pin
Ian Shlasko27-Oct-14 11:07
Ian Shlasko27-Oct-14 11:07 
GeneralRe: It's Primes as far as the eye can see! Pin
newton.saber27-Oct-14 11:13
newton.saber27-Oct-14 11:13 
GeneralRe: It's Primes as far as the eye can see! Pin
newton.saber27-Oct-14 11:03
newton.saber27-Oct-14 11:03 
GeneralRe: It's Primes as far as the eye can see! Pin
Ian Shlasko27-Oct-14 5:26
Ian Shlasko27-Oct-14 5:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.