8 ms·
Close, it's 40!/(20!*20!) 20 Rs, 20 Ds in a 20x20 grid. Example pattern: RRDDDR...D (40 letters) Basically the number of permutations, with repetition, of 20
by noapologies 2y ago
Close, it's 40!/(20!*20!)
20 Rs, 20 Ds in a 20x20 grid.
Example pattern: RRDDDR...D (40 letters)
Basically the number of permutations, with repetition, of 20 Rs and 20 Ds.
- mdp2021 2y agoOops! Thanks, just distraction... It's that first I wanted to see the general solution to those kind of problems (and I gave the solution for a wrong one in the class), then I wanted to verify the C implementation of the solution with POPCNT like the OP seems to have done (I am writing the code)... Edit: ...and yes, it seems that brute-forcing (counting to one trillion) takes more time than I expected.
- dotancohen 2y agoNow I see it. Twenty items (R operations) in 40 slots: 40!/(20!) and the order of the items does not matter, so again divide by 20!. The remaining slots are D operations. The answer actually came to me in the shower this morning.