## Task 3 - 290913

In a counting-out game, 11 children stand in a circle. One of these children recites the counting-out rhyme; with each syllable, one child is counted in a clockwise direction. The player who recites the counting-out rhyme is also included in the counting. The counting-out rhyme has 15 syllables. The child on whom the last syllable falls leaves the circle; the counting resumes with the next child, starting again from the beginning of the counting-out rhyme. This counting and elimination continues until only one player remains in the circle; this player is the winner.

a) At which child should the counting player start if he wants to win himself? (To formulate the answer, number the children and assign, for example, the counting player the number 1.)

b) If you have the opportunity to work on a (small) computer, you should write a program that solves task a) for counting-out games with $k$ children and a counting-out rhyme of $s$ syllables.
a) I. First, the number of syllables can be simplified by replacing them with the smallest possible positive values. Since $15=1 \cdot 11+4$, when counting, the children's circle is only fully traversed once, and only 4 syllables remain. In this way, it follows: If in the circle there are still

$$
11,10,9,8,7,6,5,4,3,2
$$

children standing, then because

$15=1 \cdot 11+4=1 \cdot 10+5=1 \cdot 9+6=1 \cdot 8+7=2 \cdot 7+1=2 \cdot 6+3=2 \cdot 5+5=3 \cdot 4+3=4 \cdot 3+3=7 \cdot 2+1$ the number of syllables can be replaced by

$$
4,5,6,7,1,3,5,3,3,1
$$

II. Now, one can (with the simplification from I. or without it) follow the counting with a "trial game" starting with child 1:

Counting Rhyme

1. Time:
![](https://cdn.mathpix.com/cropped/2024_06_06_b85a894aa8dbf722a7b3g-1096.jpg?height=664&width=1264&top_left_y=884&top_left_x=544)

III. Therefore, the child that remains is the one that can be reached by counting 9 more (in the original arrangement) from child 1. The starting point that leads to child 1 winning is found by counting back 9 from child 1 in the original arrangement. Thus, we find:

If child 1 is to win, the counting must start with child 3.

b) The problem can be solved, for example, by the following BASIC program:

![](https://cdn.mathpix.com/cropped/2024_06_06_b85a894aa8dbf722a7b3g-1096.jpg?height=40&width=417&top_left_y=1879&top_left_x=243)
110 INPUT "Number of syllables"; S
120 DIM M(K)
130 FOR N=K TO 2 STEP -1
140 T = S - N * INT(S/N)
150 IF T = 0 THEN T = N
160 FOR I = 1 TO T
170 GOSUB 300
180 NEXT I
190 M(A) = 1
200 NEXT N

```
![](https://cdn.mathpix.com/cropped/2024_06_06_b85a894aa8dbf722a7b3g-1096.jpg?height=34&width=217&top_left_y=2302&top_left_x=243)
```

220 B = 2 - A
230 IF B > K THEN A = 1
330 IF M(A)=1 THEN 310
340 RETURN

```

Meaning of the variables: K Number of children, S Number of syllables, A Number of the child reached by counting, M(A) Mark 0 or 1: Child A is still in the game or has been eliminated, N Number of children still in the game, T Simplified value for the number of syllables, I Counting step

Program parts:

100 to 120 Input, allocate memory,

300 to 340 Subroutine "Count to the next child still in the game"

130 to 210 "Trial game":

140 to 150 Division of \(\mathrm{S}\) by \(\mathrm{N}\) with remainder \(\mathrm{T}\) gives the simplified number of syllables \(\mathrm{T}\); only 0 is replaced by \(\mathrm{N}\)

160 to 210 After T counting steps, the reached child is eliminated. At the end of the "trial game," one more counting step to the only child still in the game.

220 to 240 Determination and output of the answer: Instead of counting forward by A-1, count backward by the same amount to \(1-(\mathrm{A}-1)=2-\mathrm{A}\); this may need to be adjusted by \(\mathrm{K}\).