brute force solution complete