Archive for July, 2007

On ordering appetizers

Some random perl code I threw together:


use Data::Dumper;
use List::Util (reduce);

@p = (580, 420, 355, 335, 275, 215);
$target = 1505;
$A[0] = [0, [], 0];
foreach $i (1 .. $target) {
    my @tmp;
    foreach $a (@A) {
	next unless defined($a);
        push @tmp, [$a->[0], $a->[1], $i];
        push @tmp, [$a->[0] + $_, [@{$a->[1]}, $_], $i] foreach (@p);
    }
    @tmp = grep({$_->[0] == $i;} @tmp);

    # ok, prefer the shortes solution for no other reason
    # than 7 times mixed fruit is so boring.
    $A[$i] = reduce { if ($a->[0] == $b->[0]) {
                          @{$a->[1]} < @{$b->[1]} ? $a : $b
                      } else {
                          $a->[0] > $b->[0] ? $a : $b
                      }
                    } @tmp;
}
print Dumper($A[$target]);

Mixed fruit? You probally have to read this xkcd strip

Update: Changing the grep statement from testing for less than or equal to strict equality seems to be about 30 times faster with the same result.

Comments (3)

Aniversaries

Principia Mathematica 320 years, Spam 70 years and Debian Social Contract 10 years. Things that changed the world?

Comments (4)

SpamFighter vs. email-brugere: 1 – 0

Forbrugerombudsmanden lader SpamFighter sende uanmodet emails. SpamFighter giver mulighed for at brugeren automatisk kan anbefale sine bekendt at sætte spamfighter-brugeren på en liste over godkendte afsendere. Denne email har tidligere indeholdt en del spamfighter-rekvalme, men efter de har begrænset sig til et link til spamfighters websted mener Forbrugerombudsmanden at det ikke længere er markedsføring.

Det er lidt en sort dag at SpamFighter på denne måde får blåstemplet en sådan praksis.

Comments

Debian Social Contract 10 years and the danish connection

  1. Our priorities are pancakes and beer

    We will be guidede by our need for pancakes and (preferable free) beer. We will place this interest first in our priorities. We wil support the needs of our users for knowledge of where to get many different kinds of pancakes and beers. We will not object to other kind of food and drinks, but pancakes and beer are our main common interesst and priorities. In furtherance of this need, we will provide guidance to beer and pancakes all over the world near and far away from Denmark.

For some reason the celebration of the Debian Social Contract was centered on Denmark. So I thought we might as well organize something in Denmark for real (some of us had talked about it some days ago).

We have yet to decide if our main priority is beer or pancake so the plans aren’t quite final yet. Ølbaren has been mentioned. If you are interested in joining contact me. (Update: Ølbaren is closed for the month)

Comments