Implement the function calculate_journey_cost(journey) that calculates the total cost of a journey based on the provided segments of transportation. The function will determine costs based on tube and bus fares, considering specific rules for fare application.
Input Requirements
The function takes a single parameter:
journey: a list of strings and/or other objects where each string represents a segment of travel by tube. Non-string objects represent bus travel segments.
Output Requirements
The function should return a string representing the total cost of the journey formatted in British pounds (e.g., '£X.XX'), where X.XX is the total cost rounded to two decimal places.
Cost Rules
Each tube segment incurs a fare of £2.4.
Each bus segment incurs a fare of £1.5, but there is a special condition:
A bus fare is only charged for the first bus segment encountered in sequence; subsequent bus segments in the same sequence do not incur additional fares until a tube segment is encountered again.
Example
Input: ['tube', 'tube', 'bus', 'bus', 'tube']
Output: '£6.30'
Explanation:
Two tube fares: £2.4 + £2.4 = £4.8
One bus fare: £1.5
Total: £4.8 + £1.5 = £6.3
Implementation Instructions
Write the solution in a file named /app/solution.py.
Ensure the function adheres to the specified input and output requirements.
Include comments explaining the logic and any assumptions made during the implementation.