## January 2022 - Challenge

**Forming primes in digit circles**

The following riddle was suggested by Evert van Dijken.

Seven **distinct** digits are places on a circle. Then, numbers can be formed in the following manner: Choose one digit to start from and add it to the number, and then move a certain number of steps on the circle either clockwise or counterclockwise. Add the digit to the number, and keep this until five digits were chosen. These digits comprise the number (the first digit being the most significant digit).

For example, in the circle [4, 7, 3, 6, 2, 0, 1]:

One can start from "2", move 3 steps clockwise to "4", move one step counterclockwise to "1", move one more step counterclockwise to "0", and move 4 steps clockwise to "3", resulting in the number "24103".

Given a circle, we assign a score to each number that can be generated from the circle based on the minimum number of steps required to generate this number. In the example above, moving from "0" to "3" in 4 steps is not optimal; one can move just 3 steps by going counterclockwise. So the score of "24103" is 3+1+1+3=8.

We allow generation only of the numbers that satisfy **all** the following criterions:

1. Prime numbers.

2. All the digits are distinct.

3. No leading 0.

For a given circle, we can form **all** the numbers that satisfy the criterion and sum their scores.

For the circle [4, 7, 3, 6, 2, 0, 1] we will find 231 total primes with 5 distinct digits, giving us a total score of 1882. This 1882 is the score of the circle itself.

In our example we had n=7 digits in a circle and the numbers had d=5 digits but we can also generalize for different values of n,d (if n > 10, we can use a different number base, but we won't do it here).

**Your goal**: Find circles giving the maximum and minimum score for the original n=7, d=5 setting.

Send your result in the following format:

[a1, a2, ..., an]

[b1, b2, ..., bn]

**A bonus** "*" will be given for finding circles giving the maximum and minimum score for n=8, d=6.

We will post the names of those who submit a correct, original solution! If you don't want your name posted then please include such a statement in your submission!

We invite visitors to our website to submit an elegant solution. Send your submission to the ponder@il.ibm.com.

*If you have any problems you think we might enjoy, please send them in. All replies should be sent to:* ponder@il.ibm.com

**Challenge:**
05/01/2022 @ 12:00 PM EST

**Solution:**
04/02/2022 @ 12:00 PM EST

**List Updated:**
10/01/2022 @ 12:00 PM EST

#### People who answered correctly:

**Lorenz Reichel **(5/1/2022 4:40 PM IDT)

***Daniel Chong Jyh Tar **(5/1/2022 5:29 PM IDT)

***Lazar Ilic **(5/1/2022 7:10 PM IDT)

**Balakrishnan Varadarajan **(5/1/2022 7:59 PM IDT)

***Hugh Coleman **(5/1/2022 8:16 PM IDT)

***Guillaume Escamocher **(5/1/2022 9:40 PM IDT)

**Dan Dima **(5/1/2022 9:58 PM IDT)

***David McCullars **(5/1/2022 11:33 PM IDT)

***Todd Will **(6/1/2022 12:32 AM IDT)

***Dieter Beckerle **(6/1/2022 1:30 AM IDT)

***Alper Halbutogullari **(6/1/2022 1:50 AM IDT)

***Bert Dobbelaere **(6/1/2022 1:59 AM IDT)

***Phil Proudman **(6/1/2022 4:14 AM IDT)

***Victor Chang **(6/1/2022 5:56 AM IDT)

***Alexander Gramolin **(6/1/2022 7:15 AM IDT)

***Reiner Martin **(6/1/2022 11:36 AM IDT)

***Christofer Ohlsson **(6/1/2022 11:47 AM IDT)

***Stéphane Higueret **(6/1/2022 11:47 AM IDT)

***Paul Shaw **(6/1/2022 12:43 PM IDT)

***Sanandan Swaminathan **(6/1/2022 12:59 PM IDT)

**Giorgos Kalogeropoulos **(6/1/2022 3:52 PM IDT)

**Graham Hemsley **(6/1/2022 4:39 PM IDT)

**Paul Revenant **(6/1/2022 5:13 PM IDT)

***Bertram Felgenhauer **(6/1/2022 5:14 PM IDT)

***Amos Guler **(6/1/2022 5:15 PM IDT)

***Gary M. Gerken **(6/1/2022 9:45 PM IDT)

***Thomas Egense **(6/1/2022 10:59 PM IDT)

***Andreas Stiller **(7/1/2022 12:45 AM IDT)

***Kennedy **(7/1/2022 6:54 AM IDT)

***Chris Shannon **(7/1/2022 7:24 AM IDT)

**Maksym Voznyy **(7/1/2022 7:37 AM IDT)

**Michael Liepelt **(7/1/2022 8:50 AM IDT)

**Collin Pearce **(7/1/2022 10:38 AM IDT)

***Evert van Dijken **(7/1/2022 12:27 PM IDT)

***Tim Walters **(8/1/2022 1:17 AM IDT)

***Keith Schneider **(8/1/2022 9:21 AM IDT)

**Alex Fleischer **(8/1/2022 10:07 AM IDT)

***Stancu Mihai **(8/1/2022 2:59 PM IDT)

**Sergey Subbotin **(8/1/2022 5:11 PM IDT)

***Clive Tong **(9/1/2022 1:06 AM IDT)

***Sreeram Ramachandran **(9/1/2022 4:11 AM IDT)

**Ananda Raidu **(9/1/2022 12:18 PM IDT)

***Thomas Pircher **(9/1/2022 2:47 PM IDT)