Skip to content

mailmahee/Airbnb-Property-Search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

You will be provided with availability and pricing data for a set of rental properties.  Your program will determine the cheapest properties for a given date range in a specific geographic area.

You will read input from STDIN and print output to STDOUT.

Input:

The input is in CSV format with three sections of data.  "Properties", "Dates", and "Searches".  Each section will begin with a single line labeling the section followed by a number of lines with that section's data.

Here is a description of each section and the data columns in contains.

"Properties" - identifies possible properties for rent

• property_id - an integer
• lat - a float
• lng - a float
• nightly_price - the standard nightly price; an integer in dollars (no cents)

"Dates" - specifies dates when properties are unavailable, or when the nightly pricing differs from the standard nightly price.  If not  specified here, the property is available at the standard nightly price.

•	property_id - an integer
•	date - a date in the format YYYY-MM-DD
•	availability - 0 if the property is unavailable, 1 if the property is available
•	price - price for the night; an integer in dollars (no cents)

"Searches" - a search to be performed

•	search_id - an integer
•	lat - a float
•	lng - a float<br>
•	checkin - a date in the format YYYY-MM-DD
•	checkout - a date in the format YYYY-MM-DD

Sample Input:

Properties
1,0.29322858181353,-69.8325156543615,500
2,15.8229075627722,102.378248903003,280
Dates
1,2012-08-15,0,500
1,2012-08-26,1,700
Searches
1,0.9802496106877,-70.146252228624,2012-08-14,2012-08-21
2,0.9802496106877,-70.146252228624,2012-08-26,2012-08-28

Output:

Your program should output the properties that match each search, up to a maximum of 10 properties per search.  Some searches may return no results.

The results should be ordered by cheapest total price for the stay, also matching the availability dates and geographic filter.  (If two properties have the same total price, sort by property_id ascending).  For the geographic filter, use a bounding box that is 2 degrees square in total (ie, +/- 1.0 degrees from each coordinate).  If a property is unavailable for any date during the range, it is not a valid result.  If a property has a variable price in the specified date range, that variable price overrides the base nightly price for that night.  The total price is the sum of the nightly prices for the entire stay.

Note that properties do not need to be available on the checkout date itself, just on the day before.

Your program should produce output with the following columns.  Each result for a given search should appear on it's own line.  A search with zero results does not need to be included in the output.

search_id - integer
rank - integer (starting with 1, max of 10)
property_id - integer
total_price - the total price for the stay in dollars

Sample Output:
2,1,1,1200

You shouldn't use any kind of external database or search engine.  Your program should load the input data into memory and then use your own logic and data structures to perform the searches and generate the output.  Using libraries (such as to parse CSV files) is ok.

About

Airbnb Programming Challenge

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published