aboutsummaryrefslogtreecommitdiff
path: root/challenge-039/duncan-c-white/README
blob: 8fe990172f212803985c02a566becadf087d8fc9 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Challenge 1: "A guest house had a policy that the light remain ON as
long as the at least one guest is in the house. There is guest book
which tracks all guest in/out time. Write a script to find out how long
in minutes the light were ON.

Guest Book

1) Alex    IN: 09:10 OUT: 09:45
2) Arnold  IN: 09:15 OUT: 09:33
3) Bob     IN: 09:22 OUT: 09:55
4) Charlie IN: 09:25 OUT: 10:05
5) Steve   IN: 09:33 OUT: 10:01
6) Roger   IN: 09:44 OUT: 10:12
7) David   IN: 09:57 OUT: 10:23
8) Neil    IN: 10:01 OUT: 10:19
9) Chris   IN: 10:10 OUT: 11:00
"


My notes: Nice question.  Looks reasonably straightforward, especially if
we may assume that the IN times are in time order (as they are in the example
data above, and would naturally be in a physical guest book, where each person
writes their name and "IN" time in the first free row.

Probably need to store the "OUT times that haven't happened yet" as
future-time diary events a la Discrete Event Simulation..  Core idea is:
store a set of users IN at the current time, and modify the set as time
passes.  Think I have a Delta Time queue Perl module somewhere to reuse.


Challenge 2: "Write a script to demonstrate Reverse Polish
notation(RPN). Checkout https://en.wikipedia.org/wiki/Reverse_Polish_notation
for more information about RPN.  (Contributed by Andrezgz) "

My notes: That's pretty open ended - but on the other hand I know RPN
very well over the years so that gives quite some scope to play:-)
An RPN evaluator, or a coventional expression->RPN translator, would
be obvious tools to build, the evaluator in particular is trivial to
do and a great opportunity to use callback functions.

BTW, almost any script in Postscript would demonstrate RPN as Postscript
is totally RPN-based, so this may is a great opportunity to go for
Postscript again:-)

I spent quite a lot of time trying to build a tiny language and translate
it to Perl and Postscript, in order to show RPN in the Postscript version,
but I ran out of time; maybe another time..