[Reader-list] redistribution.pl

Harwood Harwood at scotoma.org
Tue Nov 5 02:17:57 IST 2002


This appeared on a couple of lists a week or so ago. But might help open your
debate. 

#   Perl Routines for the redistribution of the worlds wealth 
#   Takes the cash from the rich and turn it into clean drinking water wells. 
#   w.blake at scotoma.org
#   v 0.0.1 

#   Copyright (c) 1792-2002 William Blake  
#   Unpublished work reconstituted W.Blake at Scotoma.org.
#   Permission granted to use and modify and append this library so long as the
#   copyright above is maintained, modifications are documented, and
#   credit is given for any use of the library.
#   This code is distributed under the same conditions as perl itself
#   This code is distributed with no warrenty whatsoever.
#   Thanks are due to many people for reporting bugs and suggestions

#   For more information, see http://www.scotoma.org



#Constants

my $SKINT = 0;
my $TO_MUCH = $SKINT + 1;

#This is a anonymous hash record to be filled with the Name and Cash of the rich
%{The_Rich} = {
    0 =>{
        Name        => '???',
        Cash        => '???',
    },
} 
#This is a anonymous hash record to be filled with the Price Of Clean Water
#for any number of people without clean water
%{The_Poor} = {
    0 =>{
        PlaceName           => '???', #the place name were to build a well
        PriceOfCleanWater   => '???',
        Cash                => '???',
    },
} 

# for each of the rich, process them one at a time passing 
#them by reference to RedistributeCash.
foreach my $RichBastardIndex (keys %{The_Rich}){
    &ReDisdributeCash(\%{The_Rich->{$RichBastardIndex}});
}


#This is the core subroutine designed to give away
# cash as fast as possible.
sub ReDisdributeCash {
    my $RichBasterd_REFERENCE = @_;
    
    #go through each on the poor list giving away Cash until each group
    # can afford clean drinking water
    while($RichBasterd_REFERENCE ->{CASH} >=  $TO_MUCH ){
        
        foreach my $Index (keys @{Poor}){
            $RichBasterd_REFERENCE->{CASH}--;
            $Poor->{$Index}->{Cash}++;
            if( $Poor->{$Index}->{Cash} =>
$Poor->{$Index}->{PriceOfCleanWater}){
                &BuildWell($Poor->{$Index}->{PlaceName} );
            }
            
        }
    
    }   


}



More information about the reader-list mailing list