Train fare calculator with a weekend cap

0
Remix

A train line runs through stations G, U, H, K and I in that order. Each hop between neighbouring stations costs 1, so a trip costs the number of hops it covers (G to I costs 4). Build it in three steps: a fare function for one trip, then let the list of stations change, then cap what a rider pays over a weekend.

AmazonCodingLast asked Aug 2026
No answer yet. Write the first one; the best answer gets endorsed.