Ayende's interview question, coded in Swift
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Ayende's interview question

Coded in Swift, as an excercise.

The task is described here.

We have the following file (the full data set is 276 MB), that contains the entry / exit log to a parking lot.

Image from ayende.com blog

The first value is the entry time, the second is the exit time and the third is the car id.

Details about this file: This is UTF8 text file with space separated values using Windows line ending.

What we need to do is to find out how much time a car spent in the lot based on this file.

The data and the original solution are included inside /task directory. You need to unzip it before you start. There is also short.txt, which is a smaller dataset, suitable for testing.


cd cloned-project-directory
unzip task/data.zip -d task/
swift build
./.build/debug/ayende ./task/data.txt 
# or
./.build/debug/ayende < ./task/data.txt 


There seems to be a bug with StreamReader which corrupts console output in some cases. You're better off using the stdin method.