Talk:Find the missing permutation: Difference between revisions

no edit summary
(Can't find the missing element)
No edit summary
Line 1:
== Perl shuffle ==
An odd observation...I used a [[Perl]] script derived from the [[Knuth shuffle]] task to shuffle an ordered list of permutations. I find it interesting that the left two columns show a greater vertical repeat frequency and length than the right two columns. --[[User:Short Circuit|Michael Mol]] 06:32, 24 December 2009 (UTC)
: Looking at it, I suspect that the Perl impl of that task has a bug in it; it doesn't appear to always guarantee to consider shuffling the first element. (I think. I might have also misread it.) For the Tcl version, what I did was do some frequency analysis to check whether the shuffle was fair; we shuffled the list 1,2,3,4,5 a hundred thousand times and counted up the total for each position in the list across all the runs; when the total for each column was close to 300k, we had a reasonable estimate that there weren't any subtle errors. (We checked for gross errors by eyeballing it.) My perl is very rusty though, so I'm not quite sure how to write the same thing. Perhaps later...
Line 13 ⟶ 14:
print "totals: @tot\n"</lang>
I get totals that indicate that things are OK. Not sure what's wrong then, if anything. Don't think it really matters though; the list of permutations doesn't have an ''obviously'' missing element, so a short program is indeed the best way to find the missing item. –[[User:Dkf|Donal Fellows]] 10:31, 24 December 2009 (UTC)
:I wrote that function. I based it closely on the Wikipedia pseudocode, and I was especially careful to avoid fencepost errors. I'm pretty sure it's correct. —[[User:Underscore|Underscore]] ([[User talk:Underscore|Talk]]) 12:56, 24 December 2009 (UTC)
== Prototype Tcl Solution ==
 
845

edits