cs1520: lab 1 ============= 1. Hello World -------------- write a small perl program to print "hello perl" 2. Fibonacci ------------ The Fibonacci sequence f(n) is defined as f(0) = 0 f(1) = 1 f(n) = f(n-1) + f(n-2) Write a perl program to compute the nth fibonacci number. Find f(73). Find f(74). 3. Random Vacation Days ----------------------- The cs department annual party will be held on a random day of the week. To select the day, we will flip a 5-sided coin 1000 times. Use the following code to seed the PRNG and initialize a hash table of counts: @days = qw(mon tue wed thu fri); %counts = map{ $_ => 0} @days; srand(43); Use the following to cast a float to an integer: $myfloat = 5.5; $myint = int($myfloat); After 1000 coin flips, print the tally for each day. 4. K-Difference --------------- Create an array of integers using the following code: $max = 1000000; srand(2012); for $i (0 .. $max) { @array[$i] = int(rand($max)); } How many *unique* pairs of numbers have a difference of 2012? That is, find the number of unique pairs (x,y) such that y - x = 2012. What is the naive solution? Can you think of a better solution whose time complexity is O(n)?