Recap - Word Stats
Part of the Logic & Flow section of Coddy's Swift journey — lesson 27 of 56.
Challenge
MediumRead a single line of input: a sentence (words separated by spaces). Compute and print, on separate lines:
- The number of words longer than
3characters - The total length, in characters, of all words longer than
3(combinefilter,map,reduce) - The longest word in upper case. If two words tie, return the first one. Use
reducewith the empty string as the initial accumulator.
For input swift makes data pipelines fun, the output is:
4
23
PIPELINESTry it yourself
let words = readLine()!.components(separatedBy: " ")
// TODO: count > 3 chars; total length of those; longest word uppercased
All lessons in Logic & Flow
1Strings In Depth
Count and IndicesCase and TrimSearching in StringsSplitting and JoiningReplacing SubstringsRecap - Username Check