Challenge 3: A Type Alias for a Callback — Solution typealias ValidationResult = Pair typealias Validator = (String) -> ValidationResult fun validateUsername(): Validator = { username -> if (username.length >= 3) { true to "Valid username" } else { false to "Username must be at least 3 characters" } } fun main() { val validator = validateUsername() val result1 = validator("ab") val result2 = validator("alice") println(result1) println(result2) } /* Output: (false, Username must be at least 3 characters) (true, Valid username) Notes: - ValidationResult is just a more readable name for Pair — it's fully interchangeable with that Pair type, not a distinct type, so "true to \"Valid username\"" (which produces a Pair) can be returned directly where a ValidationResult is expected. - Validator is a readable name for the function type (String) -> ValidationResult — without the alias, validateUsername()'s return type and the validator variable's type would both have to spell out "(String) -> Pair" in full, which reads far less clearly. - validateUsername() returns a lambda matching the Validator shape, and that lambda is then called twice with different usernames in main(). */