[go: up one dir, main page]

login
A102849
Position of the winner in a "5-Boom" game with n players, if all n are rational and act to stay for the longest time possible.
0
1, 1, 2, 2, 1, 5, 2, 6, 1, 5, 9, 1, 5, 9, 12, 1, 5, 9, 13, 16, 21, 3, 7, 11, 15, 19, 23, 27, 2, 6, 9, 13, 17, 21, 25, 29, 33, 37, 2, 6, 10, 14, 17, 21, 25, 28, 32, 36, 39, 43, 47, 50, 1, 5, 8, 12, 16, 20, 23, 27, 31, 35, 38, 42, 46, 50, 53, 57, 61, 65, 68, 1, 5, 9, 13, 16, 20, 24, 27, 31
OFFSET
1,3
COMMENTS
"5-Boom" goes like this: n people sit in a circle and the first player says "1" or "1,2". Then, clockwise, every player may raise the last number by one or by two. Player who's forced to say "5" is out of the game. The target of the game is to stay the longest time possible.
EXAMPLE
a(4)=2 because no matter either the first player says "1" or "1,2", the second one can bring it to 3, so the third player must say "4" and the fourth player is out of the game. Then the original second player is still the second one and since a(3)=2 he wins.
PROG
'VISUAL BASIC Public Prev(0 To 9999) Public Curr(0 To 9999) Public Num Function Winner(Num_Of_Players) Calc Num_Of_Players For i = 0 To Num_Of_Players - 1 If Curr(i) = 1 Then Winner = i + 1 Exit For End If Next i End Function Sub Calc(Max) Prev(0) = 1 Prev(1) = 2 For Num = 3 To Max D = Drop(0, 0) Curr(D) = Num For i = 1 To Num - 1 Curr((D + i) Mod Num) = Prev(i - 1) Next i For i = 0 To Num - 1 Prev(i) = Curr(i) Next i Next Num End Sub Function Drop(Player, Count) Select Case Count Case 3 Drop = (Player + 1) Mod Num Case 4 Drop = Player Case Else A = Drop((Player + 1) Mod Num, Count + 1) B = Drop((Player + 1) Mod Num, Count + 2) If Rank(Player, A) < Rank(Player, B) Then Drop = A Else Drop = B End If End Select End Function Function Rank(Player, Dropped) Rank = Prev((Player - Dropped - 1 + Num) Mod Num) End Function
CROSSREFS
Sequence in context: A277495 A188945 A281261 * A088333 A016538 A134226
KEYWORD
nonn
AUTHOR
Hagai Helman (Helman(AT)actcom.net.il), Feb 28 2005
STATUS
approved