# Current Hiring Puzzles

 Rebus Generator A rebus is a phrase or sentence expressed all or in part through pictures. For this puzzle, you will use pictures from this archive (use the included file "images.txt" to map pictures to the associated words). Write a program that will take an English sentence (here’s a list of test cases for you to use) and generate a rebus from it. Here’s a simple example:   That is, each word becomes a parenthesized expression with up to three components: a word corresponding to a picture from the clipart library, a sequence of letters to be added to the name of the picture, and a sequence of letters to be deleted from the name. Distinguish words used as pictures from other sequences of letters by prepending a colon. The order of letters must match: the letters to be added must be in the order in which they would appear in the target word, and the letters to be deleted must be in the order in which they appear in the image name. Your program should produce plain text output. But there’s more to the puzzle than that. Suppose we charge 5 points for every consonant you add or delete, and 1 point for every vowel. Now come up with a rebus that costs the fewest points. The example above costs 57 points, but this rebus of the same phrase: costs only 31 points. Finally, you can reduce the cost even further by adding or subtracting images (which cost nothing) instead of letters. If you use recursive encodings, you can get rid of letters altogether. For instance, a recursive rebus for “solve” is:     Write a program to generate recursive rebuses like the one above. Your program may use a mix of letters and pictures; balance performance against optimal scores as you see fit. Even for all-picture rebuses, a shorter rebus is better.

 BitVector Genealogy The BitVectors are an ancient and immortal race of 10,000, each with a 10,000 bit genome. The race evolved from a single individual by the following process: 9,999 times a BitVector chosen at random from amongst the population was cloned using an error-prone process that considers each bit independently, and flips it with 20% probability. Write a program to guess the reproductive history of BitVectors from their genetic material. The randomly-ordered file `bitvectors-genes.data.gz` contains a 10,000 bit line for each individual. Your program's output should be, for each input line, the 0-based line number of that individual's parent, or -1 if it is the progenitor. Balance performance against probability of mistakes as you see fit. To help you test your program, here is a much smaller 500 x 500 input dataset:`bitvectors-genes.data.small.gz`, along with its solution file: `bitvectors-parents.data.small`.
 Roll Your Own Chat Server Implement a simple standalone TCP-based chat server, using the following protocol: The server responds to all commands with either: ``` OK ``` or, when an error occurred, with: ``` ERROR ``` indicates the bytes '\r\n'. Upon connecting to the server, the client sends: ``` LOGIN ``` Clients can create new chatrooms or join existing chatrooms (chatrooms begin with the character '#') by doing: ``` JOIN # ``` Clients can leave chatrooms by sending: ``` PART # ``` Clients can be in multiple chatrooms at once. Clients can send a message to a chatroom: ``` MSG # ``` Clients can send a message to another user: ``` MSG ``` When a message is sent to a chatroom the user is in, the server sends to the appropriate client: ``` GOTROOMMSG # ``` or if the message is sent directly from one user to another: ``` GOTUSERMSG ``` Finally, the client can log off by sending: ``` LOGOUT ``` Here's a transcript of a sample session where a user named "alice" joins a chatroom called #news after connecting. C indicates the line was sent by the client, S indicates it was sent by the server (end of line indicates CRLF was sent): C: LOGIN alice S: OK C: JOIN #news S: OK C: MSG #news hi everyone S: GOTROOMMSG bob #news nothing much happened after that S: OK S: GOTROOMMSG alice #news hi everyone S: GOTUSERMSG carol hi alice, where've you been? C: MSG carol on vacation S: OK C: LOGOUT When implementing the server, aim for scalability and robustness. (Many submissions fail due to lack of robustness!) Your submission should include a description of the steps you took towards those two goals. Keep in mind that the client may be buggy, or even malicious. For example, if a client connects to the server and sends an infinite stream of the byte 'X' with no line break, the server should deal with this case gracefully. Please do not use an existing networking framework (e.g., Twisted or asyncore for Python, ACE for C++, etc.) to implement the server. The server should support running on Linux.

 The O'Hare Affair Objective You want to meet a friend at O'Hare airport at noon and return home the same day. Given a date and an origin airport, find the pair of nonstop flights that gets you to Chicago and home again on that date, minimizing your total time away from home, subject to the constraint that you are at O'Hare at noon.  Details Your program, which must be written in Java, will work by scraping our http://matrix2.itasoftware.com website. Your program should accept two command-line inputs as follows:  java -jar OHareAffair.jar YYYY-MM-DD airportCode The program should navigate to matrix2.itasoftware.com and pose a round-trip query between the given airportCode and O'Hare (ORD), limited to nonstop flights only, using BOS as the sales city, with appropriate date and time constraints. The program should then scan the resulting solution set for solutions that meet the objective specified above. No more than 15 http requests should be made of matrix2.itasoftware.com per invocation. Finally, details of the three shortest solutions (breaking ties arbitrarily) should be written out in human-readable form to the console. For example, for a traveler from Baltimore on July 4th, your program might be invoked as follows:  java -jar OHareAffair.jar 2006-07-04 BWI Sample output: Travelling round-trip from BWI to ORD on 2006-07-04: Trip length: 6:21 Outbound: American Airlines Flight AA3991 (10:03a-11:04a) Return: United Airlines Flight UA1236 (1:30p-4:24p) Trip length: 6:39 Outbound: United Airlines Flight UA641 (9:45a-10:47a) Return: United Airlines Flight UA1236 (1:30p-4:24p) Trip length: 6:54 Outbound: American Airlines Flight AA3991 (10:03a-11:04a) Return: American Airlines Flight AA4009 (2:09p-4:57p) Strive to make your code clean and robust, and to report errors cleanly. Be sure to include your source, any necessary libraries, and instructions on how to run it.
Strawberry Fields

Strawberries are growing in a rectangular field of length and width at most 50. You want to build greenhouses to enclose the strawberries. Greenhouses are rectangular, axis-aligned with the field (i.e., not diagonal), and may not overlap. The cost of each greenhouse is \$10 plus \$1 per unit of area covered.

Write a program that chooses the best number of greenhouses to build, and their locations, so as to enclose all the strawberries as cheaply as possible. Heuristic solutions that may not always produce the lowest possible cost will be accepted: seek a reasonable tradeoff of efficiency and optimality.

Your program must read a small integer 1 ≤ N ≤ 10 representing the maximum number of greenhouses to consider, and a matrix representation of the field, in which the '@' symbol represents a strawberry. Output must be a copy of the original matrix with letters used to represent greenhouses, preceded by the covering's cost. Here is an example input-output pair:

 Input Output 4 ..@@@@@............... ..@@@@@@........@@@... .....@@@@@......@@@... .......@@@@@@@@@@@@... .........@@@@@........ .........@@@@@........ 90 ..AAAAAAAA............ ..AAAAAAAA....CCCCC... ..AAAAAAAA....CCCCC... .......BBBBBBBCCCCC... .......BBBBBBB........ .......BBBBBBB........

In this example, the solution cost of \$90 is computed as (10+8*3) + (10+7*3) + (10+5*3).

Run your program on the 9 sample inputs found in this file and report the total cost of the 9 solutions found by your program, as well as each individual solution.

 Word Rectangle Write a program to find the largest possible rectangle of letters such that every row forms a word (reading left to right) and every column forms a word (reading top to bottom). Words should appear in this dictionary: WORD.LST (1.66MB). Heuristic solutions that may not always produce a provably optimal rectangle will be accepted: seek a reasonable tradeoff of efficiency and optimality.