kotlin-coding-challenges

Format train route

Instructions

Given list of strings representing train station names implement a function which will return passenger friendly String:

Challenge Solution

Examples

formatTrainRoute(listOf("Luton")) // "Train is calling at Luton"

formatTrainRoute(listOf("Luton", "Harpenden")) // "Train is calling at Luton and Harpenden"

formatTrainRoute(listOf("Luton", "Harpenden", "London")) // "Train is calling at Luton, Harpenden and London"