Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

10
  • \$\begingroup\$ Please either clarify what the ambiguity is that remains or remove the hold on my question. I believe I have corrected everything you asked, and aside from that I don't believe it violates the rules in any way. \$\endgroup\$ Commented Jan 23, 2017 at 23:07
  • \$\begingroup\$ Can you give an example with n=9, m=7? (If you can then there's a further ambiguity, which is what the distribution of the random cycles should be: I presume it's selecting a random set of valid derangements such that each set is selected with equal probability assuming a perfect random number generator, but that's not entirely clear; however, the task being actually possible is a much bigger problem). \$\endgroup\$ Commented Jan 23, 2017 at 23:17
  • \$\begingroup\$ An answer for n=9, m=7 is {{5, 3, 4, 2, 0, 7, 8, 6, 1}, {2, 0, 8, 6, 5, 3, 1, 4, 7}, {1, 4, 6, 7, 8, 2, 3, 0, 5}, {8, 6, 0, 4, 7, 1, 2, 5, 3}, {3, 7, 5, 1, 2, 0, 4, 8, 6}, {4, 5, 7, 8, 3, 6, 0, 1, 2}, {6, 8, 3, 5, 1, 4, 7, 2, 0}} \$\endgroup\$ Commented Jan 24, 2017 at 1:57
  • \$\begingroup\$ I cleared up ambiguity and stated that all the different ways of doing it with m cycles of length n should have the same probability of occurring \$\endgroup\$ Commented Jan 24, 2017 at 2:05
  • 1
    \$\begingroup\$ "The fastest algorithm (in time complexity) wins." There's two parameters here, m and n, so it's not clear how to compare tradeoffs between these. If you mean for m to be linear in n, that would resolve it. \$\endgroup\$ Commented Jan 24, 2017 at 5:11