import Foundation
func move_first_word_to_end_of_string(_ s: String) -> String {
let parts = s.split(whereSeparator: { $0.isWhitespace }).map(String.init)
if parts.count <= 1 {
return s.trimmingCharacters(in: .whitespacesAndNewlines)
}
let first = parts[0]
let rest = parts.dropFirst()
return (rest + [first]).joined(separator: " ")
}
let s = "Would you like to know more? (Explore and learn)"
let result = move_first_word_to_end_of_string(s)
print(result)
/*
run:
you like to know more? (Explore and learn) Would
*/