a workable not optimized brute-force solver