Movies as code - Free your coding mind...

"Unfortunately, no one can be told what the Matrix is. You have to see it for yourself."

Morpheus, The Matrix

March 6, 2012 | Drama | submitted by David Sinclair

Twelve Angry Men

#!/usr/bin/python

jurors = [0,"guilty","guilty","guilty","guilty",
          "guilty","guilty","guilty","guilty",
          "guilty","guilty","guilty","guilty"]
seed = 0.67130678058407;

def switch (j):
    global jurors
    if (jurors[j]=="guilty"):
        jurors[j]="not guilty"
    else:
        jurors[j]="guilty"

def get_verdict():
    foreman_verdict=jurors[0]
    for j in jurors[1:]:
        if (foreman_verdict != j):
            return None
    return foreman_verdict
       
def random():
    global seed
    new_seed=13*seed
    seed=new_seed-int(new_seed)
    return int(new_seed)

while True:
    switch(random())
    verdict = get_verdict()
    if verdict is not None:
        break
   
print "Verdict is",verdict
Vote up this code1

| Romance | submitted by canado

The Artist

package com.oscars {


    import flash.filters.ColorMatrixFilter;
    import fl.motion.AdjustColor;
    import flash.events.Event;

    private var color : AdjustColor;
    private var colorMatrix : ColorMatrixFilter;
    private var matrix : Array;
    private var filterBW : Array;
    //
    public var georgeValentin:Actor;
    public var peppyMiller:Actoress;
    public var uggie:Dog;
    //


    public class TheArtist extends blackAndWhiteSilentMovie {

        public function TheArtist(){

            color = new AdjustColor();
            color.brightness = color.contrast = 20;
            color.hue = 0;
            color.saturation = -100;

            matrix = color.CalculateFinalFlatArray();
            colorMatrix = new ColorMatrixFilter(matrix);
            filterBW = [colorMatrix];

            stage.filters = filterBW;
            stage.frameRate = 16;

            addEventListener(Event.ADDED_TO_STAGE,andAction,false,0,true);
        }


        public function andAction(e:Event):void
        {
            georgeValentin = new Actor();
            peppyMiller = new Actress();
            uggie = new Dog();
            georgeValentin.voiceVolume = peppyMiller.voiceVolume = uggie.voiceVolume = 0;
        }


    }

}
Vote up this code1

November 17, 2011 | Horror | submitted by John Riselvato

Dr. Jekyll and Mr. Hyde

#!/usr/bin/perl

@personality = ("Dr Jekyll", "Mr Hyde");
$friend = "Dr Lanyon";

print("$friend: Jekyll your research `unscientific balderdash`.n");
$research = "Unscientific Balderdash";

if ($research != "Unscientific Balderdash"){
    $personality = ("@personality[1]");
} else {
    $personality = ("@personality[0]");
}

if ($personality == @personality[1]){
    $personality = "evil";
} else {
    $personality = "good"
}
print("Dr Jekyll's research created only $personalityn");
Vote up this code0

November 8, 2011 | Disaster | submitted by Ben Howdle

Speed


    $minSpeed = 50;
    $busMph = 70;
    while ($busMph => 49):
        $busMph--;
        if($busMph < $minSpeed) die();
    endwhile;
?>
Vote up this code1

September 10, 2011 | Disaster | submitted by Ben Howdle

Titanic

.titanic {
    float: none;
}
Vote up this code10

June 1, 2011 | Comedy | submitted by Richard Gubby

Planes, Trains & Automobiles


class planesTrainsAutomobiles
{
             public $where = 'New York';
             public $to = 'Chicago';
             public $plane = true;
             public $train = true;
             public $automobile = true;

             public function show()
             {
                         while($this->where != $this->to)
                         {
                                      $this->where_am_i();

                                      while($this->plane AND $this->where != $this->to)
                                                  $this->travel_by_plane();
                                     
                                      $this->where_am_i();

                                      while($this->train AND $this->where != $this->to)
                                                  $this->travel_by_train();
                                     

                                      $this->where_am_i();

                                      while($this->automobile AND $this->where != $this->to)
                                                  $this->travel_by_automobile();

                                      $this->where_am_i();
                         }
                         $this->thanksgiving();
             }
             public function travel_by_plane()
             {
                         echo 'Travelling by Plane
'
;
                         $this->where = 'New York';
                         $this->plane = false;
                         echo 'Plane is cancelled!
'
;
             }
             public function travel_by_train()
             {
                         echo 'Travelling by Train
'
;
                         $this->where = 'Missouri';
                         $this->train = false;
                         echo 'Train engine is broken!
'
;
             }
             public function travel_by_automobile()
             {
                         echo 'Travelling by Car
'
;
                         $this->where = 'Chicago';
             }
             public function where_am_i()
             {
                         echo 'Where am i? '.$this->where.'
'
;
             }
             public function thanksgiving()
             {
                         echo "

Home - it's party time!!

"
;
             }
}

$film = new planesTrainsAutomobiles;
$film->show();
?>
Vote up this code0

May 17, 2011 | Thriller | submitted by Rich Holdsworth

Memento


    //Set up the base vars
    $sceneCount=23;
    $currentScene=1;
    $brainBlownCounter=0;
   
   
    //Assemble the scenes
    while($currentScene <= $sceneCount)
    {
        $scenes[] = 'Scene '.$currentScene;
        $currentScene++;
    }
   
    //Make this film special
    array_reverse($scenes);
   
    //Play
    $sceneCounter =0;
    foreach ($scenes as $somethingThatHappened)
    {
        $sceneCounter++;
   
        $leonardsMemory = $somethingThatHappened;
   
        echo 'We see '.$somethingThatHappened.'
'
;
        echo 'Your brain is now '.(($sceneCounter / count($scenes) * 100)).'% blown.

'
;
   
        $leonardsMemory=NULL;
    }
   
   
    //TODO: Remember Stanley Ipkiss
?>
Vote up this code1

| Comedy | submitted by Phillip David Penny

Ace Ventura: Pet Detective


    $characters = array();
   
    $characters['good'] = 'Finkle';
    $characters['bad'] = 'Einhorn';
   
    $situation = 'Realisation';
   
    if($situation == 'Realisation'){
        echo 'Einhorn is ' . $characters['good'];
        echo 'Finkle is ' . $characters['bad'];
        echo $characters['bad'] . 'is a man?!?!?!';
    }
?>
Vote up this code2

May 14, 2011 | Action | submitted by Ben Howdle

Die Hard


    $characters = array();
   
    $characters['good'] = 'John McClane';
    $characters['bad'] = 'Hans Gruber';
   
    $situation = 'Hostage situation';
   
    if($situation == "Hostage situation"){
        echo "Winner = " . $characters['good'];
        echo "Loser = " . $characters['bad'];
    }
    else {
        $didNotFallOfARoof = $characters['bad'];   
    }

?>
Vote up this code0