Programming Team:  Practice Contest, 27-Jan-05
Mt Lebanon HS 2004-5
David Kosbie


Link to the Programming Team Home Page.


Q1:  Read in a positive integer w and print out the wth prime number.

Q2:  Read in two words (all uppercase or lowercase letters and/or digits, one word per line) and output YES if they are anagrams (rearrangements of each other) and NO otherwise. You should be case insensitive, so "WAy" and "YAw" should match.

Q3: Read in two integers (one per line), x and y, with x > y > 0, and output, one per line, all the fractions a/b, where a<b and where "a" and
"b" are both in the range (x,y) (exclusively), and where the fractions are ordered from smallest to largest.
    Sample input:
            6
            2
    Sample output:
            3/5
            3/4
            4/5
If two fractions have the same value, order them so the smaller numerator is printed first.

Q4: Consider a sequence which starts with 1, 2, 3, then each subsequent number is the sum of the 3 previous numbers, so the sequence is: 1, 2, 3, 6, 11, 20, 37,.... Read in a positive integer m and print out the mth number in this sequence (so if m=4, you should output 6).

Q5: Read in a single word (all lowercase) followed by a non-negative integer n followed by n lines of a wordsearch (which will contain only lowercase letters). Output the number of times the given word occurs in the wordsearch. It can occur horizontally, vertically, or diagonally, and forwards or backwards.
    Sample input:
            dog
            3
            dogg
            oooo
            gagd
    Sample output:
            4

Q6: Regarding the sequence from Q4 (1, 2, 3, 6, 11, 20, 37,...), the first prime in the sequence is 2, the second is 3, and the third is 11.  Read in a positive integer k, and print out the kth prime in the sequence (if the answer is > 1 million, simply print out "too big").