This simulation is given finding the minimum numbers of patrollers, given patroller's coverage and position of the weak points. The weak points are the weak points on the wall that needs to be fixed. The wall is circular, and that's why there exists additional push_back when creating create_dist_btw_wp.
I stored the distances between weakpoints as vector<int>, and tried to test all permutations of the patrollers.
During refactoring, I've come to an idea that nested for loop inside do_while loop seems overkill and wanted to change this into simple for loop.[line 31:55]
What I've tried doesn't seem to work, and I can't see the difference between these two.
Was my original idea that this can be done in 1 dimensional for loop is of problem? or my implementation is wrong?
Not exactly sure what the code is supposed to do. Some additional comments inside the function would help. Maybe explain the purpose of each loop. Also explain why you are creating permutations of weak points around a wall. I don't understand why weak points around a wall (presumably fixed locations) can be permuted to be in different orders (thus not fixed locations).
Stating that a nested loop looks like overkill does not justify removing it. Discovering a logical error or a redundancy can justify removing the nested loop. You may be correct--I don't have the time to do the analysis.
What I see here is a O(n! * n^2) algorithm. The outer loop doing the next_permutation is O(n!). Each of the inner loops is O(n).
By removing the nested loop, you are removing 1 level of complexity. So, the algorithm will not run the same.
Take a few minutes to write down in English what each version of the algorithm does, then write down how you expect the second version to compensate for the reduced complexity. You need more analysis than "seems overkill" and some hand waving.