Problem 1 - Blown Fuses ----------------------- Most people don't realize how much power it takes to run a lab full of computers. Computers consume enough power that if you are not careful, you can easily blow a fuse. Calculating how much power is needed for a lab is a simple process, but it can be time consuming if you have to do it again and again. A local group of electricians, the Adept Circuit Makers guild, feels that they have wasted too much time calculating power requirements for computer labs, so they have asked you to write a piece of software to help them with their calculations. In order to do the calculations you will need to know a few facts: A. The average computer consumes 1.5 amperes, the average monitor consumes 1.0 amperes, the average printer consumes 2.0 amperes, and the average router consumes 0.5 amperes. Every computer has a single monitor. B. Fuses are made in 10 amp increments; i.e., there are 30 amp fuses and 40 amp fuses, but no 35 amp fuses. C. The electrical code requires that each lab must use a fuse rated at least two times the average ampere load for the equipment in that lab. Given these figures, you are to write a program that will read as input the number of computers, the number of printers, and the number of routers. Your program should then calculate and print out the size of the smallest fuse for that lab. Remember that fuses only come in ampere ratings that are multiples of 10 amperes. Input: three integers - the number of computers, the number of printers, and the number of routers, in that order Output: a single integer - the minimum fuse size required for the lab. Your program should then output the word "amperes" followed by a newline character and then quit. Example 1 --------- Input: 10 2 1 Output: 60 amperes Example 2 --------- Input: 5 4 0 Output: 50 amperes Problem 2 - The Year 2000 Computer Problem ------------------------------------------ Computers are evolving at an incredible pace, and savvy business people know that it is important to keep up with the times in order to be successful. Many software companies keep up with all the changes and are quite successful. Unfortunately, some companies just seem to march to the beat of a drummer that only they can hear. Take, for example, Applied Cryogenic Marmalade. As the name implies, they are confused about a great many things. The information systems managers at Applied Cryogenic Marmalade heard about the "Y" to "K" (Y2K) problem and decided to do something about it. They wrote a wonderful piece of software that converted all the letter Ys to letter Ks, and all the letter Ks to Ys. Proud of their achievement, they used the software to change all their internal memos. When they showed off their product at a conference, the sound of the laughter could be heard for miles. As you might imagine, the software turned out to be quite useless and a major embarrassment, so they deleted all copies of it. Unfortunately, all of their internal memos now have the word MONDAK in place of MONDAY, SHIPPING DOCY instead of SHIPPING DOCK, and so on. They have hired you (in their infinite wisdom) to write a piece of software to fix their memos. You are to write a program that inputs text, finds the letters K and Y, and switches them back to normal. Input - no more than 25 lines of no more than 80 uppercase letters, numbers, spaces, periods, commas, and newline characters. (There will be no lower case letters or other symbols.) The end of the input will be denoted by an exclamation point character. Output - exactly the same thing as the input, with two exceptions. First, all the letter Ks are to be replaced with Ys, and all the letter Ys are to be replaced with Ks. Second, a blank line at the end, after the final exclama- tion point. Remember to echo everything including spaces, newlines, and the final exclama- tion point. The only thing you should change is the letters K and Y. (In other words, do not add any output of your own or you'll get it wrong.) Example ------- Input: ----- TUESDAK, FEBRUARK 8 DEAR SIR, REGARDING THE SHIPMENT ON MONDAK, IT WAS LATE AND ARRIVED ON WEDNESDAK. PLEASE MAYE SURE THAT IN MAK WE DO NOT HAVE THE SAME PROBLEMS WITH THE SUNDAK OR WEDNESDAK SHIPMENTS. ALSO, PLEASE TRACY THE MISSING PACY THAT WAS SCHEDULED FOR LAST JULK. SINCERELK, KIN NAY ! Output: ------ TUESDAY, FEBRUARY 8 DEAR SIR, REGARDING THE SHIPMENT ON MONDAY, IT WAS LATE AND ARRIVED ON WEDNESDAY. PLEASE MAKE SURE THAT IN MAY WE DO NOT HAVE THE SAME PROBLEMS WITH THE SUNDAY OR WEDNESDAY SHIPMENTS. ALSO, PLEASE TRACK THE MISSING PACK THAT WAS SCHEDULED FOR LAST JULY. SINCERELY, YIN NAK ! Problem 3 - Cellular Biology Meets Junk Food -------------------------------------------- Computer programmers are surely messy folks. Have you ever looked down into a keyboard? Look at all that junk in there, probably mostly bits of Twinkies and Doritos. One young scientist, A. Cynthia McTavish is working on a solution to this problem. She is trying to develop a bacteria that will be able to live on Twinkie bits and Dorito crumbs. And she is very close to a solution, but somehow many of her cultures got mixed up! She needs your help in identifying the cultures. Each of her culture dishes starts out on day #1 with one brand new bacterium. These bacteria are quite special - they live forever! When one is placed in a culture dish, it is dormant for one day and then starts to divide. After the first day, the cell divides exactly once every day. Thus, the first bacterium will divide on days #3, #4, #5, and so on. All new bacteria (generated from a division) behave in the same way. The new bacterium born on day #3 will produce a new one on days #5, #6, #7, and so on. Hence, assume that Cynthia puts one bacterium in a dish on day #1. On day #2 there would still be one cell, on day #3 there would be two cells, on day #4 there would be three cells, etc. On day #7 there would already be 13 cells of bacteria. Remember that each newly created bacteria cell rests one day before beginning to divide; it starts dividing after 2 days and does so on every following day. (Hint: There is a simple pattern here. See if you can work it out.) Ms. McTavish has encountered one problem with her experiment. Some dishes have been contaminated. She has figured out that it is possible to determine if a dish is contaminated by counting the number of bacteria. If the number is not in the series described in the previous paragraph (1, 1, 2, 3, ...), she knows the sample is bad. To help Cynthia, you are to write a program that will read in integer counts of bacteria in culture dishes, and reports back how many days the dishes have been active. If the number of of bacteria is not valid, your program should report that the dish has been contaminated. Input - a series of integers between 2 and 25000, one per line. Each integer represents the number of bacteria in a culture dish. A zero will be used to indicate the end of the input. Output - one output, on a separate line, for each input (except the zero). If the input is a valid member of the series, output the string "Day #" followed by the day number for that culture dish. If an input number is not valid, output the word "Contaminated" instead. Example input: Example output: 2 Day #3 21 Day #8 5 Day #5 12 Contaminated 14 Contaminated 55 Day #10 0 Problem 4 - Text to Speech -------------------------- The Association of Crayon Manufacturers has decided to develop a text-to- speech system in order to aid several of their VPs who cannot read. After the software was designed, they laid off the entire development team before they realized there was more work to be done. That's where you come in. The problem is that the system states numbers such as 300 as "three zero zero", which tends to confuse many of the upper level management using it. Your task will be to write a program that translates a number into its proper English representation (i.e., "three hundred") so the system can say numbers in a way that's more understandable. Input - one positive integer, which will be less than or equal to 1 billion with no commas or leading 0s Output - the words (all in lower case letters) that would be sent to the text-to-speech engine as shown in the examples below. Example 1 --------- Input: 14179000 Output: fourteen million one hundred seventy nine thousand Example 2 --------- Input: 0 Output: zero Example 3 --------- Input: 111111111 Output: one hundred eleven million one hundred eleven thousand one hundred eleven Example 4 --------- Input: 17 Output: seventeen Example 5 --------- Input: 595 Output: five hundred ninety five Example 6 --------- Input: 10000001 Output: ten million one Problem 5 - Measuring Chemicals ------------------------------- Automated Chemical Mixing company has just finished their core project - a device for pouring out a specific amount of a hazardous chemical without human intervention. They didn't realize they needed software support for it until it was too late, so you've been called in to help. The machine has an input tank (where thousands of gallons of the chemical are stored), and output tank (where the measured chemical should go), and three smaller containers (labeled C1, C2, C3) of varying size that can be used for measuring. The idea is to use the three containers to move a predetermined amount of the chemical from the input tank to the output tank. You are allowed to fill any of the three containers from the input tank, dump any of them into the output tank, dump any of them back into the input tank, or dump any of them into any other container. In the last case, you may only dump enough to fill the second container; none must be spilled! There are 15 possible operations, represented by the letters A through O. A - empty C1 into output tank J dump C1 back into input tank B - dump C1 into C2 * K dump C2 back into input tank C - dump C1 into C3 * L dump C3 back into input tank D - empty C2 into output tank M fill C1 from input tank E - dump C2 into C1 * N fill C2 from input tank F - dump C2 into C3 * O fill C3 from input tank G - empty C3 into output tank H - dump C3 into C1 * I - dump C3 into C2 * * Dumping one small container into another consists of filling the second container as much as possible with the contents of the first, leaving the remaining chemical, if any, in the first container. For example, let's say that C1 holds 4 gallons and C2 holds 5 gallons. If you fill C2 from the input tank and dump as much as possible into C1, C1 would have 4 gallons, and C2 would have 1 remaining gallon. Your task is to write a program that generates a set of commands, using the letters in the table above, that describes how to get the proper quantity of chemical from the input tank to the output tank, given the size of the three containers and the amount of chemical needed in the output tank You do not have to dump any chemical remaining in the three containers. Input - four integers representing the sizes of the containers and the amount required (T) in the following order: C1 C2 C3 T The containers will all be less than 100 gallons in size, and the output tank will require less than 1000 gallons. Output - a sequence of characters (fewer than 1000) that represent commands that would fill the output tank to the required depth, followed by a '*' and a newline. Do not put spaces between characters or generate any other output! You may assume that a solution will always be possible. Example ------- Input: 2 5 8 1 Output: OIHG* Here is a list of the operations that will be performed by this sequence: O - Fill C3 (the 8 gallon container) I - Dump 5 gallons from C3 to C2, leaving 3 gallons in C3 H - Dump 2 gallons from C3 to C1, leaving 1 gallon in C3 G - Dump the remaining 1 gallon from C3 into the output tank