Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
For example I have an array of

array = [
    1, 2, 3,
    4, 5, 6,
    7, 8, 9
]


I want it to cycle counter clockwise starting from 1 to 5, then the output will be:

1 4 7 8 9 6 3 2 5


What I have tried:

This is what i tried
arr = [
    1, 2, 3,
    4, 5, 6,
    7, 8, 9
]

{print(i, end=' ') for i in list(arr)[::-1]}
Posted
Updated 12-Nov-22 21:37pm

1 solution

The order you are trying to use is not a simple series. You are trying to print the numbers in this order of index position:
0, 3, 6, 7, 8, 5, 2, 1, 4

The differences between those indices do not give a simple way of calculating the next values.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900