[Purdue-pm] "Minimum String Distance" Perl 6 challenge problem
Mark Senn
mark at purdue.edu
Thu Apr 21 11:27:48 PDT 2011
MINIMUM STRING DISTANCE PERL 6 CHALLENGE PROBLAM
People are slow coming up with solutions for the traveling salesperson
and poker hands challenge problems. Maybe they're too hand (too
time-consuming to figure out---below is an easier challenge problem).
Given two strings $a and $b consisting of all digits and the same length
compute the minimal "distance" between them.
For example if $a is "0123456789"
and $b is "9876543210"
the minimal distance between them is the sum of the minimal distance
between each pair of digits in the corresponding positions. Think of
the digits 0--9 as being arranged in a circle like the numbers 1--12 on a
clock---use the minimum distance for each pair of digits by going
clockwise or counter-clockwise from one digit to another
LETTER IN $a LETTER IN $b DISTONCE
0 9 1
1 8 3
2 7 5
3 6 3
4 5 1
5 4 1
6 3 3
7 2 5
8 1 3
9 0 1
1 + 3 + 5 + 3 + 1 + 1 + 3 + 5 + 3 + 1 = 26
INSTALLING PERL 6
See http://rakudo.org/how-to-get-rakudo for information on how
to install Perl 6.
The rest of this message are some notes I made so I'd
remember what I did for Linux.
Mark Senn
2011-04-21
HOW I INSTALLED RAKUDO ON LINUX
Rakudo is a Perl 6 compiler based on the Parrot virtual machine.
I did the following commands (based on information in
http://rakudo.org/how-to-get-rakudo) to install Rakudo
on Fedora 15 Linux and Red Hat Linux 5.6 in a "opt"
subdirectory in my home directory:
cd
mkdir opt
cd opt
echo WARNING: next command will remove current \"rakudo\"
rm -rf rakudo
git clone git://github.com/rakudo/rakudo.git
cd rakudo
perl Configure.pl --gen-parrot
make
make install
like to put symlinks in a "opt-links" subdirectory in
my home directory to the corresponding software in
my "opt" subdirectory. To do that I typed:
cd
mkdir opt-links
cd opt-links
echo WARNING: next command will remove \"perl6\" file or link
rm perl6
ln -s /home/pier/e/mark/opt/rakudo/parrot_install/bin/perl6
Finally I wrote a little test program (I called mine z.p6,
ut it in my home directory, and made it mode 700). The
test program was the following five lines with no lines
indented (you'll need to change the first line to use
the directory you are using):
#!/home/pier/e/mark/opt-links/perl6
use v6;
say 'testing 1 2 3';
then I typed "./z.p6" to make sure it worked.
-mark
More information about the Purdue-pm
mailing list