1. The more the merrier:
You are organising 2 parties. At one point it suddenly occurs to you: if people come to parties to have fun, why hold two when you can have everybody in one. There’s twice the fun and you don’t have to work twice as hard. You need to merge the 2 guest lists. They are both sorted alphabetically. You need a program to merge them so that the combined list is still sorted alphabetically.
Input 2 lines, each containing a list of names sorted alphabetically, output a combined list of names sorted alphabetically.
2. Lonely librarian:
You are the only librarian in the school library. You get sick of keeping record of new books and writing labels, you decide to create some automation. You want to keep entering names of new books, until at one point you enter ‘end’, so the automation stops. For each book entered, it’s added to your record, unless the same name already exists in the record. When the automation stops, it prints a list of all the books entered.
Input a series of book names, output the list of books entered.
Extension:
People make mistakes, a lonely librarian makes more. When you discover a mistake, instead of entering the name of the book, you enter ‘del’ followed by the name of the book incorrectly entered. The book is then removed from your list.
Input a number of book names and delete commands, output the final list of books.
3. Bond, James Bond:
You live a double life. During the day you are the lonely librarian, but when you are off and nobody sees you, you are James Bond the MI6 secret agent, the King's spy, with a license to kill.
You can't let others know the content of your communication with M, the head of MI6. You have a secret code book jamesbondscodebooktopsecretcantletanybodyseebecauseitsnotencrypted.txt. The book contains many lines, each containing the plain text word followed by its code word. Example:
hungry *&%#
bored 78534
irritated buzzinga!
So that a message like 'I am always hungry or bored or irritated' will be translated to 'poop am always *&%# or 78534 or buzzinga!'
Input a line of message you need to send to M. Use the code book to translate it word by word to the secret form and output the translated line. Repeat this process until a blank line is input.
No comments:
Post a Comment