The optimal solution is obtained from this code; moreover, the code is very well written and commented almost everywhere, so it was very easy to be able to understand it.
The clear difference between dijkstra and A* in the speed of reaching the optimal solution is shown.
Cons
The only cons I have noticed is that the if condition if new_state in frontier and state_cost[new_state] > state_cost[state] + cost: in the function search(.), which is used to update the cost of a state that is already inside the frontier, should be unnecessary, in fact it should never happen that a state that is already in the frontier has two different costs, since the cost is defined as the length of the state or as the length of the state + the missing number of elements to reach the goal and this always remains the same.
Peer Review
Pros
Cons
if new_state in frontier and state_cost[new_state] > state_cost[state] + cost:
in the functionsearch(.)
, which is used to update the cost of a state that is already inside the frontier, should be unnecessary, in fact it should never happen that a state that is already in the frontier has two different costs, since the cost is defined as the length of the state or as the length of the state + the missing number of elements to reach the goal and this always remains the same.