Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As the author notes, these numbers are upper bounds for a fixed trivial strategy. That makes me wonder, which permutations (for each size) are the most difficult to achieve using an optimal strategy? How might we solve such a problem short of brute force?


I've worked out a few such puzzles involving permutations and the answer always seems to be either "one vexatious ordering" or "half of all permutations"


A variant of bubble sort I think would work. Taking into consideration the 'rotating index', each operation would correctly order three cards within the rotating index.

In each N pass, we should see each element at least 3 times, and it must advance toward it's desired position at least once. since it can't be at the 'wrong' end of the triple multiple times.

Worst case in N^2 ops we should be done.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: