blob: 0220538063ca1983de3e98c2d957abe8e61bdec1 (
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
25
26
27
28
29
30
31
32
33
|
Challenge 1: "Write a script that takes 2 or more strings as command
line parameters and print the longest common substring. For example,
the longest common substring of the strings "ABABC", "ABCA"
and "BCBA" is string "BC" of length 3.
"
My notes:
Very clearly described. No obvious clever way of solving this, but the
basic method is simple.
Challenge 2: "Write a script to implement Priority Queue. It is like
regular queue except each element has a priority associated with it. In a
priority queue, an element with high priority is served before an element
with low priority. It should serve the following operations:
1) is_empty: check whether the queue has no elements.
2) insert_with_priority: add an element to the queue with an associated
priority.
3) pull_highest_priority_element: remove the element from the queue that
has the highest priority, and return it. If two elements have the same
priority, then return element added first.
"
My notes: At last, a nicely specified problem to implement a nice data
type. meat and drink to me! I've split out the Priority Queue
implementation into the module PQ.pm, minimally-OO in order to
get free magic PQ printing via interpolation and the magic of
stringification.
|