From mark at purdue.edu Fri Apr 1 20:33:27 2011 From: mark at purdue.edu (Mark Senn) Date: Fri, 01 Apr 2011 23:33:27 -0400 Subject: [Purdue-pm] challenge problems: "xoker" hands Message-ID: <29791.1301715207@pier.ecn.purdue.edu> "Xoker" is "extended poker". I just made that name up. A possible challege problem for the May meeting is to compare two xoker hands and print "1" or "2" for if the first hand or second hand wins. See http://www.pokerlistings.com/poker-hand-ranking for poker hand ranking. Xoker has the additioal rules to rank hands. See the rest of this message for the additional rules. (I'm wondering if it would be easier to have Perl code figure this out directly or have Perl code reads a rule set and uses that rule set to do the real work.) Suits are not ranked equally. In decreasing order of value: club diamond hearts spades Xoker is played with one deck of the normal 52 cards. After 10 cards are dealt (it's a two person game), all the cards are shuffled before the next hand. Each card has two parameters: a rank and a suit. Ranks are 2 3 4 5 6 7 8 9 10 j q k a Suits are c d h s Input to compare two hands is of the form, for example 10c 8d ah 2s kd / 10s as ad 2h jd 7d hand 1 is before the "/", hand 2 is after the "/". Your program should do extensive error checking. After the "One Pair" ranking but before the "High Card" rankig insert: Rainbow: red card, black card, red card, black card, red card. Example: jh 8d 7d 4h ad (aces can be high or low) Bainbow: black card, red card, black card, red card, black card. Example: kc 10d 8c 5d 2s (aces can be high or low) Straight2: like a "Straight" except instead of adjacent cards it is "every other" card. Example: as qs 10d 8h 6d (aces can be high or low) Straight3: like a "Straight" except instead of adjacent cards it is "every third" card. Example: ks 10d 7d 4s ah Primes: Prime number cards. Example: 2s 3d 5h 7d jh Example: 3d 5h 7d jh kh Fibonacci: Fibonacci number cards, k 8 5 3 2 of any suit. Example: kc 8d 5d 3c 2c Con you think of any other crazy rules to add? -mark From mark at ecn.purdue.edu Sun Apr 10 12:52:35 2011 From: mark at ecn.purdue.edu (Mark Senn) Date: Sun, 10 Apr 2011 15:52:35 -0400 (EDT) Subject: [Purdue-pm] more about "xoker" hands challenge Message-ID: <201104101952.p3AJqZGL021232@pier.ecn.purdue.edu> UPDATE On 2011-04-09 Joe Kline suggested changing the card rank "10" to "t" so all card ranks would be one character. So, 10c 8d ah 2s kd / 10s as ad 2h jd 7d becomes tc 8d ah 2s kd / 10s as ad 2h jd 7d There are 15,820,024,220 ways to choose 10 cards from 52 cards. Because of that I wanted to fnd a more compact representation of hands. I made the following improvements (continuing from above) tc 8d ah 2s kd 10s as ad 2h jd 7d tc8dah2skd10sasad2hjd7d Finally, I wanted to compress each card representation from two bytes to one byte. To do that I gave each rank a number 0--12 and each suit a number 0--3. I wanted each card representation to be a printable character so one could see it easily and so it would not be confused with newline character. I did that using the chr((1 << 6) | ($nrank << 2) | ($nsuit)) expression below. Below is the program I'm running to produce all the possible combinations. It has produced only about 5% of the output so far. ===== program starts with next line #!/usr/bin/perl # revised 'enumerate.pl 2011-04-10 Mark Senn http://engineering.purdue.edu/~mark' # created 'enumerate.pl 2011-04-10 Mark Senn http://engineering.purdue.edu/~mark' use feature 'say'; use Math::Combinatorics; my @rank = qw(2 3 4 5 6 7 8 9 t j q k a); my @nrank = qw(0 1 2 3 4 5 6 7 8 9 10 11 12); my @suit = qw(c d h s); my @nsuit = qw(0 1 2 3); my @card = (); foreach $nrank (@nrank) { foreach $nsuit (@nsuit) { push @card, chr((1 << 6) | ($nrank << 2) | ($nsuit)); } } my $comb = Math::Combinatorics->new( count => 10, data => [@card], ); while (my @dealt = $comb->next_combination) { say @dealt; } ===== program ends with previous line -mark ORIGINAL MESSAGE To: purdue-pm at pm.org From: Mark Senn Date: Fri, 01 Apr 2011 23:33:27 -0400 Subject: [Purdue-pm] challenge problems: "xoker" hands "Xoker" is "extended poker". I just made that name up. A possible challege problem for the May meeting is to compare two xoker hands and print "1" or "2" for if the first hand or second hand wins. See http://www.pokerlistings.com/poker-hand-ranking for poker hand ranking. Xoker has the additioal rules to rank hands. See the rest of this message for the additional rules. (I'm wondering if it would be easier to have Perl code figure this out directly or have Perl code reads a rule set and uses that rule set to do the real work.) Suits are not ranked equally. In decreasing order of value: club diamond hearts spades Xoker is played with one deck of the normal 52 cards. After 10 cards are dealt (it's a two person game), all the cards are shuffled before the next hand. Each card has two parameters: a rank and a suit. Ranks are 2 3 4 5 6 7 8 9 10 j q k a Suits are c d h s Input to compare two hands is of the form, for example 10c 8d ah 2s kd / 10s as ad 2h jd 7d hand 1 is before the "/", hand 2 is after the "/". Your program should do extensive error checking. After the "One Pair" ranking but before the "High Card" rankig insert: Rainbow: red card, black card, red card, black card, red card. Example: jh 8d 7d 4h ad (aces can be high or low) Bainbow: black card, red card, black card, red card, black card. Example: kc 10d 8c 5d 2s (aces can be high or low) Straight2: like a "Straight" except instead of adjacent cards it is "every other" card. Example: as qs 10d 8h 6d (aces can be high or low) Straight3: like a "Straight" except instead of adjacent cards it is "every third" card. Example: ks 10d 7d 4s ah Primes: Prime number cards. Example: 2s 3d 5h 7d jh Example: 3d 5h 7d jh kh Fibonacci: Fibonacci number cards, k 8 5 3 2 of any suit. Example: kc 8d 5d 3c 2c Con you think of any other crazy rules to add? -mark _______________________________________________ Purdue-pm mailing list Purdue-pm at pm.org http://mail.pm.org/mailman/listinfo/purdue-pm From gizmo at purdue.edu Sun Apr 10 20:00:18 2011 From: gizmo at purdue.edu (Joe Kline) Date: Sun, 10 Apr 2011 23:00:18 -0400 Subject: [Purdue-pm] more about "xoker" hands challenge In-Reply-To: <201104101952.p3AJqZGL021232@pier.ecn.purdue.edu> References: <201104101952.p3AJqZGL021232@pier.ecn.purdue.edu> Message-ID: <4DA26EC2.5060509@purdue.edu> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 04/10/2011 03:52 PM, Mark Senn wrote: > UPDATE > > On 2011-04-09 Joe Kline suggested changing the card rank "10" to "t" > so all card ranks would be one character. So, > 10c 8d ah 2s kd / 10s as ad 2h jd 7d > becomes > tc 8d ah 2s kd / 10s as ad 2h jd 7d > > There are 15,820,024,220 ways to choose 10 cards from 52 cards. Because > of that I wanted to fnd a more compact representation of hands. I made > the following improvements (continuing from above) > > tc 8d ah 2s kd 10s as ad 2h jd 7d > tc8dah2skd10sasad2hjd7d > > Finally, I wanted to compress each card representation from two bytes to > one byte. To do that I gave each rank a number 0--12 and each suit a > number 0--3. I wanted each card representation to be a printable character > so one could see it easily and so it would not be confused with newline > character. I did that using the > chr((1 << 6) | ($nrank << 2) | ($nsuit)) > expression below. > I was looking through Perl Poker modules and came across a Base 64 representation of the cards. http://search.cpan.org/~pip/Games-Cards-Poker-1.2.565CHh5/Poker.pm#NOTES joe -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk2ibsEACgkQb0mzA2gRTplbewCgnwkpcB/GQU2WPMxni7ODuVYx T08An04XZJUSGpNWwxEbihLVoXneiYZF =yCdS -----END PGP SIGNATURE----- From mark at ecn.purdue.edu Mon Apr 11 04:43:42 2011 From: mark at ecn.purdue.edu (Mark Senn) Date: Mon, 11 Apr 2011 07:43:42 -0400 Subject: [Purdue-pm] more about "xoker" hands challenge In-Reply-To: <4DA26EC2.5060509@purdue.edu> References: <201104101952.p3AJqZGL021232@pier.ecn.purdue.edu> <4DA26EC2.5060509@purdue.edu> Message-ID: <19251.1302522222@pier.ecn.purdue.edu> > I was looking through Perl Poker modules and came across a Base 64 > representation of the cards. > > http://search.cpan.org/~pip/Games-Cards-Poker-1.2.565CHh5/Poker.pm#NOTES Thanks. I'll change my stuff to take advantage of 4 * 13 = 2 * 26 (4 suits, 13 ranks, 2 cases (upper and lower), 26 letters): LETTER DESCRIPTION A--M 2--A clubs N--Z 2--A diamonds a--m 2--A hearts n--z 2--A spades (Digits could be used for jokers but we don't need to worry about those.) (I plan to do my compare two hands solution without using any modules to compare the hands. Will be writing a simple engine so I can specify, for example, A? A? A? B? B? to specify a full house. (The ?'s mean match any suit...they'll be error checking code before this to make sure the only legal hands were "dealt".) -mark From mark at purdue.edu Mon Apr 11 05:05:03 2011 From: mark at purdue.edu (Mark Senn) Date: Mon, 11 Apr 2011 08:05:03 -0400 Subject: [Purdue-pm] improved description of xoker engine Message-ID: <22952.1302523503@pier.ecn.purdue.edu> (the following obsoletes my previous message, only the last paragraph was changed, sorry for resend) > I was looking through Perl Poker modules and came across a Base 64 > representation of the cards. > > http://search.cpan.org/~pip/Games-Cards-Poker-1.2.565CHh5/Poker.pm#NOTES Thanks. I'll change my stuff to take advantage of 4 * 13 = 2 * 26 (4 suits, 13 ranks, 2 cases (upper and lower), 26 letters): LETTER DESCRIPTION A--M 2--A clubs N--Z 2--A diamonds a--m 2--A hearts n--z 2--A spades (Digits could be used for jokers but we don't need to worry about those.) (I plan to do my compare two hands solution without using any modules to compare the hands. Will be writing a simple engine so I can specify, for example, A? A? A? B? B? to specify a full house. (The A's all match the same rank which can be any rank, the B's all match the same (but different from A) rank, and the ?'s mean match any suit...they'll be error checking code before this to make sure the only legal hands were "dealt".) -mark From gizmo at purdue.edu Thu Apr 14 07:20:50 2011 From: gizmo at purdue.edu (Joe Kline) Date: Thu, 14 Apr 2011 10:20:50 -0400 Subject: [Purdue-pm] OT: for the bio folks Message-ID: <4DA702C2.9080805@purdue.edu> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Interesting look at where wet labs are...possible. http://www.boingboing.net/2011/04/14/biopunk01.html -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Using GnuPG with Red Hat - http://enigmail.mozdev.org/ iD8DBQFNpwLBb0mzA2gRTpkRAs34AJ40MTEX5EgLtqEUd9qvJ2H8b4t7HwCbBYgW T86Kebi3WoYSoLvgHxwq5jk= =F3Cd -----END PGP SIGNATURE----- From gizmo at purdue.edu Thu Apr 14 12:47:10 2011 From: gizmo at purdue.edu (Joe Kline) Date: Thu, 14 Apr 2011 15:47:10 -0400 Subject: [Purdue-pm] txt2re Message-ID: <4DA74F3E.6000203@purdue.edu> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Visual regular expression creator http://www.boingboing.net/2011/04/14/automatically-genera.html -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Using GnuPG with Red Hat - http://enigmail.mozdev.org/ iD8DBQFNp089b0mzA2gRTpkRAgiGAJ9ZP3WM+5VHNwUzl3RHip73HO+urwCgiECz +5kHlWt7C8aILKyuGMHHxF0= =LfoH -----END PGP SIGNATURE----- From bradley.d.andersen at gmail.com Thu Apr 14 13:27:05 2011 From: bradley.d.andersen at gmail.com (Bradley Andersen) Date: Thu, 14 Apr 2011 16:27:05 -0400 Subject: [Purdue-pm] txt2re In-Reply-To: <4DA74F3E.6000203@purdue.edu> References: <4DA74F3E.6000203@purdue.edu> Message-ID: here's what i always use: http://gskinner.com/RegExr/ On Thu, Apr 14, 2011 at 3:47 PM, Joe Kline wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Visual regular expression creator > > http://www.boingboing.net/2011/04/14/automatically-genera.html > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.5 (GNU/Linux) > Comment: Using GnuPG with Red Hat - http://enigmail.mozdev.org/ > > iD8DBQFNp089b0mzA2gRTpkRAgiGAJ9ZP3WM+5VHNwUzl3RHip73HO+urwCgiECz > +5kHlWt7C8aILKyuGMHHxF0= > =LfoH > -----END PGP SIGNATURE----- > _______________________________________________ > Purdue-pm mailing list > Purdue-pm at pm.org > http://mail.pm.org/mailman/listinfo/purdue-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gizmo at purdue.edu Thu Apr 21 06:41:20 2011 From: gizmo at purdue.edu (Joe Kline) Date: Thu, 21 Apr 2011 09:41:20 -0400 Subject: [Purdue-pm] Perl 5.14. RC1 Message-ID: <4DB03400.7060304@purdue.edu> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 It looks like a new Perl is getting ready to pop. The changes coming: http://search.cpan.org/dist/perl-5.14.0-RC1/pod/perldelta.pod It mostly looks like Unicode fixes are the big deal but there are a few interesting changes: non-destructive substitution http://search.cpan.org/dist/perl-5.14.0-RC1/pod/perldelta.pod#Non-destructive_substitution package block syntax http://search.cpan.org/dist/perl-5.14.0-RC1/pod/perldelta.pod#package_block_syntax given return values http://search.cpan.org/dist/perl-5.14.0-RC1/pod/perldelta.pod#given_return_values joe -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Using GnuPG with Red Hat - http://enigmail.mozdev.org/ iD8DBQFNsDQAb0mzA2gRTpkRApqvAJ9Hl9Qw00OoZj27GgUXDo3/OzNp2ACeL+6Q Vc+HoX0msNjLmatvTgw3Bfg= =Z6BK -----END PGP SIGNATURE----- From mark at purdue.edu Thu Apr 21 11:27:48 2011 From: mark at purdue.edu (Mark Senn) Date: Thu, 21 Apr 2011 14:27:48 -0400 Subject: [Purdue-pm] "Minimum String Distance" Perl 6 challenge problem Message-ID: <26044.1303410468@pier.ecn.purdue.edu> 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 From mark at purdue.edu Tue Apr 26 06:10:54 2011 From: mark at purdue.edu (Mark Senn) Date: Tue, 26 Apr 2011 09:10:54 -0400 Subject: [Purdue-pm] Perl is Alive Message-ID: <16379.1303823454@pier.ecn.purdue.edu> The "Perl is Alive" website is at http://perlisalive.com/ It states "Rumours of my death have been greatly exaggerated." The site aims to "provide a counter-point to the oft-repeated myth that 'Perl is dead', by collecting real-world stories and case studies about large-scale, high-profile, or otherwise interesting Perl systems." Thought you might be intereted. -mark From mark at purdue.edu Thu Apr 28 06:55:36 2011 From: mark at purdue.edu (Mark Senn) Date: Thu, 28 Apr 2011 09:55:36 -0400 Subject: [Purdue-pm] new Rakudo Star Perl 6 Message-ID: <14146.1303998936@pier.ecn.purdue.edu> Purdue Perl Mongers, I've been using the Rakudo implementation of Perl 6. It is (get ready for it, because I hardly ever use this word) awesome. A much better language than Perl 5 in my opinion. Even if you don't use Perl you may want to keep tabs on Perl 6---my guess is other languages will borrow features from it. If there is time after the other talks at the next Perl Mogers meeting on May 17 (see http://pm.purdue.org/Wiki/wiki.pl for details) I'll be givig a talk on "A Perl 6 Grammar for Home Automation" that uses the new Perl 6 grammar feature to simplify input parsing. I'll also show how to use other new features of Perl 6. -mark Here is the announcement for the new Rakudo Star implementation of Perl 6. I haven't tried using this new version yet. >Date: Wed, 27 Apr 2011 23:25:16 -0500 >From: "Patrick R. Michaud" >To: perl6-compiler at perl.org, perl6-language at perl.org, perl6-users at perl.org, > parrot-dev at lists.parrot.org >Subject: Announce: Rakudo Star 2011.04 released >User-Agent: Mutt/1.5.20 (2009-06-14) >X-ECN-MailServer-VirusScanned: by amavisd-new >X-ECN-MailServer-Origination: x6.develooper.com [207.171.7.86] >X-ECN-MailServer-SpamScanAdvice: DoScan > >On behalf of the Rakudo and Perl 6 development teams, I'm happy to >announce the April 2011 release of "Rakudo Star", a useful and usable >distribution of Perl 6. The tarball for the April 2011 release is >available from . > >Rakudo Star is aimed at "early adopters" of Perl 6. We know that >it still has some bugs, it is far slower than it ought to be, and >there are some advanced pieces of the Perl 6 language specification >that aren't implemented yet. But Rakudo Perl 6 in its current form >is also proving to be viable (and fun) for developing applications >and exploring a great new language. These "Star" releases are >intended to make Perl 6 more widely available to programmers, grow >the Perl 6 codebase, and gain additional end-user feedback about the >Perl 6 language and Rakudo's implementation of it. > >In the Perl 6 world, we make a distinction between the language >("Perl 6") and specific implementations of the language such as >"Rakudo Perl". The April 2011 Star release includes release #40 >of the Rakudo Perl 6 compiler [1], version 3.3.0 of the Parrot >Virtual Machine [2], and various modules, documentation, >and other resources collected from the Perl 6 community. > >This release of Rakudo Star adds the following features over the >previous Star release: > * Modules MiniDBI, form, HTTP::Daemon, Yaml and Module::Tools are > removed in this release. > * New modules Pies (including panda, the module installer) and > HTTP::Server::Simple have been added. > * New implementation of IO::Socket::INET, with basic IPv6 support > * -p and -n command-line options are now available > * Many new IO improvements, including stat-related methods > * New --ll-backtrace command-line switch for printing PIR level stack traces > * Preliminary implementation of Infix 'orelse' > * Added Str.indent > * Bugfixes to negation meta operator > * Support for complex conjugation > >There are some key features of Perl 6 that Rakudo Star does not >yet handle appropriately, although they will appear in upcoming >releases. Some of the not-quite-there features include: > * nested package definitions > * binary objects, native types, pack and unpack > * typed arrays > * macros > * state variables > * threads and concurrency > * Unicode strings at levels other than codepoints > * pre and post constraints, and some other phasers > * interactive readline that understands Unicode > * backslash escapes in regex <[...]> character classes > * non-blocking I/O > * most of Synopsis 9 > * perl6doc or pod manipulation tools > >In many places we've tried to make Rakudo smart enough to inform the >programmer that a given feature isn't implemented, but there are >many that we've missed. Bug reports about missing and broken >features are welcomed at . > >See http://perl6.org/ for links to much more information about >Perl 6, including documentation, example code, tutorials, reference >materials, specification documents, and other supporting resources. >An updated draft of a Perl 6 book is available as > in the release tarball. > >The development team thanks all of the contributors and sponsors >for making Rakudo Star possible. If you would like to contribute, >see , ask on the perl6-compiler at perl.org >mailing list, or join us on IRC #perl6 on freenode. > >Rakudo Star releases are created on a three-month cycle, or as >needed in response to important bug fixes or improvements. >(The Rakudo compiler will continue with monthly releases.) >The next planned release of Rakudo Star will be in July 2011. > >[1] http://github.com/rakudo/rakudo >[2] http://parrot.org/ From gizmo at purdue.edu Fri Apr 29 07:14:50 2011 From: gizmo at purdue.edu (Joe Kline) Date: Fri, 29 Apr 2011 10:14:50 -0400 Subject: [Purdue-pm] lazy sprintf Message-ID: <4DBAC7DA.9080202@purdue.edu> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I just might have to use this. :-) http://www.samuelkaufman.com/blog/2011/04/29/lazy-sprintf-in-perl/ joe -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Using GnuPG with Red Hat - http://enigmail.mozdev.org/ iD8DBQFNusfZb0mzA2gRTpkRAsWcAKCaPwuN29b0Apl+WI8WC+c1tANmSwCgkBuP MQve5F7eq3aeltq68YkKWo4= =q45m -----END PGP SIGNATURE-----