Sei sulla pagina 1di 3

Programming Challenges - Quora

Page 1 of 3

Find Questions, Topics and People

Add Question

Programming Challenges
1. Datacenter Cooling
We have some rooms in our datacenter, and we need to connect them all with a single cooling duct. Here are the rules: The datacenter is represented by a 2D grid. Rooms we own are represented by a 0. Rooms we do not own are represented by a 1. The duct has to start at the air intake valve, which is represented by a 2. The duct has to end at the air conditioner, which is represented by a 3. The duct cannot go in multiple directions out of the intake or the AC - they must be the two endpoints of the duct. The duct must pass through each room exactly once. The duct cannot pass through rooms we do not own. The duct can connect between rooms horizontally or vertically but not diagonally. Here is an example datacenter: 2 0 0 0 0 0 0 0 3 0 0 1

A T J C P T

There are two possible ways to run the duct here: 2--0--0--0 | 0--0--0--0 | 0--0--3 1 or 2 0--0--0 | | | 0 0 0--0 | | | 0--0 3 1 Write a program to compute the number of possible ways to run the duct. For the above example, the correct answer is 2.

http://www.quora.com/about/challenges

8/10/2010

Programming Challenges - Quora

Page 2 of 3

Input format: Your program should read from stdin. The input will be a series of integers separated by whitespace. The first two integers will be W and H, with width and height of the datacenter. These will be followed by W*H more integers, specifying the 2D grid representing the datacenter. Output format: Your program should write a single integer out to stdout: the number of possible ways to run the duct. See how fast you can make it. Our best solution (written in C) can solve the following test case in under 5 seconds on a 2.4GHz Pentium 4, but it's pretty good if you can get to within 1-2 orders of magnitude of that. 7 2 0 0 0 0 0 0 3 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1

Submission Send your solutions to jobs@quora.com

2. Python URI
In Python, write a class or module with a bunch of functions for manipulating a URI. For this exercise, pretend that the urllib, urllib2, and urlparse modules don't exist. You can use other standard Python modules, such as re, for this. The focus of the class or module you write should be around usage on the web, so you'll want to have things that make it easier to update or append a querystring var, get the scheme for a URI, etc., and you may want to include ways to figure out the domain for a URL (britishsite.co.uk, us-site.com, etc.) We're looking for correctness (you'll probably want to read the relevant RFCs; make sure you handle edge cases), and elegance of your API (does it let you do the things you commonly want to do with URIs in a really straightforward way?,) as well as coding style. If you don't know Python already, then this is also an exercise in learning new things quickly and well. Your code should be well-commented and documented and conform to the guidelines in the PEP 8 Style Guide for Python Code. Include some instructions and examples of usage in your documentation. You may also want to write unit tests.

http://www.quora.com/about/challenges

8/10/2010

Programming Challenges - Quora

Page 3 of 3

Submission Send your solutions to jobs@quora.com

About

Jobs

Privacy Terms Press

Login

Sign Up

http://www.quora.com/about/challenges

8/10/2010

Potrebbero piacerti anche