aboutsummaryrefslogtreecommitdiff
path: root/challenge-004/duncan-c-white/README
blob: c5628c24dd4e614de852f19699eca74ad1885e15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Challenge 1: "Write a script to output the same number of PI digits
as the size of your script. Say, if your script size is 10, it should
print 3.141592653."

Note that it DOESN'T SAY "calculate the same number of PI digits..." so
I took the liberty to grab them over the internet (via a bitly link I set
up to shorten the URL and hence the program) rather than generate them
on the fly, because generating Pi is so dull.

Note that ch-1.pl takes an optional single command line argument to tell
how many digits to print, if absent the default is to use the size of
the script as the question wanted.  I built two cut down versions of the
script, but didn't include them here.


Challenge 2: "You are given a file containing a list of words (case
insensitive 1 word per line) and a list of letters. Print each word from
the file than can be made using only letters from the list. You can use
each letter only once (though there can be duplicates and you can use
each of them once), you don't have to use all the letters."

This is a natural "bag of words" question, essentially we need to build
a "bag subset" operation.  See ch-2.pl for the solution, simple and obvious
(I love Perl's hashes especially for their idiomatic set and bag uses).