Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Document examples for wsg category
  • Loading branch information
Paul Cochrane committed Apr 10, 2015
1 parent 533535f commit a294ef5
Show file tree
Hide file tree
Showing 8 changed files with 603 additions and 3 deletions.
112 changes: 112 additions & 0 deletions categories/wsg/advanced-2008/event001-eric256.pl
@@ -1,5 +1,117 @@
use v6;

=begin pod
=TITLE Could I Get Your Phone Number?
=AUTHOR Eric Hodges
In Could I Get Your Phone Number? competitors are given a phone number and
then—using the letters found on a standard phone dial—construct a word in
which the letters correspond to the numbers in the phone number.
Event Scenario
As you probably know, phone numbers can be difficult to remember; that’s why
many companies and organizations use mnemonic devices – such as acronyms and
jingles – to make their phone numbers a little more memorable.
What’s that? Can we give you an example of one of those mnemonic devices?
You bet we can. For example, suppose the Scripting Guys had the phone number
727-4787. That’s hard to remember; therefore, the Scripting Guys might tell
people to dial SCRIPTS instead. The word SCRIPTS – in which the letters in
the word correspond to the numbers in the phone number – is a mnemonic
device: it makes it easier for you to remember something.
Good question: how do you get SCRIPTS out of a phone number like 727-4787?
Well, on a standard phone dial, the digits 2 through 9 have all been
assigned letter values in addition to their numeric value:
=begin table
Digit Letter Values
===== =============
2 A B C
3 D E F
4 G H I
5 J K L
6 M N O
7 P R S
8 T U V
9 W X Y
=end table
It’s these corresponding letter values that enable us to derive the word
SCRIPTS from of the phone number 727-4787:
=begin table
7 S
2 C
7 R
4 I
7 P
8 T
7 S
=end table
That’s pretty cool; SCRIPTS is way easier to remember than 727-4787. On the
other hand, trying to figure out which word – if any – can be made from a
given phone number is kind of challenging. What would really be cool is
script that can convert a phone number to a word.
Now, try to guess what you need to do for Event 1 in the Advanced Division.
Good guess. Your task in Event 1 is this: given a seven-digit phone number
(e.g., 732-3464), create a seven-letter word corresponding to those digits.
Keep in mind that you can only use the three letter values that correspond
to each digit. For example, the word you create for 732-3464 must start with
the letter P, R, or S. Why? Because the phone number starts with the number
7, and, on the standard phone dial, those three letters are the only letters
associated with the number 7. In case you’re wondering, one possible
solution for 732-3464 is the word READING:
=begin table
7 3 2 3 4 6 4
= = = = = = =
R E A D I N G
=end table
To receive credit for this event you must come up with a seven-letter word;
any other use of the seven letters (for example, a four-letter word plus a
three-letter word) will not be accepted. In addition, the word must appear
in the file WordList.txt, an official word list that is included as part of
the Scripting Games’ Competitors Pack. On top of that, keep in mind that: 1)
although there might be multiple solutions for a given phone number your
script should only display one solution; and 2) the script should only
display a correct solution. Please don’t display all possible solutions; for
example, don’t do this:
PDBEGMH
READING
SFCFHOI
If you do, we’ll have to disqualify your entry. Instead, display only a
single correct solution, like so:
READING
Your script must prompt the user to enter a phone number (either via the
command line or using an Input box). When the scripts are tested, phone
numbers will be entered without the hyphen; thus the number 732-3464 will
actually be entered into the program like this:
7323464
In other words, you do not need to include code that removes the hyphen from
the phone number; the hyphen will never appear in the phone number. Oh, and
when your script reads from the file WordList.txt (trust us: your script
will need to do that) make sure this file is in the folder C:\Scripts. If
the file is in any other folder, your script will likely fail when we test
it.
L<http://web.archive.org/web/20080321224441/http://www.microsoft.com/technet/scriptcenter/funzone/games/games08/aevent1.mspx>
=end pod

my $input-file = $*PROGRAM_NAME.IO.dirname ~ "/wordlist.txt";
my %dict = ( ($input-file.IO.slurp.split("\n").grep: {.chars == 7}) X 1);

Expand Down
65 changes: 65 additions & 0 deletions categories/wsg/advanced-2008/event002-eric256.pl
@@ -1,5 +1,70 @@
use v6;

=begin pod
=TITLE Skating on Thin Ice
=AUTHOR Eric Hodges
In Skating on Thin Ice competitors must write a script that determines the
winner of a figure skating competition.
Event Scenario
If you’re likely the Scripting Guys, your fondest wish in life is to be able
to judge a figure skating contest. Event 2 in the Advanced Division is proof
that wishes really do come true.
OK, if you want to get picky, you don’t actually get to judge a figure
skating contest; the judging has already been done for you. Instead, all you
have to do is determine who actually won the contest, using a formula
roughly similar to that used by the International Skating Union. Sounds fun,
huh?
To determine the winner your script must use the scoring information found
in the text file Skaters.txt (which can be found in the Scripting Games
Competitors’ Pack). Each line in the text file consists of information for
an entrant in the competition; more specifically, each line contains the
skater’s name followed by the scores awarded by each of the seven judges:
Ken Myer,55,66,76,67,59,70,54
To calculate Ken Myer’s score you (or, more precisely, your script) must do
the following:
=item Throw out the highest of his seven scores (76).
=item Throw out the lowest of his seven scores (54).
=item Average the remaining five scores (55, 66, 67, 59, and 70).
Thus Ken Myer would receive a score of 63.4 (55 + 66 + 67 + 59 +70, all
divided by 5).
To receive credit for this event your script must report back the winners of
the gold (skater with the highest score); silver (skater with the
second-highest score); and bronze (skater with the third-highest score)
medals, along with their score. Your final output should look similar to
this:
Gold medal: Ken Myer, 63.4
Silver medal: Pilar Ackerman, 62.78
Bronze medal: Jonathan Haas, 61.8272
If another of your fondest wishes is to successfully complete this event,
make sure you place the file Skaters.txt in the folder C:\Scripts; if you
use any folder other than C:\Scripts then your script is likely to fail.
Also, you must display the results in the command window; do not overwrite
the file Skaters.txt. If you do overwrite the file, you will not receive any
points for the event. (And we won’t be very happy with you, because you’ll
have overwritten our copy of the file!)
Note that your script does not have to include code for handling ties. We’ve
set up the scores to make sure that there won’t be any ties for the top 3
positions.
L<http://web.archive.org/web/20080325083541/http://www.microsoft.com/technet/scriptcenter/funzone/games/games08/aevent2.mspx>
=end pod

my @lines = slurp("skaters.txt").split("\n");

my %skaters ;
Expand Down
145 changes: 145 additions & 0 deletions categories/wsg/advanced-2008/event005-eric256.pl
@@ -1,5 +1,150 @@
use v6;

=begin pod
=TITLE You Call That a Strong Password?
=AUTHOR Eric Hodges
In You Call That a Strong Password? competitors must write a script that,
based on the supplied criteria, determines the strength of a password.
Event Scenario
In this day and age, people are encouraged to use “strong” passwords any
time they need to create or change a password. That’s good advice, but it
also leads to a couple of questions: 1) what exactly is a strong password,
and 2) along the same lines, how can we tell whether a given password is
strong or not? Event 5 is designed to help you answer those two questions.
In this event you will create a script that can determine the “strength” of
a password. Password strength will be determined by submitting the password
to the following checks. The script must do all of the following:
=item B<Make sure that the password is not an actual word.> The password
rhubarb fails this test because rhubarb is an actual word. To determine
whether a word is an actual word or not, always use the file WordList.txt,
an official word list that is included as part of the Scripting Games
Competitors’ Pack. (Make sure you put this file in the folder C:\Scripts.)
Note that this check should be case-insensitive: not only is rhubarb an
actual word but so is RHUBARB, rhUBArb, etc.
=item B<Make sure that the password, minus the last letter, is not an actual
word.> For example, the password rhubarb5 fails this test because, if you
remove the last letter, the remaining string value – rhubarb – is an actual
word. This check should be case-insensitive.
=item B<Make sure that the password, minus the first letter, is not an actual
word.> For example, the password @rhubarb fails this test because, if you
remove the first letter, the remaining string value – rhubarb – is an actual
word. This check should be case-insensitive.
=item B<Make sure that the password does not simply substitute 0 (zero) for the
letter o (either an uppercase O or a lowercase o).> For example, the password
t00lb0x fails this test. Why? Because if you replace each of the zeroes with
the letter O you’ll be left with an actual word: toolbox.
=item B<Make sure that the password does not simply substitute 1 (one) for the
letter l (either an uppercase L or a lowercase l).> For example, the password
f1oti11a fails this test. Why? Because if you replace each of the ones with
the letter L you’ll be left with an actual word: flotilla.
=item B<Make sure that the password is at least 10 characters long but no more
than 20 characters long.> The password rhubarb fails this test because it has
only 7 characters.
=item B<Make sure that the password includes at least one number (the digits 0
through 9).> The password rhubarb%$qwC fails this test because it does not
include a number.
=item B<Make sure that the password includes at least one uppercase letter.> The
password rhubarb fails this test because it does not have an uppercase
letter.
=item B<Make sure that the password includes at least one lowercase letter.> The
password RHUBARB fails this test because it does not have a lowercase
letter.
=item B<Make sure that the password includes at least one symbol.> This can be
any character that is neither an uppercase or lowercase letter, or a number;
that would include – but not be limited to – the symbols ~, @, #, $, % and
^.
=item B<Make sure that the password does not include four (or more) lowercase
letters in succession.> The password rhubARB fails this test because it
includes four lowercase letters (rhub) in succession.
=item B<Make sure that the password does not include four (or more) uppercase
letters in succession.> The password rHUBArb fails this test because it
includes four uppercase letters (HUBA) in succession.
=item B<Make sure that the password does not include any duplicate characters.>
The password rhubarb fails this test because it has two r’s and two b’s.
This check should be case-sensitive: A and a are to be considered separated
letters. Thus the password Oboe would not fail this particular test.
Note. Yes, that is a lot to remember, isn’t it? To help you keep track of
everything we’ve included a checklist (Password_Checklist.doc) in the
Competitors’ Pack.
To successfully complete this event, your script must accept a possible
password as a command-line argument and rate that password. For example, if
you want to rate the strength of the password rhubarb33! you would start
your script using a command similar to this command:
myscript.pl rhubarb33!
Your script should start out with a password score of 13; that means that a
password that passed every single check will have a final score of 13. After
retrieving the password from the arguments collection (and we will pass the
script only one password at a time) your script should run each of the
previously-mentioned checks against that password. If the password passes a
given check (for example, the test that checks to see if the password is an
actual word) then the script should simply go on to the next test. That
should be easy enough.
Now, what happens if the password fails a given check? For example, the
password rhubarb will fail the test that says a password cannot have four
consecutive lowercase letters. In that case, the script must do two things:
=item Subtract 1 from the password score. For example, if the password score
is 11 and the script fails the check for four consecutive lowercase letters
then the password score should be lowered to 10
=item Echo back a message stating that the proposed password has failed this
test. For example, in this case you would echo back a message similar to
this:
Four consecutive lowercase letters in password.
After all the checks have been made the script should then rate the
password, using the following scale:
=item A score of 6 or less represents a weak password.
=item A score of 7, 8, 9, or 10 represents a moderately-strong password.
=item A score of 11 or more represents a strong password.
You should echo back both the score and the password rating. For example:
A password score of 4 indicates a weak password.
As an example, here’s the kind of output you should get when you check the
password rhubarb33!:
=begin code
No uppercase letters in password.
Four consecutive lowercase letters in password.
Duplicate letters in password.
A password score of 10 indicates a moderately-strong password.
=end code
That’s all you need to do.
L<http://web.archive.org/web/20080410170315/http://www.microsoft.com/technet/scriptcenter/funzone/games/games08/aevent5.mspx>
=end pod

my $input-file = $*PROGRAM_NAME.IO.dirname ~ "/wordlist.txt";
my %dict = ( ($input-file.IO.slurp.split("\n").grep: {.chars > 6}) X 1);

Expand Down

0 comments on commit a294ef5

Please sign in to comment.