Array elements in a specific range and center element of range

Hi Everyone!
Nice to see there is an active community here, that offers support to beginners.
I have the following problem I am trying to resolve with a roulette wheel program:
#First array that contains all the roulette wheel numbers in clockwise order starting from pocket 0:


ckwheel = np.array([ 0, 32, 15, 19, 4, 21, 2, 25, 17, 34, 6, 27, 13, 36, 11, 30, 8, 23, 10, 5, 24, 16, 33, 1, 20, 14, 31, 9, 22, 18, 29, 7, 28, 12, 35, 3, 26 ])

There is a second array (let’s call it arr2) that contains 4 numbers (random values from the ckwheel array)

Output needed:
I need to identify:

1. Are all the 4 numbers in arr2 within a distance/range of 17(consecutive)pockets on a roulette wheel?

For example:
example 1:

arr2=[4, 17, 27, 23]

These numbers are from index 4 to index 17 in the ckwheel array and are actually in a distance of 13 in the pockets in a roulette wheel. So they are also in a range of 17 consecutive pockets.
example 2:

arr2=[ 28, 3, 19, 27]

These numbers are on index 32, 35, 3 and 11. The roulette wheel being continuous (not like my array), these 4 numbers are in fact in a range of exactly 17 pockets.

So first, print a message :

“the numbers in arr2 can be covered within 17 consecutive pockets”
" No, the numbers are too distanced to cover"

2. If the numbers can be covered by a 17 pockets range, identify and print the middle(center) pocket number of this 17 numbers range

I hope I was clear enough to get some ideas for coding this.
Thank you!

Welcome to, Adrian!

Your description has many good details. What’s your experience level with Python?

Have you started coding? If so, what do you have so far?

VERY IMPORTANT: The code you’ve posted above is single lines, which isn’t too bad to read in a proportional font. If you post more than one line, though, please surround your code with a “fence” of three backticks [ ``` ] as shown below. This will…

  1. Trigger an easy-to-read monospace font with color highlighting.
  2. Preserve indents in code you paste in.
  3. Prevent Discourse (this platform) from converting your straight quotation marks to curly marls that IDS’s don’t recognize.
  4. Provide a handy ‘Copy Code’ button at top right of the code block.

So fence your posted code like this:

<paste or type code here>

It will make this:

volunteers = 0
print("That's a reader-friendly code format.")
volunteers += 1
print(f"It will probably encourage at least {volunteers} person to help me")
while True:
    volunteers += 1
    print(f"or maybe {volunteers} people...")

You can also use the monospace font inline by using single backticks before and after the text.

`use the monospace font`

Thanks for replying and sorry for the rookie mistakes :blush:
I am learning coding in python.
And I just set some goals like this one, and get it done after reading a lot from the internet. The code I have is really irrelevant to this problem i’m trying to solve.
The ckwheel array is defined as a numpy array and it doesn’t change ever.
The second arr2 array is changing after each roulette spin, the 4 numbers inside this array randomly change. this is already done, but as I said, it’s irrelevant to this next part. I tried several times, but can’t get it working for the presented in example 2…

If you don’t have any idea how to code it, maybe you should start with a simpler exercise…?

You can do this with base Python (called the ‘Standard Library’ or StdLib). NumPy can wait for something that needs the speed or the fancy functions. As yougrow in your programming, you will find soemthign that actually needs numPy.

P.S. You can go back and edit your post to ad the inline monospace for code. It isn’t too late to present yourself well to new readers–and show anyone who comes back that you care about code presentation.