..:: 1337 ::..
[ j00 d34d f00 ]
home
intro code comics poetry

// code

10. You can end every argument with ctrl-alt-del
- The Heuristic Squelch, Top Ten Reasons to Date an EECS Major

Page last modified Saturday, 26-Mar-2005 05:01:36 PST
bookmark this page

navigation bar

pi

Description: This code outputs an approximation to pi (3.141592654 ...) in an unusual manner. The source code itself is shaped as a circle, and the program works by calculating its own area and diameter, and then doing a division to approximate pi.


#define _ F-->00 || F-OO--;
long F=00,OO=00;
main(){F_OO();printf("%1.3f\n", 4.*-F/OO/OO);}F_OO()
{
            _-_-_-_
       _-_-_-_-_-_-_-_-_
    _-_-_-_-_-_-_-_-_-_-_-_
  _-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_
  _-_-_-_-_-_-_-_-_-_-_-_-_-_
    _-_-_-_-_-_-_-_-_-_-_-_
       _-_-_-_-_-_-_-_-_
            _-_-_-_
}

So how does the code actually work? Click here for a forum discussion.


pig-latin translator

Author: Don Dodson

Description: This code take English strings as input and translates them to pig-latin. Not only is the code shaped like a pig head, but the variable names inside the code are written in pig latin (note the #define statements at the top).


#define X
#define XX
#define XXX
#define XXXX
#define XXXXX
#define XXXXXX
#define XXXXXXX
#define orfa for
#define XXXXXXXXX
#define archa char
#define ainma main
#define etcharga getchar
#define utcharpa putchar

     X                                       X
    X X                                     X X
   X   X                                   X   X
   X    X                                 X    X
  X      X                               X      X
  X       X                             X       X
 X         X                           X         X
 X   X     X                           X     X   X
 X   XX     X                         X     XX   X
X    XXX    X        XXXXXXXXX        X    XXX    X
X     XXX    X   XXXX         XXXX   X    XXX     X
X     XXXX   X XX ainma(){ archa  XX X   XXXX     X
X     XXXX    X   oink[9],*igpa,    X    XXXX     X
X     XXXXXX atinla=etcharga(),iocccwa XXXXXX     X
X      XXXX ,apca='A',owla='a',umna=26  XXXX      X
X      XXX  ; orfa(; (atinla+1)&&(!(((   XXX      X
X      XX atinla-apca)*(apca+umna-atinla) XX      X
 X     X  >=0)+((atinla-owla)*(owla+umna-  X     X
 X       atinla)>=0))); utcharpa(atinla),        X
 X   X atinla=etcharga()); orfa(; atinla+1;  X   X
  X X  ){ orfa(      igpa=oink     ,iocccwa=( X X
  X X  (atinla-  XXX  apca)*(  XXX apca+umna- X X
   X atinla)>=0) XXX           XXX   ; ((((    X
  X atinla-apca XXXXX XXXXXXX XXXXX  )*(apca+   X
  X umna-atinla XXXXXX )>=0) XXXXXX +((atinla-  X
 X owla)*(owla+ XXXX   umna-   XXXX atinla)>=0)) X
 X   &&"-Pig-"   XX  "Lat-in"   XX   "COb-fus"   X
 X "ca-tion!!"[  X  (((atinla-   X  apca)*(apca+ X
 X umna-atinla) X  >=0)?atinla-   X  apca+owla:  X
X atinla)-owla X ]-'-')||((igpa==  X oink)&&!(*(  X
X igpa++)='w') X )||! X (*( X igpa X ++)=owla); * X
X (igpa++)=(( X  (   XXX   XXX      X atinla-apca X
X  )*(apca+   X umna XXX - XXX      X atinla)>=0) X
X  ?atinla-   X apca XXX + XXX owla X  :atinla),  X
 X   atinla=   X      X     X      X etcharga()) X
 X   ; orfa(   X atinla=iocccwa?(( X  (atinla-   X
 X owla)*(owla+ X umna-atinla)>=0 X  )?atinla-   X
 X  owla+apca:   X   atinla):    X  atinla; (((  X
  X atinla-apca)* X (apca+umna- X atinla)>=0)+( X
  X (atinla-owla)* X  (owla+   X umna-atinla)>= X
   X 0)); utcharpa( XX       XX atinla),atinla X
   X  =etcharga());   XXXXXXX  orfa(*igpa=0,   X
    X  igpa=oink; *           igpa; utcharpa( X
     X *(igpa++))); orfa(; (atinla+1)&&(!((( X
      X atinla-apca              )*(apca+   X
       X   umna-    XXXXX XXXXX atinla)>=0 X
        X   )+((       XXXXX     atinla-  X
         XX  owla)*(         owla+umna- XX
           XX atinla)>=0))); utcharpa XX
             XX  (atinla),atinla=   XX
               XX etcharga()); }  XX
                 XXXX   }     XXXX
                     XXXXXXXXX

palindrome

Author: Unknown

				char rahc
				   [ ]
				    =
				  "\n/"
				    ,
				redivider
				   [ ]
				    =
		       "Able was I ere I saw elbA"
				    ,
				    *
			     deliver,reviled
				    =
				   1+1
				    ,
			       niam ; main
				   ( )
				  {/*\}
				   \*/
				 int tni
				    =
				   0x0
				    ,
			     rahctup,putchar
				   ( )
		           ,LACEDx0 = 0xDECAL,
				rof ; for
			     (;(int) (tni);)
			       (int) (tni)
			  = reviled ; deliver =
				redivider
				    ;
for ((int)(tni)++,++reviled;reviled* *deliver;deliver++,++(int)(tni)) rof
			            =
			     (int) -1- (tni)
		          ;reviled--;--deliver;
			     (tni)  =  (int)
			  - 0xDECAL + LACEDx0 -
				rof ; for
       (reviled--,(int)--(tni);(int) (tni);(int)--(tni),--deliver)
			    rahctup = putchar
			   (reviled* *deliver)
				    ;
			    rahctup * putchar
			    ((char) * (rahc))
				    ;
				   /*\
				  {\*/}

love letters

Author: Brian Westley

Description: This code is a "Picking the Daisy" simulation. Supply the program with the number of petals desired as the argument, to figure out if she loves you, or loves you not. Read each block of code as a piece of correspondence between two lovers, charlie and charlotte. Note the inevitable: (char)lotte and (char*)lie are incompatible types, hehe.

char*lie;

	double time, me= !0XFACE,

	not; int rested,   get, out;

	main(ly, die) char ly, **die ;{

	    signed char lotte,


dear; (char)lotte--;

	for(get= !me;; not){

	1 -  out & out ;lie;{

	char lotte, my= dear,

	**let= !!me *!not+ ++die;

	    (char*)(lie=


"The gloves are OFF this time, I detest you, snot\n\0sed GEEK!");

	do {not= *lie++ & 0xF00L* !me;

	#define love (char*)lie -

	love 1 *!(not= atoi(let

	[get -me?

	    (char)lotte-


(char)lotte: my- *love -
	
	'I'  -  *love -  'U' -

	'I'  -  (long)  - 4 - 'U' ])- !!
	
	(time  =out=  'a'));} while( my - dear

	&& 'I'-1l  -get-  'a'); break;}}

	    (char)*lie++;


(char)*lie++, (char)*lie++; hell:0, (char)*lie;

	get *out* (short)ly   -0-'R'-  get- 'a'^rested;

	do {auto*eroticism,

	that; puts(*( out

	    - 'c'
	
-('P'-'S') +die+ -2 ));}while(!"you're at it");


for (*((char*)&lotte)^=

	(char)lotte; (love ly) [(char)++lotte+

	!!0xBABE];){ if ('I' -lie[ 2 +(char)lotte]){ 'I'-1l ***die; }

	else{ if ('I' * get *out* ('I'-1l **die[ 2 ])) *((char*)&lotte) -=

	'4' - ('I'-1l); not; for(get=!


get; !out; (char)*lie  &  0xD0- !not) return!!

	(char)lotte;}


(char)lotte;

	do{ not* putchar(lie [out

	*!not* !!me +(char)lotte]);

	not; for(;!'a';);}while(

	    love (char*)lie);{


register this; switch( (char)lie

	[(char)lotte] -1 *!out) {

	char*les, get= 0xFF, my; case' ':

	*((char*)&lotte) += 15; !not +(char)*lie*'s';

	this +1+ not; default: 0xF +(char*)lie;}}}

	get - !out;

	if (not--)

	goto hell;

	    exit( (char)lotte);}

evolution of a programmer

Author: Unknown



High School/Jr.High

  10 PRINT "HELLO WORLD"
  20 END
 

First year in College

  program Hello(input, output)
    begin
      writeln('Hello World')
    end.
 

Senior year in College

  (defun hello
    (print
      (cons 'Hello (list 'World))))
 

New professional

  #include <stdio.h>
  void main(void)
  {
    char *message[] = {"Hello ", "World"};
    int i;
 
    for(i = 0; i < 2; ++i)
      printf("%s", message[i]);
    printf("\n");
  }
 

Seasoned professional

  #include <iostream.h>
  #include <string.h>
 
  class string
  {
  private:
    int size;
    char *ptr;
 
  public:
    string() : size(0), ptr(new char('\0')) {}
 
    string(const string &s) : size(s.size)
    {
      ptr = new char[size + 1];
      strcpy(ptr, s.ptr);
    }
 
    ~string()
    {
      delete [] ptr;
    }
 
    friend ostream &operator <<(ostream &, const string &);
    string &operator=(const char *);
  };
 
  ostream &operator<<(ostream &stream, const string &s)
  {
    return(stream << s.ptr);
  }
 
  string &string::operator=(const char *chrs)
  {
    if (this != &chrs)
    {
      delete [] ptr;
     size = strlen(chrs);
      ptr = new char[size + 1];
      strcpy(ptr, chrs);
    }
    return(*this);
  }
 
  int main()
  {
    string str;
 
    str = "Hello World";
    cout << str << endl;
 
    return(0);
  }
 

Master Programmer

  [
  uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820)
  ]
  library LHello
  {
      // bring in the master library
      importlib("actimp.tlb");
      importlib("actexp.tlb");
 
      // bring in my interfaces
      #include "pshlo.idl"
 
      [
      uuid(2573F8F5-CFEE-101A-9A9F-00AA00342820)
      ]
      cotype THello
   {
   interface IHello;
   interface IPersistFile;
   };
  };
 
  [
  exe,
  uuid(2573F890-CFEE-101A-9A9F-00AA00342820)
  ]
  module CHelloLib
  {
 
      // some code related header files
      importheader(<windows.h>);
      importheader(<ole2.h>);
      importheader(<except.hxx>);
      importheader("pshlo.h");
      importheader("shlo.hxx");
      importheader("mycls.hxx");
 
      // needed typelibs
      importlib("actimp.tlb");
      importlib("actexp.tlb");
      importlib("thlo.tlb");
 
      [
      uuid(2573F891-CFEE-101A-9A9F-00AA00342820),
      aggregatable
      ]
      coclass CHello
   {
   cotype THello;
   };
  };
 
 
  #include "ipfix.hxx"
 
  extern HANDLE hEvent;
 
  class CHello : public CHelloBase
  {
  public:
      IPFIX(CLSID_CHello);
 
      CHello(IUnknown *pUnk);
      ~CHello();
 
      HRESULT  __stdcall PrintSz(LPWSTR pwszString);
 
  private:
      static int cObjRef;
  };
 
 
  #include <windows.h>
  #include <ole2.h>
  #include <stdio.h>
  #include <stdlib.h>
  #include "thlo.h"
  #include "pshlo.h"
  #include "shlo.hxx"
  #include "mycls.hxx"
 
  int CHello::cObjRef = 0;
 
  CHello::CHello(IUnknown *pUnk) : CHelloBase(pUnk)
  {
      cObjRef++;
      return;
  }
 
  HRESULT  __stdcall  CHello::PrintSz(LPWSTR pwszString)
  {
      printf("%ws\n", pwszString);
      return(ResultFromScode(S_OK));
  }
 
 
  CHello::~CHello(void)
  {
 
  // when the object count goes to zero, stop the server
  cObjRef--;
  if( cObjRef == 0 )
      PulseEvent(hEvent);
 
  return;
  }
 
  #include <windows.h>
  #include <ole2.h>
  #include "pshlo.h"
  #include "shlo.hxx"
  #include "mycls.hxx"
 
  HANDLE hEvent;
 
   int _cdecl main(
  int argc,
  char * argv[]
  ) {
  ULONG ulRef;
  DWORD dwRegistration;
  CHelloCF *pCF = new CHelloCF();
 
  hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
 
  // Initialize the OLE libraries
  CoInitializeEx(NULL, COINIT_MULTITHREADED);
 
  CoRegisterClassObject(CLSID_CHello, pCF, CLSCTX_LOCAL_SERVER,
      REGCLS_MULTIPLEUSE, &dwRegistration);
 
  // wait on an event to stop
  WaitForSingleObject(hEvent, INFINITE);
 
  // revoke and release the class object
  CoRevokeClassObject(dwRegistration);
  ulRef = pCF->Release();
 
  // Tell OLE we are going away.
  CoUninitialize();
 
  return(0); }
 
  extern CLSID CLSID_CHello;
  extern UUID LIBID_CHelloLib;
 
  CLSID CLSID_CHello = { /* 2573F891-CFEE-101A-9A9F-00AA00342820 */
      0x2573F891,
      0xCFEE,
      0x101A,
      { 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }
  };
 
  UUID LIBID_CHelloLib = { /* 2573F890-CFEE-101A-9A9F-00AA00342820 */
      0x2573F890,
      0xCFEE,
      0x101A,
      { 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }
  };
 
  #include <windows.h>
  #include <ole2.h>
  #include <stdlib.h>
  #include <string.h>
  #include <stdio.h>
  #include "pshlo.h"
  #include "shlo.hxx"
  #include "clsid.h"
 
  int _cdecl main(
  int argc,
  char * argv[]
  ) {
  HRESULT  hRslt;
  IHello        *pHello;
  ULONG  ulCnt;
  IMoniker * pmk;
  WCHAR  wcsT[_MAX_PATH];
  WCHAR  wcsPath[2 * _MAX_PATH];
 
  // get object path
  wcsPath[0] = '\0';
  wcsT[0] = '\0';
  if( argc > 1) {
      mbstowcs(wcsPath, argv[1], strlen(argv[1]) + 1);
      wcsupr(wcsPath);
      }
  else {
      fprintf(stderr, "Object path must be specified\n");
      return(1);
      }
 
  // get print string
  if(argc > 2)
      mbstowcs(wcsT, argv[2], strlen(argv[2]) + 1);
  else
      wcscpy(wcsT, L"Hello World");
 
  printf("Linking to object %ws\n", wcsPath);
  printf("Text String %ws\n", wcsT);
 
  // Initialize the OLE libraries
  hRslt = CoInitializeEx(NULL, COINIT_MULTITHREADED);
 
  if(SUCCEEDED(hRslt)) {
 
 
      hRslt = CreateFileMoniker(wcsPath, &pmk);
      if(SUCCEEDED(hRslt))
   hRslt = BindMoniker(pmk, 0, IID_IHello, (void **)&pHello);
 
      if(SUCCEEDED(hRslt)) {
 
   // print a string out
   pHello->PrintSz(wcsT);
 
   Sleep(2000);
   ulCnt = pHello->Release();
   }
      else
   printf("Failure to connect, status: %lx", hRslt);
 
      // Tell OLE we are going away.
      CoUninitialize();
      }
 
  return(0);
  }
 
 
 

Apprentice Hacker

  #!/usr/local/bin/perl
  $msg="Hello, world.\n";
  if ($#ARGV >= 0) {
    while(defined($arg=shift(@ARGV))) {
      $outfilename = $arg;
      open(FILE, ">" . $outfilename) || die "Can't write $arg: $!\n";
      print (FILE $msg);
      close(FILE) || die "Can't close $arg: $!\n";
    }
  } else {
    print ($msg);
  }
  1;
 
 
 

Experienced Hacker

  #include <stdio.h>
  #define S "Hello, World\n"
  main(){exit(printf(S) == strlen(S) ? 0 : 1);}
 
 
 

Seasoned Hacker

  % cc -o a.out ~/src/misc/hw/hw.c
  % a.out
 
 
 

Guru Hacker

  % echo "Hello, world."
 
 
 

New Manager

  10 PRINT "HELLO WORLD"
  20 END
 
 
 

Middle Manager

  mail -s "Hello, world." bob@b12
  Bob, could you please write me a program that prints "Hello,
 world."?
  I need it by tomorrow.
  ^D
 
 
 

Senior Manager

  % zmail jim
  I need a "Hello, world." program by this afternoon.
 
 
 

Chief Executive

  % letter
  letter: Command not found.
  % mail
  To: ^X ^F ^C
  % help mail
  help: Command not found.
  % damn!
  !: Event unrecognized
  % logout


multi-lingual program

Author: Kevin Bungard, Peter Lisle, and Chris Tham

Description: This program is compatible with 7 programming languages!


---cut here--(two blank lines are MANDATORY)---

                                                                         (*O/*_/
Cu  #%* )pop mark/CuG 4 def/# 2 def%%%%@@P[TX---P\P_SXPY!Ex(mx2ex("SX!Ex4P)Ex=
CuG #%*                                                                  *+Ex=
CuG #%*------------------------------------------------------------------*+Ex=
CuG #%*   POLYGLOT - a program in seven languages      15 February 1991  *+Ex=
CuG #%*                                                                  *+Ex=
CuG #%*   Written by Kevin Bungard, Peter Lisle, and Chris Tham          *+Ex=
CuG #%*                                                                  *+Ex=
CuG #%*   We have successfully run this program using the following:     *+Ex=
CuG #%*     ANSI COBOL:            MicroFocus COBOL85 (not COBOL74)      *+Ex=
CuG #%*     ISO  Pascal:           Turbo Pascal (DOS & Mac), Unix PC,    *+Ex=
CuG #%*                            AIX VS Pascal                         *+Ex=
CuG #%*     ANSI Fortran:          Unix f77, AIX VS Fortran              *+Ex=
CuG #%*     ANSI C (lint free):    Microsoft C, Unix CC, GCC, Turbo C++, *+Ex=
CuG #%*                            Think C (Mac)                         *+Ex=
CuG #%*     PostScript:            GoScript, HP/Adobe cartridge,         *+Ex=
CuG #%*                            Apple LaserWriter                     *+Ex=
CuG #%*     Shell script:          gnu bash, sh (SysV, BSD, MKS), ksh    *+Ex=
CuG #%*     8086 machine language: MS-DOS 2.00, 3.03, 4.01, 5.00 beta    *+Ex=
CuG #%*                            VPix & DOS Merge (under unix)         *+Ex=
CuG #%*                            SoftPC (on a Mac), MKS shell          *+Ex=
CuG #%*                                                                  *+Ex=
CuG #%*   Usage:                                                         *+Ex=
CuG #%*     1. Rename this file to polyglot.[cob|pas|f77|c|ps|sh|com]    *+Ex=
CuG #%*     2. Compile and/or run with appropriate compiler and          *+Ex=
CuG #%*        operating system                                          *+Ex=
CuG #%*                                                                  *+Ex=
CuG #%*   Notes:                                                         *+Ex=
CuG #%*     1. We have attempted to use only standard language features. *+Ex=
CuG #%*        Without the -traditional flag gcc will issue a warning.   *+Ex=
CuG #%*                                                                  *+Ex=
CuG #%*     2. This text is a comment block in all seven languages.      *+Ex=
CuG #%*                                                                  *+Ex=
CuG #%*     3. When run as a .COM file with MS-DOS it makes certain      *+Ex=
CuG #%*        (not unreasonable) assumptions about the contents of      *+Ex=
CuG #%*        the registers.                                            *+Ex=
CuG #%*                                                                  *+Ex=
CuG #%*     4. When transfering from Unix to DOS make sure that a LF     *+Ex=
CuG #%*        is correctly translated into a CR/LF.                     *+Ex=
CuG #%*                                                                  *+Ex=
CuG #%*   Please mail any comments, corrections or additions to          *+Ex=
CuG #%*   peril@extro.ucc.su.oz.au                                       *+Ex=
CuG #%*                                                                  *+Ex=
CuG #%*------------------------------------------------------------------*QuZ=
CuG #%*                                                                  *+Ex=
CuG #%*!Mx)ExQX4ZPZ4SP5n#5X!)Ex+ExPQXH,B+ExP[-9Z-9Z)GA(W@'UTTER_XYZZY'CPK*+
CuG #(*                                                                  *(
C   # */);                                                              /*(
C   # *)  program        polyglot (output);                             (*+
C   #     identification division.
C   #     program-id.    polyglot.
C   #
C   #     data           division.
C   #     procedure      division.
C   #
C   # * ))cleartomark   /Bookman-Demi findfont 36 scalefont setfont     (
C   # *                                                                 (
C   #
C   # *                  hello polyglots$
C   #     main.
C   #         perform
C     * ) 2>_$$; echo   "hello polyglots"; rm _$$; exit
              print
C             stop run.
     -*,                'hello polyglots'
C
C         print.
C             display   "hello polyglots".                              (
C     */  int i;                                                        /*
C     */  main () {                                                     /*
C     */      i=printf ("hello polyglots\n"); O= &i; return *O;         /*
C     *)                                                                (*
C     *)  begin                                                         (*
C     *)      writeln  ('hello polyglots');                             (*
C     *)                                                                (* )
C     * ) pop 60 360                                                    (
C     * ) pop moveto    (hello polyglots) show                          (
C     * ) pop showpage                                                  ((
C     *)
           end                                                          .(* )
C)pop%     program       polyglot.                                      *){*/}

William Wu © ocf.berkeley.edu/~wwu: home | intro | code | comics | poetry