[seqfan] the revolver sequence

Tanya Khovanova mathoflove-seqfan at yahoo.com
Wed Sep 23 23:06:47 CEST 2009

Hello all,

I just submitted a sequence related to the revolver puzzle:

I generalized it to revolvers having n chambers.

I think there should be more sequences: for example, the one when it is preferable to spin and the one when the chances are the same.

Also, my programs are usually not very efficient. It will be nice if someone can add more terms to this sequence.

%I A165646
%S A165646 0,0,0,0,2,3,4,5,18,43,60,84,294,472,724
%N A165646 The revolver sequence. 
%C A165646 a(n) is in how many ways you can load a revolver with n chambers, so that if a person survives after the first shot, he/she has better chances of survival for the second shot if the shooter continues rather than spins. a(n) <= A000031(n) as A000031(n) counts the number of possible revolver loadings. 
%H A165646 Tanya Khovanova, <a href="http://blog.tanyakhovanova.com/?p=174">Heard on the Street</a> 
%e A165646 Based on the famous interview question where the revolver has six chambers and the shooter loads two adjacent bullets. As the answer to this question is to continue, a(6) must be at least 1. 
%t A165646 << Combinatorica` colors[x_] := Table[PadLeft[Table[1, {n, i}], x], {i, 0, x}] continueBetter[list_] := (len = Length[list]; c0 = 0; c00 = 0; rotateN = 0; While[rotateN < len, newList = RotateLeft[list, rotateN]; If[newList[[1]] == 0, c0++; If[newList[[2]] == 0, c00++]]; rotateN++]; If[c0 > 0, c00/c0 > c0/len, False]) continueNum[num_] := (neckNum = Length[colors[num]]; ans = 0; count = 1; While[count <= neckNum, ans = ans + Length[Select[ListNecklaces[num, colors[num][[count]], Cyclic], continueBetter[#] &]]; count++]; ans) Table[continueNum[n], {n, 2, 15}] 
%Y A165646 A000031 
%K A165646 more,nonn
%O A165646 1,5
%A A165646 Tanya Khovanova (tanyakh(AT)yahoo.com), Sep 23 2009

More information about the SeqFan mailing list