Untitled
In python, only standard library, allowed to use third-party test packages (e.g. pytest or testify) Provide test and comments where necessary ( produce production-quality code) Once done, provide all source code in zip file/tarball to be checked out and build. Provide a README file with instructions on how to build/run your program (and tests if present) Don't include the name. ////Requirements Exercise Build a billing system for a mass transit system. The transit system has a network of train stations --- each belonging to a pricing zone. A user enters (IN) or exits (OUT) --- a station is recorded. The data you are provided with is the user_id with direction either IN or OUT of the station A user can do only one journey at a time. THE STATION AND THE TIME OF ENTRY/EXIT (IN UTC) FOR ALL JOURNYES IS GIVEN IN TIME PERIOD. You can assume the data is sorted by timestamp but not nessecarily by users. You are tasked with calculating the total charge for each customer at the end of the period. Each journey has a £2 base fee, and additional costs based on the entry and exit zones. Zone | In / Out additional Cost 1. £0.80 £0.50 £0.30 £0.10 Examples: The price of a journey from zone 1 to zone 1 is 2.00 + 0.80 + 0.80 = £3.60. The price of a journey from zone 6 to zone 4 is 2.00 + 0.10 + 0.30 = £2.40. For any erroneous journeys where an IN or OUT is missing, a £5 fee is used as the total journey price. It should be assumed that all valid journeys are completed before midnight (i.e., all valid journeys will have an IN and OUT on the same day). There is also a daily cap of £15, and a monthly cap of £100. Caps include all journey costs and fees, and once a given cap is reached the customer pays no extra for the given day or month. Expected cmd to run: <your_program> <zones_file_path> <journey_data_path> <output_file_path> Expected Output: each user_id and their billing_amount (to 2 decimal places) written to output_file_path in user_id alphanumeric increasing order (e.g., [‘23Charlie’, ‘alpha’, ‘bravo’]) as shown in the example output file. E.g. to run a Python solution: python my_solution.py zone_map.csv journey_data.csv output.csv or for a Go solution: go run main.go zone_map.csv journey_data.csv output.csv Input Data: Each event specifies a user_id, direction (IN or OUT), the station, and a timestamp. Active Journeys: A dictionary tracks users who have entered (IN) a station but haven't yet exited. Completed Journeys: When a user exits (OUT), the journey is completed, and the fare is calculated based on zones. Fare Calculation: Uses zone_fares to determine the cost of a journey based on the entry and exit zones. Output: Displays the details of completed journeys, including fare and station details.
Leave a Comment