main.swift449 chars15 lines
In this code, we first split the input string into an array of components using the components(separatedBy:)
method with whitespace as the separator. Then, we create an empty array to store the groups of three characters.
We use a nested for loop to iterate over each component and each group of three characters within each component. For each component, we convert the string to an array of characters and iterate over the array in groups of three characters. We append each group of three characters to the GroupsOfThreeChars
array.
Finally, we print the GroupsOfThreeChars
array to the console.
gistlibby LogSnag