Words starting with the same letter

Report a typo

Imagine playing a game with a friend: you're trying to name as many words that start with the same letter as possible. You've already named some of them. The input contains a random number of words. If all words indeed start with the same letter you need to print them all in the same order, but if at least one word starts with a different letter, print nothing.

Sample Input 1:

fish fiacko feeling french

Sample Output 1:

fish fiacko feeling french

Sample Input 2:

dish cat dear dream

Sample Output 2:

Write a program in Kotlin
fun main() {
val words: List<String> = readln().split(" ")
// output the result collection
}
___

Create a free account to access the full topic