New answers tagged


Graph canonization is well-studied, and there are sophisticated algorithms for it; see The standard answer is to use existing, well-tuned software, such as Nauty, rather than trying to invent your own. How to implement in Python is out of scope of this site (but I would investigate API bindings or running it ...


I made a Monte Carlo tree search (MCTS) algorithm for the travelling salesman problem inspired by this paper which explains how to do such thing. However the algorithm described in the paper is very slow and needs a lot of improvement. I'll try to improve it by shortening the playoff/playout phase and adding some local optimization in the playout


Given $i$, you could find an index $j$ verifying $i \leqslant j < n$ such that $A[i] + A[j] = k$ using a binary search. This would result in a total complexity $\mathcal{O}(n\log n)$. This is only possible if the array is sorted. Note that it can even be done in linear time, with one index working from the left and one from the right. For $k=0$, with ...

Top 50 recent answers are included