solved. basic brute force solution with minimal optmization.