The Daily WTF: Curious Perversions in Information Technology
Welcome to TDWTF Forums Sign in | Join | Help
in Search

Speed Challenge 33 - Something that does nothing.

Last post 04-04-2008 4:59 PM by zokar. 17 replies.
Page 1 of 1 (18 items)
Sort Posts: Previous Next
  • 07-23-2007 3:22 PM

    • Daid
    • Top 100 Contributor
    • Joined on 01-30-2007
    • Posts 258

    Speed Challenge 33 - Something that does nothing.

    Write something that looks like it's doing a whole lot, but doesn't actualy do anything under the hood.

    For example, back in my "QBasic" days, I wrote a "format" ulility, that showed exactly the same stuff as normal format, but didn't do anything.

    Doesn't have to be an exisiting program, feel free to invent anything you want.

     

    Kinda inspired by this WTF: http://worsethanfailure.com/Articles/I_Thought_You_Wanted_Demonstrations.aspx 

  • 07-23-2007 7:49 PM In reply to

    Re: Speed Challenge 33 - Something that does nothing.

    Not only does it do nothing, but it doesn't look like anything either.

     

       	 	 			






















































    In case the forum software eats the tabs, here's the same code written out:

     SP SP SP TAB SP TAB SP TAB TAB TAB LF
    TAB LF SP SP
    SP SP SP TAB TAB SP TAB TAB TAB TAB LF
    TAB LF SP SP
    SP SP SP TAB TAB TAB SP SP TAB SP LF
    TAB LF SP SP
    SP SP SP TAB TAB SP TAB SP TAB TAB LF
    TAB LF SP SP
    SP SP SP TAB TAB SP TAB SP SP TAB LF
    TAB LF SP SP
    SP SP SP TAB TAB SP TAB TAB TAB SP LF
    TAB LF SP SP
    SP SP SP TAB TAB SP SP TAB TAB TAB LF
    TAB LF SP SP
    SP SP SP TAB LF
    SP SP TAB TAB LF
    LF SP SP SP SP SP LF
    SP SP SP SP TAB SP SP SP SP SP LF
    TAB LF SP SP
    SP SP SP TAB LF
    TAB SP SP SP
    SP LF SP
    LF TAB TAB SP SP SP LF
    SP LF LF
    LF TAB TAB SP TAB TAB LF
    SP SP SP TAB SP TAB TAB SP TAB TAB LF
    TAB LF SP SP
    SP SP SP SP TAB TAB TAB TAB SP TAB LF
    TAB LF SP SP
    SP SP TAB TAB LF
    SP SP TAB SP TAB TAB SP SP SP TAB LF
    LF SP LF SP SP SP LF
    LF SP SP SP TAB TAB LF
    SP SP SP TAB SP TAB TAB TAB SP TAB LF
    TAB LF SP SP
    SP SP SP SP TAB SP SP SP SP SP LF
    TAB LF SP SP
    SP SP SP SP TAB TAB SP SP SP TAB LF
    TAB LF SP SP
    SP SP SP SP TAB SP SP TAB SP TAB LF
    TAB LF SP SP
    LF SP SP TAB TAB TAB LF
    LF SP LF TAB TAB TAB LF
    LF LF LF
  • 07-24-2007 4:31 AM In reply to

    • Daid
    • Top 100 Contributor
    • Joined on 01-30-2007
    • Posts 258

    Re: Speed Challenge 33 - Something that does nothing.

    It also doesn't look like it's doing anything, which kinda was the challange :P unless I miss the fact that there is some whitespace compiler?
  • 07-24-2007 5:06 AM In reply to

    • PJH
    • Top 25 Contributor
    • Joined on 02-14-2007
    • Posts 596

    Re: Speed Challenge 33 - Something that does nothing.

    Daid:
    unless I miss the fact that there is some whitespace compiler?


    http://en.wikipedia.org/wiki/Whitespace_(programming_language)
    This is not a problem that requires infinite wisdom, Benj. This is a problem that requires enough neural organization to qualify as a vertebrate, apparently a stretch for some folks these days.
    - Cecil Adams.
    Filed under:
  • 07-24-2007 9:07 AM In reply to

    Re: Speed Challenge 33 - Something that does nothing.

    This is something I saw long long time ago in my teacher's notes:

     

    /*

    PROGRAM 2: Hello

    Program asks user for his full name and displays welcome message

    */ 

    #include <iostream.h>

    void main()

    {

       char* fullname;

       cout << "Enter your name: ";

     

       //WHY DOES THIS CRASH? 

       //cin >> fullname;

       //cout << "Hello, " << fullname << endl;

     

       cout << "Hello, " << "John Doe" << endl;

    }

     

    Program does exactly what it should. Somewhat. And still, does pretty nothing. It was ~7 years ago, and I think that my professor was learning C++ along with his students :)

    When I come back home I will think about something original, but I have no ideas for now :|

     

    Cheers

  • 07-24-2007 9:46 AM In reply to

    Re: Speed Challenge 33 - Something that does nothing.

    The following code do absolutely notihng except use up CPU and print dots to fake work.

    It's in C# and is a console application. Thanks for your patience ;)
    using System;
    
    namespace DoNothing
    {
    	class Foobar
    	{
    		static void Main(string[] args)
    		{
    			Console.WriteLine("System is ready to process the data. Proceed ? (y/n)");
    			string ans = System.Console.ReadLine();
    			if (ans == "y")
    			{
    				// just random process time
    				int maxTimeDelta = (new Random(DateTime.Now.Millisecond)).Next(10, 60);
    				int importantTimeDelta = (new Random(DateTime.Now.Millisecond + maxTimeDelta)).Next(0, maxTimeDelta); // Yay ! Seed with previous random !
    				DateTime endTime = DateTime.Now.AddSeconds((double)maxTimeDelta);
    				DateTime importantTime = DateTime.Now.AddSeconds((double)importantTimeDelta);
    				bool bImportant = false;
    				while (DateTime.Now < endTime) // sure way to use up CPU
    				{
    					// Let's print dots randomly to fake work
    					if ((new Random(DateTime.Now.Millisecond)).Next(0, 100) == 1)
    						Console.Write(".");
    					if (!bImportant && DateTime.Now > importantTime)
    					{
    						bImportant = true;
    						Console.WriteLine();
    						Console.WriteLine("Beginning critical processing. Any interruption could lead to data corruption and rash.");
    					}
    				}
    				Console.WriteLine();
    				Console.WriteLine("Data processed. Thanks for your patience.");
    			}
    			else if (ans == "n")
    			{
    				Console.WriteLine("kthxbye :'(");
    			}
    			else
    			{
    				Console.WriteLine("Learn to type !");
    			}
    		}
    	}
    }
  • 07-27-2007 10:11 AM In reply to

    Re: Speed Challenge 33 - Something that does nothing.

    The last post was three days ago. Will nobody declare a winner?
    --Edward Dassmesser
  • 07-27-2007 12:21 PM In reply to

    • Daid
    • Top 100 Contributor
    • Joined on 01-30-2007
    • Posts 258

    Re: Speed Challenge 33 - Something that does nothing.

    durnurd:
    The last post was three days ago. Will nobody declare a winner?
    Yeah, sorry. They installed a new firewall at work. Guess what they blocked? Just about everything. (Google and wikipedia work, but that's about it, suddenly google cache is a blessing)

    I was having some problems getting the whitespace one to run. Seems to run now. After some creative abuse of sed and your posted TAB SP LF version.

    .... Does it stay stuck at 1%? It does... right? I'll guess I'll put it in a screen and check a while later.

     

    Calculating winner:

    [=..................................] Working... 1% 

  • 07-27-2007 2:55 PM In reply to

    • Daid
    • Top 100 Contributor
    • Joined on 01-30-2007
    • Posts 258

    Re: Speed Challenge 33 - Something that does nothing.

    Close one, but this one goes to omega0.

     

    Why? Well, it doesn't do much, but it also looks like nothing. Anyone making anything in whitespace gets bonuspoints. The C# from Kokuma is also nice, with random progression, no idea when it finishes and added critical section. But having me running a whitespace program in a screen, for a few houres just to see if it really doesn't do anything is simply priceless.

  • 07-27-2007 6:05 PM In reply to

    Re: Speed Challenge 34 - I laugh in the face of warnings of danger.

    ...It deeply amuses me for some reason that my Working...1% was watched for so long.  I shouldn't laugh though, I had the hulkulator finish all its calculations.

    On to #34:

    Create warnings.

    As many compiler / runtime warnings as you can possibly get in a single statement (the code does have to compile & execute though, no errors, just warnings).

  • 07-27-2007 11:49 PM In reply to

    • kirchhoff
    • Top 150 Contributor
    • Joined on 02-27-2007
    • ECE 280 (Circuit Analysis)
    • Posts 216

    Re: Speed Challenge 34 - I laugh in the face of warnings of danger.

    omega0:

    ...It deeply amuses me for some reason that my Working...1% was watched for so long.  I shouldn't laugh though, I had the hulkulator finish all its calculations.

    On to #34:

    Create warnings.

    As many compiler / runtime warnings as you can possibly get in a single statement (the code does have to compile & execute though, no errors, just warnings).

     

    void main (int argc, char ** argv) {
    int z, x = 0;
    wtf:if (argc > 0) if(z = z) return z = z + ((void *) printf("%ld%s\n", -x + 5 / -3.1, &x, z) + 3);
    else
    return;
    }
    bash-3.00$ gcc warns.c -O -Wall -o warns
    
    ...snip...
    warns.c: In function ‘main’:
    warns.c:4: warning: suggest parentheses around assignment used as truth value
    warns.c:4: warning: implicit declaration of function ‘printf’
    warns.c:4: warning: incompatible implicit declaration of built-in function ‘prin tf’
    warns.c:4: warning: format ‘%ld’ expects type ‘long int’, but argument 2 has typ e ‘double’
    warns.c:4: warning: format ‘%s’ expects type ‘char *’, but argument 3 has type ‘ int *’
    warns.c:4: warning: too many arguments for format
    warns.c:4: warning: cast to pointer from integer of different size
    warns.c:4: warning: assignment makes integer from pointer without a cast
    warns.c:4: warning: ‘return’ with a value, in function returning void
    warns.c:4: warning: suggest explicit braces to avoid ambiguous ‘else’
    warns.c:4: warning: label ‘wtf’ defined but not used
    warns.c:4: warning: ‘z’ is used uninitialized in this function
    
    Filed under: , ,
  • 07-28-2007 3:52 PM In reply to

    Re: Speed Challenge 33 - Something that does nothing.

    Console Program
    union ForSleepTime {
      char buffer[4];
      unsigned long time;
    } timeSleep;
    char md5Buffer[64]; //I have a habit of making sure all all arrays and structs are sizeof() power of 2
    char inputBuffer[64];
    
    int main() {
      while (1) {
        PromptForInput();
        strcpy(inputBuffer, GrabInput());
        strcpy(md5Buffer, MD5_string(inputBuffer));
        timeSleep.buffer[0] = md5Buffer[0];
        timeSleep.buffer[1] = md5Buffer[1];
        timeSleep.buffer[2] = md5Buffer[2];
        timeSleep.buffer[3] = md5Buffer[3];
        echo("Running command: ", inputBuffer, "\n");
        DoSomethingWithDiskToMakeNoise();
        sleep(timeSleep.time/10);
        echo("10% Completed. . .");
        DoSomethingWithDiskToMakeNoise();
        sleep(timeSleep.time/10);
        echo("20% Completed. . .");
        DoSomethingWithDiskToMakeNoise();
        sleep(timeSleep.time/10);
        echo("30% Completed. . .");
        DoSomethingWithDiskToMakeNoise();
        sleep(timeSleep.time/10);
        echo("40% Completed. . .");
        DoSomethingWithDiskToMakeNoise();
        sleep(timeSleep.time/10);
        echo("50% Completed. . .");
        DoSomethingWithDiskToMakeNoise();
        sleep(timeSleep.time/10);
        echo("60% Completed. . .");
        DoSomethingWithDiskToMakeNoise();
        sleep(timeSleep.time/10);
        echo("70% Completed. . .");
        DoSomethingWithDiskToMakeNoise();
        sleep(timeSleep.time/10);
        echo("80% Completed. . .");
        DoSomethingWithDiskToMakeNoise();
        sleep(timeSleep.time/10);
        echo("90% Completed. . .");
        DoSomethingWithDiskToMakeNoise();
        sleep(timeSleep.time/10);
        echo("100% Completed. . .");
        echo("Running command: ", inputBuffer, " has completed ", ((inputBuffer%2) ? "successfully" : "failled"), "\n");
      }
      return 0; //As if. . .
    }
    
    irc://irc.slashnet.org/#TDWTF
    [12:15:49] <Duplication_Prevention_Bot> Human test subjects are illegal! I didn't sign an EULA for this.


  • 07-30-2007 4:57 AM In reply to

    • Daid
    • Top 100 Contributor
    • Joined on 01-30-2007
    • Posts 258

    Re: Speed Challenge 34 - I laugh in the face of warnings of danger.

    Two files required:

    -Main.c
    -Main.h

    Main.h:

    #define test

    But without the newline at the end.

    Main.c:

    //Repeat the following line as many times as you want warnings.
    #include "Main.h"
    #include "Main.h"
    #include "Main.h"
    #include "Main.h"
    #include "Main.h"
    #include "Main.h"
    #include "Main.h"
    #include "Main.h"
    #include "Main.h"
    #include "Main.h"
    #include "Main.h"
    int main(int argc, char** argv) {return 0;}

     

    Unlimited warnings for the taking! All on the same line ;) 

  • 07-30-2007 6:37 AM In reply to

    Re: Speed Challenge 34 - I laugh in the face of warnings of danger.

    G++ goes into an infinite loop when I put #include "main.h" before the #define TEST Near-unlimited warnings ftw.
    #include "main.h"
    #define TEST
    irc://irc.slashnet.org/#TDWTF
    [12:15:49] <Duplication_Prevention_Bot> Human test subjects are illegal! I didn't sign an EULA for this.


  • 07-30-2007 6:51 AM In reply to

    • flop
    • Top 500 Contributor
    • Joined on 04-27-2007
    • Posts 50

    Re: Speed Challenge 34 - I laugh in the face of warnings of danger.

    A trivial solution: A "404 warning".
    $ perl -e 'warn! warn! warn! warn for  0 .. 100' 
  • 07-30-2007 7:02 AM In reply to

    • Daid
    • Top 100 Contributor
    • Joined on 01-30-2007
    • Posts 258

    Re: Speed Challenge 34 - I laugh in the face of warnings of danger.

    Lingerance:
    G++ goes into an infinite loop when I put #include "main.h" before the #define TEST Near-unlimited warnings ftw.
    #include "main.h"
    #define TEST
    But finaly crashes witn an error. Which does not satisfy the "compiles&runs" requirement.
  • 07-30-2007 6:52 PM In reply to

    Re: Speed Challenge 34 - I laugh in the face of warnings of danger.

    kirchhoff, the next round is yours.  The near-infinite solutions are clever, but 100 of the same error is little boring.
  • 04-04-2008 4:59 PM In reply to

    • zokar
    • Not Ranked
    • Joined on 02-27-2008
    • Posts 2

    Re: Speed Challenge 34 - I laugh in the face of warnings of danger.

    I'm a bit late, but I thought I'd try my hand for the warnings program. This program will probably segfault, though it shouldn't surprise anyone -- it does a lot of pointer munging for the heck of it.

     

    50+ warnings, mostly unique, 256 bytes of source, so about one warning every 5 characters. As a bonus, it uses no whitespace. I'm well aware this is longer than a single statement, but it is a single line with no spaces, tabs or newlines ;)

    A=&A;struct{int*A};s(P){return"";{int*A;c(A);}return;}main(){int*c={1,3},q=&A,*d,r[3][3]={0};char*u;unsigned*v;l:if(d=s?d:s,v<0,*v<0<0)if(+3<<0xfffffffffU/0,q+=(void*)printf("%s%f%s",1.,s),*u<300);else;d=d++;vsscanf("",'HOLA',c);sprintf(&A,"%c%c",""[*u]);}

    Using pre tags:

     A=&A;struct{int*A};s(P){return"";{int*A;c(A);}return;}main(){int*c={1,3},q=&A,*d,r[3][3]={0};char*u;unsigned*v;l:if(d=s?d:s,v<0,*v<0<0)if(+3<<0xfffffffffU/0,q+=(void*)printf("%s%f%s",1.,s),*u<300);else;d=d++;vsscanf("",'HOLA',c);sprintf(&A,"%c%c",""[*u]);}

    > gcc -Wall warnfactory.c -Wextra -O

    warnfactory.c:1: warning: type defaults to `int' in declaration of `A'
    warnfactory.c:1: warning: initialization makes integer from pointer without a cast
    warnfactory.c:1: warning: data definition has no type or storage class
    warnfactory.c:1: warning: no semicolon at end of struct or union
    warnfactory.c:1: warning: unnamed struct/union that defines no instances
    warnfactory.c:1: warning: return type defaults to `int'
    warnfactory.c: In function `s':
    warnfactory.c:1: warning: type of "P" defaults to "int"
    warnfactory.c:1: warning: return makes integer from pointer without a cast
    warnfactory.c:1: warning: implicit declaration of function `c'
    warnfactory.c:1: warning: `return' with no value, in function returning non-void
    warnfactory.c:1: warning: this function may return with or without a value
    warnfactory.c: At top level:
    warnfactory.c:1: warning: unused parameter 'P'
    warnfactory.c:1: warning: return type defaults to `int'
    warnfactory.c: In function `main':
    warnfactory.c:1: warning: initialization makes pointer from integer without a cast
    warnfactory.c:1: warning: excess elements in scalar initializer
    warnfactory.c:1: warning: (near initialization for `c')
    warnfactory.c:1: warning: initialization makes integer from pointer without a cast
    warnfactory.c:1: warning: missing braces around initializer
    warnfactory.c:1: warning: (near initialization for `r[0]')
    warnfactory.c:1: warning: the address of `s', will always evaluate as `true'
    warnfactory.c:1: warning: pointer type mismatch in conditional expression
    warnfactory.c:1: warning: ordered comparison of pointer with integer zero
    warnfactory.c:1: warning: comparison of unsigned expression < 0 is always false
    warnfactory.c:1: warning: comparisons like X<=Y<=Z do not have their mathematical meaning
    warnfactory.c:1: warning: left-hand operand of comma expression has no effect
    warnfactory.c:1: warning: integer constant is too large for "unsigned long" type
    warnfactory.c:1: warning: division by zero
    warnfactory.c:1: warning: implicit declaration of function `printf'
    warnfactory.c:1: warning: format argument is not a pointer (arg 2)
    warnfactory.c:1: warning: double format, pointer arg (arg 3)
    warnfactory.c:1: warning: too few arguments for format
    warnfactory.c:1: warning: assignment makes integer from pointer without a cast
    warnfactory.c:1: warning: comparison is always true due to limited range of data type
    warnfactory.c:1: warning: left-hand operand of comma expression has no effect
    warnfactory.c:1: warning: empty body in an else-statement
    warnfactory.c:1: warning: suggest explicit braces to avoid ambiguous `else'
    warnfactory.c:1: warning: empty body in an if-statement
    warnfactory.c:1: warning: operation on `d' may be undefined
    warnfactory.c:1: warning: implicit declaration of function `vsscanf'
    warnfactory.c:1:220: warning: multi-character character constant
    warnfactory.c:1: warning: passing arg 2 of `vsscanf' makes pointer from integer without a cast
    warnfactory.c:1: warning: passing arg 3 of `vsscanf' from incompatible pointer type
    warnfactory.c:1: warning: implicit declaration of function `sprintf'
    warnfactory.c:1: warning: array subscript has type `char'
    warnfactory.c:1: warning: passing arg 1 of `sprintf' from incompatible pointer type
    warnfactory.c:1: warning: too few arguments for format
    warnfactory.c:1: warning: unused variable `r'
    warnfactory.c:1: warning: label `l' defined but not used
    warnfactory.c:1: warning: control reaches end of non-void function
    warnfactory.c:1: warning: 'u' might be used uninitialized in this function
    warnfactory.c:1:257: warning: no newline at end of file

    Filed under: , , ,
Page 1 of 1 (18 items)
Powered by Community Server (Non-Commercial Edition), by Telligent Systems