News for hackers. Stuff that matters.
Re:Project Euler by mdp2021 on Monday October 14, 2024 @08:09PM (#41843596)
No. It's 20!/(10!x10!)

You have 20 slots to be filled with 10 items vs other 10 items.

Re:Project Euler by noapologies on Monday October 14, 2024 @08:20PM (#41843664)
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.

Re:Project Euler by mdp2021 on Monday October 14, 2024 @08:26PM (#41843698)
Oops! 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.

Re:Project Euler by dotancohen on Tuesday October 15, 2024 @04:14AM (#41846175)
Now 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.