Harry Potter’s World
1) I
notice that all names from Harry Potter begin with a capital letter,
then have a vowel, and continue with other letters. Write
a regular expression that matches such strings.
2) Write
a line of code that sets a cookie on the client computer. The
cookie should be good for the current session only, and then MAGICALLY
disappear.
3) (Yes/No)
Can one easily use recursion in Perl?
4) What
does the following program do?
(define (wand x)
(if (null? (cdr
x))
1
0
)
)
5) Name
one difference in how Perl and PHP treat
variables.
6) In
PHP I have an array named Quidish where the indexes are numbers but not
consecutive integers. How can I sum the
elements in the array? Write me some code
on this MAGICAL paper.
7) InPerl, I need to decide if a file exists and I
have read permission on it. Write me a
line of code that can tell if the file exists or not.
8) Name
one feature that PHP has that neither Perl,
Java, C++ nor Lisp have.
9) What does the following lisp program do?
(define (golden_snitch x)
(if (< x 1)
1
(+ 1 (/ x 2))
)
)
10)
I want to run the command 'ls -ltr' and capture it's output into a
variable named blodger. Write me some code to do this. Use
any of PHP, Perl, or Lisp. Hint ... it can be done in one easy
line.
Chose
one program from each group.
(1 point) Write me a LISP program that returns the second element of
the list.
(2 points) Write me a LISP program that returns the smallest element of
the list.
(1 point) Write me a PHP program that Ravenclaw
can use for math drills. It should accept
two numbers and print their sum.
(2 points) Write me the same program as above, but it should also keep
track of how many times the student has used it.
(1 point) Write me a Perl program that
decides if ‘Malfoy’ is a user on the system. Malfoy is a user on
the system if the file /etc/passwd contains “Malfoy:” as the first 7 characters of any line.
(2 points) Write me a Perl program that
prints the longest username on the system. The
usernames are stored in the file /etc/passwd
as the characters from the beginning of each line to the first “:”.