OFFSET
1,1
COMMENTS
Consider a one-handed variant of the game of Chopsticks with 2 players. Each player has a hand of n fingers, starting with i fingers up (i must be > 0). If we simulate the game for any n, we can test whether one player wins all games for i < n.
Prime numbers appear to be a subset of this sequence. a(n) is generally odd (but not always). Additionally, it appears that for all prime n, the game will always end in the same number of rounds, regardless of i.
EXAMPLE
Using the framework listed in the Comments section, let n = 5 and i = 1 (a standard game of 1-handed Chopsticks). Each player has 1 hand with 5 fingers and starts the game with 1 finger up. Player 1 goes first and taps Player 2's hand. Player 2 adds the number from Player 1's hand to their own, unless the amount exceeds 5 (the number of total fingers on the hand), in which case Player 2 subtracts 5 from the result. For example, on the first turn, Player 1 taps Player 2's hand, and Player 2 adds an additional finger (now 2 fingers up). Player 2 goes next, and play proceeds similarly. Player 2 taps their 2 fingers on Player 1's single finger, and Player 1 ends up with 3 fingers up. On the next turn, Player 1 taps their 3 fingers to Player 2's 2 fingers, and Player 2 now has 5 fingers up. The game ends when either player gets exactly 5 fingers up. In this case, Player 1 wins since Player 2 got to 5 fingers first. Clearly, this is a deterministic procedure, and Player 1 will always win when starting with 1 finger up on a hand of 5 fingers. It can be demonstrated that Player 1 will also win when starting with 2, 3, or 4 fingers (given the 5-finger hand). Hence, 5 is in the sequence.
Note that because i must be greater than 0 and i must be less than n, there are no valid values for i to take when n = 1. Therefore, 1 should not be part of the sequence. - Michael Schwalen, Feb 08 2020
PROG
(R)
# Generalized Chopsticks Sequence
# Alexander Robinson & Michael Schwalen
# Code assistance from Angela Lin
# April 7, 2018
# This code simulates the Generalized Chopsticks Sequence (A302403).
# Load library
library(dplyr)
# Create function
chopsticks <- function(n) {
# Initialize empty variables
num_turns_p1_wins=c()
num_turns_p2_wins=c()
num_p1_wins=0
num_p2_wins=0
# Run loop to determine round winners
for(j in 1:(n-1)){
p1=j
p2=j
for(i in 1:(n-1)){
p2=p1+p2
p1=p2+p1
i=i+1
if(p2%%n==0){
num_p1_wins=num_p1_wins+1
num_turns_p1_wins=c(num_turns_p1_wins, i)
break
}
if(p1%%n==0){
num_p2_wins=num_p2_wins+1
num_turns_p2_wins=c(num_turns_p2_wins, i)
break
}
p2=p2%%n
p1=p1%%n
}
}
# Determine final winner
winner <- ifelse(num_p2_wins == n-1, "P2", ifelse(num_p1_wins == n-1, "P1", "Neither"))
return(winner)
}
# Simulate n 2:1000
simulation <- data.frame(n = 2:1000)
simulation$winner <- lapply(simulation$n, chopsticks)
# Create sequence
sequence <- filter(simulation, winner != "Neither")
sequence <- sequence$n
sequence
# Create list output
paste0(paste0(as.character(sequence), ", "), collapse = "")
CROSSREFS
KEYWORD
nonn
AUTHOR
Alexander Robinson and Michael Schwalen, Apr 07 2018
EXTENSIONS
Term 1 removed by Michael Schwalen, Feb 08 2020
STATUS
approved