Puzzle
1 minute read

Ponder This Challenge - July 2026 - Return of the Superheroes

Continuing the theme of last month, we deal with a movie franchise consisting of nn superheroes. They are joined by nn supervillains. The producers intend to pair the superheroes and the supervillains to form (hero, villain) pairs where each hero has a unique villain serving as their nemesis.

Each pairing is accepted differently by the audiences. After elaborate work, a method of assigning numerical value f(a,b)f(a,b) to each pairing (a,b)(a,b) to estimate the audiences' reaction was developed. The producers wish to find the list of pairings that maximizes the value of the pairing with the minimal value in the list. This minimal value is called the hero-villain value.

The way f(a,b)f(a,b) is computed is as follows: Let pp be some prime and define a function Ta,b(x)=x2+ax+bT_{a,b}(x)=x^2+ax+b. By setting x0=0x_0=0 and xn+1=T(xn)x_{n+1}=T(x_n) we obtain a sequence x0,x1,x2,x_0,x_1,x_2,\ldots which eventually repeats. Let f(a,b)f(a,b) be the number of steps until the first repeat happens. i.e. if xnx_n is the first element in the sequence such that there exists m<nm<n for which xn=xmx_n=x_m, then (a,b)=n(a,b)=n.

For example, for n=5n=5 and p=101p=101, one possible list of pairings is (1,3),(2,1),(3,4),(4,2),(5,5)(1,3), (2,1), (3,4), (4,2), (5,5) which yields the values 14,18,19,22,1414, 18, 19, 22, 14 for which the minimum is 14. It turns out that every list of pairings gives a value of at most 14, so 14 is the superhero value for this case.

Your goal Find the superhero value for n=???n=??? and p=????p=????

A bonus "*" will be given for finding the optimal nn in the range 1<n<N1<n<N for N=???N=??? which gives the maximal superhero value for nn and p=????p=????.

Related posts