in ,

ITA's old “Hiring Puzzles” is still a treasure trove of good problems, Hacker News


        

        

            

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 ourhttp: // matrix2.itasoftware.comwebsite. 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:

            

            Traveling round-trip from BWI to ORD on 2006 – 07 – 04:
            Trip length: 6: 21
            Outbound: American Airlines Flight AA 3991 ((***************************************************: 03 a – 11: 04 a)
            Return: United Airlines Flight UA 1236 (1: (P-4:) p)
            Trip length: 6: 39
            Outbound: United Airlines Flight UA 641 (9: 45 a – 10: (a)
            Return: United Airlines Flight UA 1236 (1: (P-4:) p)
            Trip length: 6: 54             Outbound: American Airlines Flight AA 3991 ((***************************************************: 03 a – 11: 04 a)
            Return: American Airlines Flight AA 4009 (2: 09 P-4 : 57 p)

            


            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.

            

            

            

Brave Browser
Read More
Payeer

What do you think?

Leave a Reply

Your email address will not be published.

GIPHY App Key not set. Please check settings

Norilsk: Otherworldly photos of an Arctic city, Hacker News

Norilsk: Otherworldly photos of an Arctic city, Hacker News

Aishwarya Rai shares Amitabh Bachchan’s most adorable picture with granddaughter Aaradhya. See here – Hindustan Times, Hindustantimes.com

Aishwarya Rai shares Amitabh Bachchan’s most adorable picture with granddaughter Aaradhya. See here – Hindustan Times, Hindustantimes.com