Solution for test coding question