A380247 Triangle read by rows: T(n,k) is the number of the k-th eliminated person in the variation of the Josephus elimination process for n people, where the number of people skipped correspond to the number of letters in the next number in English alphabet.
1, 2, 1, 1, 3, 2, 4, 1, 3, 2, 4, 3, 2, 5, 1, 4, 2, 5, 1, 3, 6, 4, 1, 2, 3, 6, 5, 7, 4, 8, 7, 6, 1, 2, 5, 3, 4, 8, 6, 3, 2, 1, 9, 7, 5, 4, 8, 5, 1, 9, 6, 10, 7, 2, 3, 4, 8, 3, 10, 6, 1, 2, 7, 11, 9, 5, 4, 8, 2, 9, 3, 10, 7, 11, 12, 1, 5, 6, 4, 8, 1, 7, 13, 6, 3, 2, 12, 11, 5, 9, 10, 4, 8, 14, 6, 12, 3, 13, 10, 7, 2, 11, 1, 5, 9, 4
Offset: 1
Examples
Triangle begins: 1; 2, 1; 1, 3, 2; 4, 1, 3, 2; 4, 3, 2, 5, 1; 4, 2, 5, 1, 3, 6; 4, 1, 2, 3, 6, 5, 7; ... For n = 4 suppose four people are arranged in a circle corresponding to the fourth row of the triangle. Three people are skipped for each letter in O-N-E; then the 4th person is eliminated. This means the row starts with 4. The next three people are skipped, and the person eliminated is number 1. Thus, the next element in the row is 1. Then, 5 people are skipped, and the next person eliminated is number 3. Similarly, the last person eliminated is number 2. Thus, the fourth row of this triangle is 4, 1, 3, 2.
Crossrefs
Programs
-
Python
from num2words import num2words as n2w def spell(n): return sum(1 for c in n2w(n).replace(" and", "").replace(" ", "").replace(chr(44), "").replace("-", "")) def inverse_permutation(p): inv = [0] * len(p) for i, x in enumerate(p): inv[x-1] = i +1 return inv def nthRow(n): l = [] for i in range(0,n): l.append(0) zp = 0 for j in range(1,n+1): zc = 0 while zc <= spell(j): if l[zp] == 0: zc += 1 zp += 1 zp = zp % n l[zp-1] = j return l l = [] for i in range(1,15): l += inverse_permutation(nthRow(i)) print(l)
-
Python
from num2words import num2words as n2w def f(n): return sum(1 for c in n2w(n).replace(" and", "") if c.isalpha()) def row(n): c, i, J = 1, 0, list(range(1, n+1)) out = [] while len(J) > 1: i = (i + f(c))%len(J) q = J.pop(i) out.append(q) c = c+1 out.append(J[0]) return out print([e for n in range(1, 15) for e in row(n)]) # Michael S. Branicky, Feb 15 2025
Comments