programming

programming

trident765 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun 1 year ago

This problem has no solution. The cards added to the top of the deck makes the shuffling of one size deck too different from the other. So there is no pattern that can be observed and exploited.

Of course, I am sure a Silicon Valley scum will be able to solve this by applying some bizarre mathematical trick. But knowledge of these mathematical tricks has little use in the real world.

I had a friend who was good at solving these types of problems but he a dumbass when it came to common sense. First he lost a bunch of money by investing in obscure cryptocurrencies. And when psychopaths took over my department at work he was completely oblivious to what was happening. He embraced liberalism with all his heart, and believed that those who spread disinfo about the vaccine are a threat to society.

fschmidt[S] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun 1 year ago

Of course there is a solution. And while a little math is needed, the core insight isn't mathematical.

This problem served me well while western culture was still sane. I got good programmers by using it. But it is no longer useful because the main issue with programmers now is values, not out-of-the-box thinking.

trident765 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 1 fun 1 year ago

Ok I solved it by recognizing that the result of shuffling n times is the mapping indices to perform n shuffles. So I precomputed the first n shuffles (I used 400000 for n), and then bulk shuffled the fast way that I just described until I got a result that was in the precomputed shuffles.

fschmidt[S] 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 1 fun 1 year ago

What answer did you get? If the answer is 400001 then how would you find it?

trident765 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 1 fun 1 year ago

I got 5812104600.

If the answer is 400001 then how would you find it?

After the 2nd bulk shuffle the deck would be at the 800000th shuffle. If the answer is 400001, then the 800000th shuffle will be identical to the 399999th shuffle, so I will find the 800000th (399999th) shuffle in the precomputed table, and then this would tell me to subtract 800000 - 399999 = 400001.

Here is my code:

https://pastebin.com/YTjL9d1i