brute force correct solution