by alexirpan · 2y ago · 0 comments
https://www.wolframalpha.com/input?i=plot+%28n%21%29%5E2+vs+...
To be more specific - you get to O(n^2
2^n*2^n) by doing dynamic programming, which lets you avoid recomputing extra work for considering future ordering possibilities. This approach still implicitly considers all possible future orderings and acts optimally with respect to that.You can read the original post for more details - at a high level you are building a cache of win probabilities assuming optimal play, starting from the base case of 1-player crew battles, and extending it by 1 match per step of the recursion until you get back to the top-level problem. It is sufficient to only do computation 1 step ahead if you have a cache for how to act optimally for all n future steps.
Yes dynamic programming is indeed faster than brute force and I think I can convince myself this is the same approach with a little thought.
I think everything we said here was correct (yes both of us) but I was responding to an incorrect understanding of your strategy (you aren't doing one step ahead you are indeed calculating total expectations).
The brute force was just to show that the overall problem size was small when n is 6, in spirit of the original comment, and that brute force was just fine.
That is the standard interpretation of x^y^z. Interpreting it as
(x^y)^z
doesn’t make sense as that is equal to the simpler and shorter x^(yz)
(https://math.stackexchange.com/a/1633800)You can also put four spaces in front of the line to automatically escape all formatting characters.
*this has four spaces in front of it and no escape characters*