Problem 1 --------- A local charity organization has been having a contest to see which of their agents can collect the most donations. As the contest draws to a close, bags full of coins have been arriving at the judge's desk. The contest judge, being the lazy sort that a contest judge is, doesn't want to be bothered with totaling up the sums of money and comparing the bags, so he has asked you to help out by writing a program to compare bags full of coins. The program you are to write will determine which of two bags is worth more. You will be given the number of pennies, nickels, dimes, quarters, and half dollars that are in each bag, and you are to report which bag has more money, and by how much. Input: The input to your program will be 10 numbers. The first five correspond to the coins in bag 1, and the second five correspond to the coins in bag 2. The five numbers for each bag represent, in this order, the number of pennies, nickels, dimes, quarters, and half dollars in the bag. Do not prompt for input! Output: You are to report either "The bags are the same", or "Bag N has X cents more.", where 'N' is the number of the bag with more money, and 'X' is how much more money there is in this bag than in the other bag. See below for an example. Example 1 --------- Input: 3 5 9 2 4 8 11 3 1 5 Output: The bags are the same. Example 2 --------- Input: 10 12 97 3 5 678 6 15 0 10 Output: Bag 1 has 7 cents more. Problem 2 --------- A local company has offered to hire you to help you create an operating system which will compete with Microsoft Windows. But before they give you the job, you must show them that you are a savvy programmer. They have devised a simple test to see if you understand how file systems work. Your task is to write a program which will take a relative path, and output an absolute path. A relative path is one that contains . and .. directory names. The rules they gave you for converting a relative path to an absolute path are quite simple. Apply rule one to every part of the path, then apply rule two, and so on: 1. /name -- keep as is. 2. /. -- remove both the slash and the dot 3. /../ -- remove both dots and slashes, and remove the previous name. 4. /.. -- remove both dots and the slash, and remove the previous name. Input to your program will be a pathname consisting of slashes, relative names . or .., and directory names. Normal directory names will only consist of letters, and you are guaranteed to not have two slashes next to each other. At most, an input path will be 80 characters long. All input paths begin with a /name and no sequence of /.. characters will require you to back up past this beginning slash. The output should be the smallest equivalent path, and should contain no . or .. sequences. (Follow the above rules only.) Look carefully at the following examples. Example 1 --------- Input: /windows/system/./../../fooled/ya Output: /fooled/ya Example 2 --------- Input: /home/usr/local/bin/../gnu/bin/./././. Output: /home/usr/local/gnu/bin/ Problem 3 --------- You've probably read the story of the Trojan Horse, so I won't repeat it here. The moral to the story is that things aren't always what they appear to be. In the world of computer security, a "Trojan Horse" is data that is passed across a computer network that contains information that isn't obvious to a casual observer. For example, let's say you wanted to help your old buddy Bill break out of jail at some hour of a particular day. You might arrange to send him an email with the word "Bill" included some number of times, and he would know that the number of occurrences of that word would indicate the hour of the break-out. For example, if the word "Bill" was there 4 times, you'd be there at 4:00 am to blow up the door of the jail. This problem involves a similar Trojan Horse, except the input will be a matrix (2-dimensional array) of characters plus a key word that you are to search for. The output will be the number of times you find the key word in the matrix. The catch is that the word may be written left to right, right to left, top to bottom, bottom to top, or diagonally (up or down and left or right). All letters in the array will be upper case alphas. The array will always be 8 characters by 8 characters. Letter(s) may be shared between two occurrences of the word. A palindrome will count as two occurrences of the word since it appears in both directions. (A palindrome is a word that reads the same frontwards and backwards - like BOB.) Here are two examples: Example 1 --------- Input: XBXXXXXX XXIXXXXX XXXLXXXX XXXXLXXX XXXXXIXX XXXXXXBX XXXXXXXX XXXXXXXX BILL Output: 2 Example 2 --------- Input: XXXXXXXX XXXXXXXX XBOBXXXX XBOBXXXX XBOBXXXX XXXXXXXX XXXXXXXX XXXXXXXX BOB Output: 10 Problem 4 --------- For a suspicious person, 1998 is a really scary year. The most dreaded event that such a person can face is Friday the 13th, and 1998 has three of them! It's important form some people to know ahead of time when a Friday the 13th will occur so they can avoid making important business deals that might come to fruition on one of those days and avoid conceiving a child that might be born at such a horrible time, so you have been asked to write a program that figures out how many Friday the 13ths there are in a particular year. Just in case you've forgotten, there are 365 days in a year, except that leap years have 366. Leap years are those divisible by four with one exception - years that are divisible by 100 but not divisible by 400 are NOT leap years. Hence, 2000 is a leap year, but 2100 is not. Also, you should know that January 1, 1998, was a Thursday. The input and output of your program will be very simple. Input will be a year, and output will be the number of Friday the 13ths in that year. Remember, do not prompt for an input. The year number will always be 1998 or beyond. You will not be asked to provide information on past years. Example 1 --------- Input: 1998 Output: 3 Example 2 --------- Input: 2050 Output: 1 Problem 5 --------- There are a lot of weird things in this world. There are people who believe Elvis is still alive, there are plants which eat animals, there are alien markings in fields of hay, and there are bolts of lightning shaped like basketballs that bounce around. Even mathematics has it's share of weirdness. In fact, this problem deals with the calculation of weird numbers. A number is called 'weird' if it is 'abundant' without being the sum of any subset of its proper divisors. An 'abundant' number is one that is smaller than the sum of all of its proper divisors. For example, 12 is abundant, since it's proper divisors are 1, 2, 3, 4, and 6, and 1+2+3+4+6 = 16. (Note that a number is not a proper divisor of itself.) The smallest weird number is 70. The proper divisors of 70 are 1, 2, 5, 7, 10, 14, and 35, the sum of which is 74, which is greater than 70. No subset of these values adds up to 70. Write a program that takes as an input a number, and calculates and outputs the next 'weird' number greater than that number. Your program may not take more than one minute to run on any of the cases below. SPECIAL NOTE: If your program runs more than one minute, the judges will terminate their test. If it doesn't complete within that time, we will assume that the program is in an infinite loop. In that case, the message you will get from the judges will be "No output within 1 minute." Example 1 --------- Input: 1 Output: 70 Example 2 --------- Input: 69 Output: 70 Test case 1 ----------- Input: 70 Output: ??? A number bigger than 70! Figure it out!