Your skill will accomplish what the force of many cannot |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
The PGA was the Perl Golf Apocalypse at the 4th Perl Conference. Uri Guttman has kindly sent me the questions in order to replay the tournament here at PerlMonks. The tournament was arranged into 17 "holes". Each hole had a stated level of difficulty and a time limit. The time limit doesn't apply here but they have been left in as an indication of the pressure that the contestants were under. The holes will be submitted in three rounds over three weeks. The PGA suggested solutions for each round will be published before each new round. We can also turn this into a competition. Send me a /msg if you wish to take part. I will keep track of the scores over the whole course and setup a leadership table. Even if you haven't played Perl Golf before you should try one or two of these. Dijkstra notwithstanding, Perl Golf is a good way to learn some of Perl's dustier features and if nothing else it will probably get you to read the perlrun manpage. Notes: 1. The aim of the tournament is the shortest solution on each hole. You should publish your score with each solution. Counting is as follows: 2. "use strict" and -w are not required. 3. All subroutines which should return a single scalar value will be called in a scalar context. Thanks again to Uri and the others who contributed to the PGA. Uri's Perl Golf page is here. ROUND 1: Holes 1-6 Hole 1 - Fifth Word Write a Perl subroutine which returns the fifth word in a string. A word is any sequence of letters, numbers, and/or underscores. The string will be passed as the sole argument and will contain at least 5 words. * Difficulty: Easy * Time: 3 minutes Hole 2 - Error Message Write a Perl one-liner that prints the following to STDERR:
* Difficulty: Easy * Time: 3 minutes Hole 3 - Smallest Repeating Pattern Write a subroutine that accepts a string which may consist of a repeating pattern, and returns the smallest repeating substring. If the string does not consist of a repeating pattern, the subroutine should return undef or the empty string. e.g.: * Difficulty: Easy * Time: 4 minutes Hole 4 - Hex to Char Write a subroutine which, given a string consisting entirely of hexadecimal digits, converts pairs of digits to their ASCII character equivalents and returns the result as a list of characters. The hexadecimal digits A-F may appear in upper or lower case. There will be an even number of digits in the string. e.g. * Difficulty: Easy * Time: 4 minutes Hole 5 - Max without Sort Write a subroutine that accepts a list of numbers, and returns the maximum number from the list, without using Perl's built-in sort. * Difficulty: Easy * Time: 4 minutes Hole 6 - Vowel Sort Write a subroutine that accepts a list of words, and returns the list sorted by the first *vowel* that appears in each word. If two words have the same first vowel, it does not matter which is sorted first. Words will be in lowercase and will always contain at least one vowel. (Vowels are a, e, i, o, and u.)
* Difficulty: Easy * Time: 5 minutes They get harder. ;-) John. -- In reply to PGA Golf, Round 1 by jmcnamara
|
|