bruteforce algorithm and simulation