Rotated Position of IntegersDriftsort an arrayFill in an increasing sequence with as many numbers as possibleGet the decimal!Minimally sort a list into a matrixDigits in their lanesCodegolf Rainbow : Sorting Colors with ReflectionSort by Largest Digit(s)Spot all (anti)diagonals with duplicated valuesCould you please stop shuffling the deck and play already?Valid Badminton Score?

How can you travel on a trans-Siberian train when it is fully booked?

Implement Homestuck's Catenative Doomsday Dice Cascader

Bent spoke design wheels — feasible?

Strange symbol for two functions

Avoiding cliches when writing gods

Can you really not move between grapples/shoves?

About the expansion of seq_set_split

Should I "tell" my exposition or give it through dialogue?

What is the purpose of building foundations?

Russian equivalent of the French expression "broyer du noir"

2.8 is missing the Carve option in the Boolean Modifier

When writing an error prompt, should we end the sentence with a exclamation mark or a dot?

4*4*4 Rubiks cube Top Layer Issue

SF novella separating the dumb majority from the intelligent part of mankind

Company did not petition for visa in a timely manner. Is asking me to work from overseas, but wants me to take a paycut

Select items in a list that contain criteria #2

How is it possible that Gollum speaks Westron?

Does the "6 seconds per round" rule apply to speaking/roleplaying during combat situations?

Why does the Schrödinger equation work so well for the Hydrogen atom despite the relativistic boundary at the nucleus?

Average spam confidence

Translating 'Liber'

Deformation of rectangular plot

What risks are there when you clear your cookies instead of logging off?

Trapping Rain Water



Rotated Position of Integers


Driftsort an arrayFill in an increasing sequence with as many numbers as possibleGet the decimal!Minimally sort a list into a matrixDigits in their lanesCodegolf Rainbow : Sorting Colors with ReflectionSort by Largest Digit(s)Spot all (anti)diagonals with duplicated valuesCould you please stop shuffling the deck and play already?Valid Badminton Score?













20












$begingroup$


Challenge:



Input:



A sorted list of positive integers.



Output:



The amount of integers which are still at the exact same index, after rotating the digits in each integer its index amount of times towards the left and sorting the modified list again.



Example:



Input: [8,49,73,102,259,762,2782,3383,9217,37846,89487,7471788]

Output (0-based indexing): 6

Output (1-based indexing): 5



Why?



0-based indexing:



After rotating each: [8,94,73,102,592,276,8227,3338,9217,63784,89487,7887471]
Sorted again: [8,73,94,102,276,592,3338,8227,9217,63784,89487,7887471]

Input indices: 0 1 2 3 4 5 6 7 8 9 10 11
Original input-list: [8,49,73,102,259,762,2782,3383,9217,37846,89487,7471788]
Modified list: [8,73,94,102,276,592,3338,8227,9217,63784,89487,7887471]
Modified indices: 0 2 1 3 5 4 7 6 8 9 10 11
Equal indices: ^ ^ ^ ^ ^ ^

So the output is: 6


1-based indexing:



After rotating each: [8,49,37,021,925,762,2278,3383,2179,37846,94878,8874717]
Sorted again: [8,(0)21,37,49,762,925,2179,2278,3383,37846,94878,8874717]

Input indices: 1 2 3 4 5 6 7 8 9 10 11 12
Original input-list: [8,49,73,102,259,762,2782,3383,9217,37846,89487,7471788]
Modified list: [8,21,37,49,762,925,2179,2278,3383,37846,94878,8874717]
Modified indices: 1 4 3 2 6 5 9 7 8 10 11 12
Equal indices: ^ ^ ^ ^ ^

So the output is: 5


Challenge rules:



  • The input-list is guaranteed to only contain positive integers.

  • The input-list is guaranteed to be sorted from lowest to highest.

  • The input-list is guaranteed to contain at least two items.

  • As you can see above, both 0-based and 1-based indexing is allowed. Please state in your answer which of the two you've used, since outputs can differ accordingly!

  • Leading 0s after rotating are ignored, which can be seen with the 1-based example above, where the integer 102 becomes 021 after rotating, and is then treated as 21.

  • Integers are guaranteed unique in the input-list, and are guaranteed to remain unique after the rotations are completed.

  • Note that we only look at the positions of the rotated integers in correlation with the positions of the input, not with the values of the input-list. To clarify what I mean by this: with the input-list [1234,3412] and 1-based indexing, the list becomes [2341,1234] after rotating each integer it's index amount of times, and then when sorted becomes [1234,2341]. Although both the original input-list and the rotated list contains the integer 1234 at the leading position, they aren't the same! The rotated 1234 was 3412 before. The 1-indexed output for this input-list is therefore 0, since the two integers have swapped their positions.

  • Input is flexible. Can be a list/stream/array of integers/strings/digit-arrays, etc. Please state what you've used if you don't take the inputs as integers.

General rules:



  • This is code-golf, so shortest answer in bytes wins.

    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code (i.e. TIO).

  • Also, adding an explanation for your answer is highly recommended.

Test cases:



Input: [8, 49, 73, 102, 259, 762, 2782, 3383, 9217, 37846, 89487, 7471788]
0-based output: 6
1-based output: 5

Input: [1234, 3412]
0-based output: 2
1-based output: 0

Input: [2349, 2820, 17499, 21244, 29842, 31857, 46645, 56675, 61643, 61787]
0-based output: 3
1-based output: 0

Input: [4976, 11087, 18732, 22643, 52735]
0-based output: 2
1-based output: 3

Input: [4414, 5866, 7175, 8929, 14048, 16228, 16809, 19166, 24408, 25220, 29333, 44274, 47275, 47518, 53355]
0-based output: 4
1-based output: 4

Input: [11205, 16820, 63494]
0-based output: 1
1-based output: 3


Feel free to generate more random test cases with (or draw inspiration from) this ungolfed 05AB1E program, where the input is the size of the random list (NOTE: the output of this generator might not comply with the rule "Integers are guaranteed unique in the input-list, and are guaranteed to remain unique after the rotations are completed", so keep that in mind when using it.)










share|improve this question











$endgroup$











  • $begingroup$
    May we assume that the input has at least 2 elements?
    $endgroup$
    – Robin Ryder
    May 28 at 21:02






  • 2




    $begingroup$
    @RobinRyder Hmm, my first thought would be no, but since I don't have any test cases with single items and it won't add much to the challenge, why not. I'll add a rule that the input-list is guaranteed to contain at least 2 items.
    $endgroup$
    – Kevin Cruijssen
    May 28 at 21:07










  • $begingroup$
    May we accept input as a list of strings?
    $endgroup$
    – Embodiment of Ignorance
    May 29 at 3:29






  • 1




    $begingroup$
    @Shaggy I've notified the answers I thought would benefit from it. If you see any that could benefit from it as well, feel free to notify them as well.
    $endgroup$
    – Kevin Cruijssen
    May 29 at 6:24






  • 1




    $begingroup$
    From the example it seems the output should be "The amount of integers which are still at the exact same index, after rotating the digits in each integer its index amount of times towards the left, and sorting the array again"?
    $endgroup$
    – qwr
    2 days ago















20












$begingroup$


Challenge:



Input:



A sorted list of positive integers.



Output:



The amount of integers which are still at the exact same index, after rotating the digits in each integer its index amount of times towards the left and sorting the modified list again.



Example:



Input: [8,49,73,102,259,762,2782,3383,9217,37846,89487,7471788]

Output (0-based indexing): 6

Output (1-based indexing): 5



Why?



0-based indexing:



After rotating each: [8,94,73,102,592,276,8227,3338,9217,63784,89487,7887471]
Sorted again: [8,73,94,102,276,592,3338,8227,9217,63784,89487,7887471]

Input indices: 0 1 2 3 4 5 6 7 8 9 10 11
Original input-list: [8,49,73,102,259,762,2782,3383,9217,37846,89487,7471788]
Modified list: [8,73,94,102,276,592,3338,8227,9217,63784,89487,7887471]
Modified indices: 0 2 1 3 5 4 7 6 8 9 10 11
Equal indices: ^ ^ ^ ^ ^ ^

So the output is: 6


1-based indexing:



After rotating each: [8,49,37,021,925,762,2278,3383,2179,37846,94878,8874717]
Sorted again: [8,(0)21,37,49,762,925,2179,2278,3383,37846,94878,8874717]

Input indices: 1 2 3 4 5 6 7 8 9 10 11 12
Original input-list: [8,49,73,102,259,762,2782,3383,9217,37846,89487,7471788]
Modified list: [8,21,37,49,762,925,2179,2278,3383,37846,94878,8874717]
Modified indices: 1 4 3 2 6 5 9 7 8 10 11 12
Equal indices: ^ ^ ^ ^ ^

So the output is: 5


Challenge rules:



  • The input-list is guaranteed to only contain positive integers.

  • The input-list is guaranteed to be sorted from lowest to highest.

  • The input-list is guaranteed to contain at least two items.

  • As you can see above, both 0-based and 1-based indexing is allowed. Please state in your answer which of the two you've used, since outputs can differ accordingly!

  • Leading 0s after rotating are ignored, which can be seen with the 1-based example above, where the integer 102 becomes 021 after rotating, and is then treated as 21.

  • Integers are guaranteed unique in the input-list, and are guaranteed to remain unique after the rotations are completed.

  • Note that we only look at the positions of the rotated integers in correlation with the positions of the input, not with the values of the input-list. To clarify what I mean by this: with the input-list [1234,3412] and 1-based indexing, the list becomes [2341,1234] after rotating each integer it's index amount of times, and then when sorted becomes [1234,2341]. Although both the original input-list and the rotated list contains the integer 1234 at the leading position, they aren't the same! The rotated 1234 was 3412 before. The 1-indexed output for this input-list is therefore 0, since the two integers have swapped their positions.

  • Input is flexible. Can be a list/stream/array of integers/strings/digit-arrays, etc. Please state what you've used if you don't take the inputs as integers.

General rules:



  • This is code-golf, so shortest answer in bytes wins.

    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code (i.e. TIO).

  • Also, adding an explanation for your answer is highly recommended.

Test cases:



Input: [8, 49, 73, 102, 259, 762, 2782, 3383, 9217, 37846, 89487, 7471788]
0-based output: 6
1-based output: 5

Input: [1234, 3412]
0-based output: 2
1-based output: 0

Input: [2349, 2820, 17499, 21244, 29842, 31857, 46645, 56675, 61643, 61787]
0-based output: 3
1-based output: 0

Input: [4976, 11087, 18732, 22643, 52735]
0-based output: 2
1-based output: 3

Input: [4414, 5866, 7175, 8929, 14048, 16228, 16809, 19166, 24408, 25220, 29333, 44274, 47275, 47518, 53355]
0-based output: 4
1-based output: 4

Input: [11205, 16820, 63494]
0-based output: 1
1-based output: 3


Feel free to generate more random test cases with (or draw inspiration from) this ungolfed 05AB1E program, where the input is the size of the random list (NOTE: the output of this generator might not comply with the rule "Integers are guaranteed unique in the input-list, and are guaranteed to remain unique after the rotations are completed", so keep that in mind when using it.)










share|improve this question











$endgroup$











  • $begingroup$
    May we assume that the input has at least 2 elements?
    $endgroup$
    – Robin Ryder
    May 28 at 21:02






  • 2




    $begingroup$
    @RobinRyder Hmm, my first thought would be no, but since I don't have any test cases with single items and it won't add much to the challenge, why not. I'll add a rule that the input-list is guaranteed to contain at least 2 items.
    $endgroup$
    – Kevin Cruijssen
    May 28 at 21:07










  • $begingroup$
    May we accept input as a list of strings?
    $endgroup$
    – Embodiment of Ignorance
    May 29 at 3:29






  • 1




    $begingroup$
    @Shaggy I've notified the answers I thought would benefit from it. If you see any that could benefit from it as well, feel free to notify them as well.
    $endgroup$
    – Kevin Cruijssen
    May 29 at 6:24






  • 1




    $begingroup$
    From the example it seems the output should be "The amount of integers which are still at the exact same index, after rotating the digits in each integer its index amount of times towards the left, and sorting the array again"?
    $endgroup$
    – qwr
    2 days ago













20












20








20


1



$begingroup$


Challenge:



Input:



A sorted list of positive integers.



Output:



The amount of integers which are still at the exact same index, after rotating the digits in each integer its index amount of times towards the left and sorting the modified list again.



Example:



Input: [8,49,73,102,259,762,2782,3383,9217,37846,89487,7471788]

Output (0-based indexing): 6

Output (1-based indexing): 5



Why?



0-based indexing:



After rotating each: [8,94,73,102,592,276,8227,3338,9217,63784,89487,7887471]
Sorted again: [8,73,94,102,276,592,3338,8227,9217,63784,89487,7887471]

Input indices: 0 1 2 3 4 5 6 7 8 9 10 11
Original input-list: [8,49,73,102,259,762,2782,3383,9217,37846,89487,7471788]
Modified list: [8,73,94,102,276,592,3338,8227,9217,63784,89487,7887471]
Modified indices: 0 2 1 3 5 4 7 6 8 9 10 11
Equal indices: ^ ^ ^ ^ ^ ^

So the output is: 6


1-based indexing:



After rotating each: [8,49,37,021,925,762,2278,3383,2179,37846,94878,8874717]
Sorted again: [8,(0)21,37,49,762,925,2179,2278,3383,37846,94878,8874717]

Input indices: 1 2 3 4 5 6 7 8 9 10 11 12
Original input-list: [8,49,73,102,259,762,2782,3383,9217,37846,89487,7471788]
Modified list: [8,21,37,49,762,925,2179,2278,3383,37846,94878,8874717]
Modified indices: 1 4 3 2 6 5 9 7 8 10 11 12
Equal indices: ^ ^ ^ ^ ^

So the output is: 5


Challenge rules:



  • The input-list is guaranteed to only contain positive integers.

  • The input-list is guaranteed to be sorted from lowest to highest.

  • The input-list is guaranteed to contain at least two items.

  • As you can see above, both 0-based and 1-based indexing is allowed. Please state in your answer which of the two you've used, since outputs can differ accordingly!

  • Leading 0s after rotating are ignored, which can be seen with the 1-based example above, where the integer 102 becomes 021 after rotating, and is then treated as 21.

  • Integers are guaranteed unique in the input-list, and are guaranteed to remain unique after the rotations are completed.

  • Note that we only look at the positions of the rotated integers in correlation with the positions of the input, not with the values of the input-list. To clarify what I mean by this: with the input-list [1234,3412] and 1-based indexing, the list becomes [2341,1234] after rotating each integer it's index amount of times, and then when sorted becomes [1234,2341]. Although both the original input-list and the rotated list contains the integer 1234 at the leading position, they aren't the same! The rotated 1234 was 3412 before. The 1-indexed output for this input-list is therefore 0, since the two integers have swapped their positions.

  • Input is flexible. Can be a list/stream/array of integers/strings/digit-arrays, etc. Please state what you've used if you don't take the inputs as integers.

General rules:



  • This is code-golf, so shortest answer in bytes wins.

    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code (i.e. TIO).

  • Also, adding an explanation for your answer is highly recommended.

Test cases:



Input: [8, 49, 73, 102, 259, 762, 2782, 3383, 9217, 37846, 89487, 7471788]
0-based output: 6
1-based output: 5

Input: [1234, 3412]
0-based output: 2
1-based output: 0

Input: [2349, 2820, 17499, 21244, 29842, 31857, 46645, 56675, 61643, 61787]
0-based output: 3
1-based output: 0

Input: [4976, 11087, 18732, 22643, 52735]
0-based output: 2
1-based output: 3

Input: [4414, 5866, 7175, 8929, 14048, 16228, 16809, 19166, 24408, 25220, 29333, 44274, 47275, 47518, 53355]
0-based output: 4
1-based output: 4

Input: [11205, 16820, 63494]
0-based output: 1
1-based output: 3


Feel free to generate more random test cases with (or draw inspiration from) this ungolfed 05AB1E program, where the input is the size of the random list (NOTE: the output of this generator might not comply with the rule "Integers are guaranteed unique in the input-list, and are guaranteed to remain unique after the rotations are completed", so keep that in mind when using it.)










share|improve this question











$endgroup$




Challenge:



Input:



A sorted list of positive integers.



Output:



The amount of integers which are still at the exact same index, after rotating the digits in each integer its index amount of times towards the left and sorting the modified list again.



Example:



Input: [8,49,73,102,259,762,2782,3383,9217,37846,89487,7471788]

Output (0-based indexing): 6

Output (1-based indexing): 5



Why?



0-based indexing:



After rotating each: [8,94,73,102,592,276,8227,3338,9217,63784,89487,7887471]
Sorted again: [8,73,94,102,276,592,3338,8227,9217,63784,89487,7887471]

Input indices: 0 1 2 3 4 5 6 7 8 9 10 11
Original input-list: [8,49,73,102,259,762,2782,3383,9217,37846,89487,7471788]
Modified list: [8,73,94,102,276,592,3338,8227,9217,63784,89487,7887471]
Modified indices: 0 2 1 3 5 4 7 6 8 9 10 11
Equal indices: ^ ^ ^ ^ ^ ^

So the output is: 6


1-based indexing:



After rotating each: [8,49,37,021,925,762,2278,3383,2179,37846,94878,8874717]
Sorted again: [8,(0)21,37,49,762,925,2179,2278,3383,37846,94878,8874717]

Input indices: 1 2 3 4 5 6 7 8 9 10 11 12
Original input-list: [8,49,73,102,259,762,2782,3383,9217,37846,89487,7471788]
Modified list: [8,21,37,49,762,925,2179,2278,3383,37846,94878,8874717]
Modified indices: 1 4 3 2 6 5 9 7 8 10 11 12
Equal indices: ^ ^ ^ ^ ^

So the output is: 5


Challenge rules:



  • The input-list is guaranteed to only contain positive integers.

  • The input-list is guaranteed to be sorted from lowest to highest.

  • The input-list is guaranteed to contain at least two items.

  • As you can see above, both 0-based and 1-based indexing is allowed. Please state in your answer which of the two you've used, since outputs can differ accordingly!

  • Leading 0s after rotating are ignored, which can be seen with the 1-based example above, where the integer 102 becomes 021 after rotating, and is then treated as 21.

  • Integers are guaranteed unique in the input-list, and are guaranteed to remain unique after the rotations are completed.

  • Note that we only look at the positions of the rotated integers in correlation with the positions of the input, not with the values of the input-list. To clarify what I mean by this: with the input-list [1234,3412] and 1-based indexing, the list becomes [2341,1234] after rotating each integer it's index amount of times, and then when sorted becomes [1234,2341]. Although both the original input-list and the rotated list contains the integer 1234 at the leading position, they aren't the same! The rotated 1234 was 3412 before. The 1-indexed output for this input-list is therefore 0, since the two integers have swapped their positions.

  • Input is flexible. Can be a list/stream/array of integers/strings/digit-arrays, etc. Please state what you've used if you don't take the inputs as integers.

General rules:



  • This is code-golf, so shortest answer in bytes wins.

    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code (i.e. TIO).

  • Also, adding an explanation for your answer is highly recommended.

Test cases:



Input: [8, 49, 73, 102, 259, 762, 2782, 3383, 9217, 37846, 89487, 7471788]
0-based output: 6
1-based output: 5

Input: [1234, 3412]
0-based output: 2
1-based output: 0

Input: [2349, 2820, 17499, 21244, 29842, 31857, 46645, 56675, 61643, 61787]
0-based output: 3
1-based output: 0

Input: [4976, 11087, 18732, 22643, 52735]
0-based output: 2
1-based output: 3

Input: [4414, 5866, 7175, 8929, 14048, 16228, 16809, 19166, 24408, 25220, 29333, 44274, 47275, 47518, 53355]
0-based output: 4
1-based output: 4

Input: [11205, 16820, 63494]
0-based output: 1
1-based output: 3


Feel free to generate more random test cases with (or draw inspiration from) this ungolfed 05AB1E program, where the input is the size of the random list (NOTE: the output of this generator might not comply with the rule "Integers are guaranteed unique in the input-list, and are guaranteed to remain unique after the rotations are completed", so keep that in mind when using it.)







code-golf number integer sorting






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago







Kevin Cruijssen

















asked May 28 at 6:53









Kevin CruijssenKevin Cruijssen

45.2k576227




45.2k576227











  • $begingroup$
    May we assume that the input has at least 2 elements?
    $endgroup$
    – Robin Ryder
    May 28 at 21:02






  • 2




    $begingroup$
    @RobinRyder Hmm, my first thought would be no, but since I don't have any test cases with single items and it won't add much to the challenge, why not. I'll add a rule that the input-list is guaranteed to contain at least 2 items.
    $endgroup$
    – Kevin Cruijssen
    May 28 at 21:07










  • $begingroup$
    May we accept input as a list of strings?
    $endgroup$
    – Embodiment of Ignorance
    May 29 at 3:29






  • 1




    $begingroup$
    @Shaggy I've notified the answers I thought would benefit from it. If you see any that could benefit from it as well, feel free to notify them as well.
    $endgroup$
    – Kevin Cruijssen
    May 29 at 6:24






  • 1




    $begingroup$
    From the example it seems the output should be "The amount of integers which are still at the exact same index, after rotating the digits in each integer its index amount of times towards the left, and sorting the array again"?
    $endgroup$
    – qwr
    2 days ago
















  • $begingroup$
    May we assume that the input has at least 2 elements?
    $endgroup$
    – Robin Ryder
    May 28 at 21:02






  • 2




    $begingroup$
    @RobinRyder Hmm, my first thought would be no, but since I don't have any test cases with single items and it won't add much to the challenge, why not. I'll add a rule that the input-list is guaranteed to contain at least 2 items.
    $endgroup$
    – Kevin Cruijssen
    May 28 at 21:07










  • $begingroup$
    May we accept input as a list of strings?
    $endgroup$
    – Embodiment of Ignorance
    May 29 at 3:29






  • 1




    $begingroup$
    @Shaggy I've notified the answers I thought would benefit from it. If you see any that could benefit from it as well, feel free to notify them as well.
    $endgroup$
    – Kevin Cruijssen
    May 29 at 6:24






  • 1




    $begingroup$
    From the example it seems the output should be "The amount of integers which are still at the exact same index, after rotating the digits in each integer its index amount of times towards the left, and sorting the array again"?
    $endgroup$
    – qwr
    2 days ago















$begingroup$
May we assume that the input has at least 2 elements?
$endgroup$
– Robin Ryder
May 28 at 21:02




$begingroup$
May we assume that the input has at least 2 elements?
$endgroup$
– Robin Ryder
May 28 at 21:02




2




2




$begingroup$
@RobinRyder Hmm, my first thought would be no, but since I don't have any test cases with single items and it won't add much to the challenge, why not. I'll add a rule that the input-list is guaranteed to contain at least 2 items.
$endgroup$
– Kevin Cruijssen
May 28 at 21:07




$begingroup$
@RobinRyder Hmm, my first thought would be no, but since I don't have any test cases with single items and it won't add much to the challenge, why not. I'll add a rule that the input-list is guaranteed to contain at least 2 items.
$endgroup$
– Kevin Cruijssen
May 28 at 21:07












$begingroup$
May we accept input as a list of strings?
$endgroup$
– Embodiment of Ignorance
May 29 at 3:29




$begingroup$
May we accept input as a list of strings?
$endgroup$
– Embodiment of Ignorance
May 29 at 3:29




1




1




$begingroup$
@Shaggy I've notified the answers I thought would benefit from it. If you see any that could benefit from it as well, feel free to notify them as well.
$endgroup$
– Kevin Cruijssen
May 29 at 6:24




$begingroup$
@Shaggy I've notified the answers I thought would benefit from it. If you see any that could benefit from it as well, feel free to notify them as well.
$endgroup$
– Kevin Cruijssen
May 29 at 6:24




1




1




$begingroup$
From the example it seems the output should be "The amount of integers which are still at the exact same index, after rotating the digits in each integer its index amount of times towards the left, and sorting the array again"?
$endgroup$
– qwr
2 days ago




$begingroup$
From the example it seems the output should be "The amount of integers which are still at the exact same index, after rotating the digits in each integer its index amount of times towards the left, and sorting the array again"?
$endgroup$
– qwr
2 days ago










22 Answers
22






active

oldest

votes


















10












$begingroup$


R, 114 107 bytes



-5 bytes thanks to Giuseppe.



Outgolfed by digEmAll.





function(l)for(j in seq(l))l[j]=rep(l[j]%/%(e=10^(b=nchar(l[j]):1-1))%%10,j+1)[j+0:b]%*%e
sum(sort(l)==l)


Try it online!



0-indexed.



Ungolfed version:



function(l) 
n = length(l) # size of input
for (j in 1:n)
b = nchar(l[j]) -1 # number of digits in l[j] -1
e = 10 ^ (b:0)
d = l[j] %/% e %% 10 # convert to vector of digits
l[j] = rep(d, j + 1)[j + 0:b] %*% e # rotate digits and convert back to an integer

sum(sort(l) == l) # number of integers which are in the same position



To rotate the b digits of an integer by j positions, the code repeats the digits many times, then takes the digits in positions j+1 to j+b. For instance, to rotate 102 4 times, keep the values marked with an x (positions 5 to 7):



102102102102
xxx


so the result is 021.






share|improve this answer











$endgroup$












  • $begingroup$
    111 bytes
    $endgroup$
    – Giuseppe
    May 28 at 16:40










  • $begingroup$
    @Giuseppe Thanks! I need to remember seq(a=...). I expect there is some Map magic to perform, but my attempts left the byte count unchanged at best.
    $endgroup$
    – Robin Ryder
    May 28 at 19:23










  • $begingroup$
    Map might be a bit too expensive since the function boilerplate is at least 9 bytes, but if you switch to 0-indexing, we can do 109 bytes
    $endgroup$
    – Giuseppe
    May 28 at 19:26






  • 1




    $begingroup$
    Good find! Down to 107 by realizing that seq(a=l) can be seq(l) as long as the input has at least 2 elements (I asked whether this is OK).
    $endgroup$
    – Robin Ryder
    May 28 at 21:02






  • 1




    $begingroup$
    Let's change the approach :D
    $endgroup$
    – digEmAll
    May 29 at 12:03



















6












$begingroup$


Japt -x, 10 9 bytes



0-based



í¶UñÈséYn


Try it



í¶UñÈséYn :Implicit input of integer array U
í :Interleave with
Uñ :U sorted by
È :Passing each integer at 0-based index Y through the following function
s : Convert to string
é : Rotate right by
Yn : Y negated
¶ :Reduce each pair by testing for equality
:Implicit output of sum of resulting array





share|improve this answer











$endgroup$




















    5












    $begingroup$


    05AB1E, 9 bytes



    ΣN._ï}-_O


    Try it online!



    Uses 0-based indexing.



    Explanation:



    Σ } # sort the input by
    N._ # each number rotated its index to the left
    ï # then cast to int (otherwise the sort is alphabetic)
    - # subtract the input from the result
    _O # then count the 0s





    share|improve this answer









    $endgroup$




















      4












      $begingroup$


      Jelly, 9 bytes



      Dṙ"JḌỤ=JS


      Try it online!



      Monadic link that takes a list of integers and returns an integer indicating the number of integers that remain in place after performing the rotation using 1-indexing.



      Explanation



      D | Convert to decimal digits
      ṙ"J | Rotate left by index
      Ḍ | Convert back to integer
      Ụ | Index in sorted list
      =J | Check if equal to index in original list
      S | Sum





      share|improve this answer











      $endgroup$




















        4












        $begingroup$


        Python 2, 104 100 97 93 bytes





        b=[int((s*-~i)[i:i+len(s)])for i,s in enumerate(input())]
        print map(cmp,b,sorted(b)).count(0)


        Try it online!



        0-based indexing.



        First rotates each number, and then compares the result with result, but sorted.




        Saved:



        • -3 bytes, thanks to Erik the Outgolfer

        • -4 bytes, thanks to Kevin Cruijssen (and his rule-change)





        share|improve this answer











        $endgroup$












        • $begingroup$
          -3 as a full program.
          $endgroup$
          – Erik the Outgolfer
          May 28 at 16:04










        • $begingroup$
          @eriktheoutgolfer thanks, I was too busy trying to make a lambda, that I forgot about input() :)
          $endgroup$
          – TFeld
          May 28 at 17:57










        • $begingroup$
          That's why I first try to make a full program... :D Seriously, if you first try to make a full program, you will then clearly see if it's worth converting to a lambda or not. Don't start with a def right away (they're pretty useless in Python 2, contrary to Python 3).
          $endgroup$
          – Erik the Outgolfer
          May 28 at 18:00











        • $begingroup$
          I've allowed the input-list as strings now, so you can drop 4 bytes by removing the grave accents surrounding the s.
          $endgroup$
          – Kevin Cruijssen
          May 29 at 6:19


















        4












        $begingroup$


        R, 90 88 85 bytes





        function(x)sum(rank(as.double(substr(strrep(x,L<-sum(x|1)),y<-1:L,y+nchar(x)-1)))==y)


        Try it online!



        • 0-indexed rotation

        • rotation strategy inspired by @RobinRyder's answer

        • -5 bytes thanks to @Giuseppe

        Unrolled code with explanation :



        function(x)1) # store the length of x

        R=strrep(x,L) # repeat each string of vector x L times

        S=substring(R,1:L,1:L+nchar(x)-1)) # for each string of R, extract a substring of the same
        # length of the original number starting from index 1
        # for the 1st element, index 2 for the 2nd and so on
        # (this basically rotates the strings )

        Y=as.double(S) # convert the strings to numbers

        sum(rank(Y)==1:L) # return the number of times the ranks of Y
        # match with their original positions






        share|improve this answer











        $endgroup$




















          3












          $begingroup$


          J, 28 26 bytes



          -2 bytes thanks to Jonah



          1#.i.@#=[:/:#".@|.&>":&.>


          Try it online!






          share|improve this answer











          $endgroup$








          • 1




            $begingroup$
            Nice. Looks like you can lose the "0 (Try it online!) but other than that I didn't see a way to golf further.
            $endgroup$
            – Jonah
            May 28 at 22:58










          • $begingroup$
            @Jonah Thank you! I don't know why I didn't try without it.
            $endgroup$
            – Galen Ivanov
            May 29 at 3:46


















          2












          $begingroup$


          Stax, 11 10 bytes



          ìát'óJ♣á◄·


          Run and debug it



          This program uses 0-based indexing and takes input as an array of strings. I saved a byte by taking opportunity of the new input clarificatinos.






          share|improve this answer











          $endgroup$




















            2












            $begingroup$


            Perl 5 -pa, 80 bytes





            map$d$_.substr$_,0,$b%y///c,''=$b++,@F;$+=$d$_==$r++for sort$a-$bkeys%d}t[1:m+1]&put(b,[+t,l[k]])&x
            l[i:=1to*l]=sortf(b,1)[i,2]&n+:=1&x
            return n
            end


            Try it online!



            1-based indexing






            share. Also, you can change your first loop to for((i=0;++i<=$#;));.
            $endgroup$
            – Kevin Cruijssen
            May 29 at 13:21










          • $begingroup$
            @KevinCruijssen -- usually I have found Bash and friends needs that space to parse the command line. On this occasion you are correct it may be removed. Nice idea to re-base and pre-increment. 202 bytes.
            $endgroup$
            – PJF
            May 29 at 13:29



















          • 1












            $begingroup$


            Scala, 200 160 bytes





            def f(a:Seq[String])=
            a.zipWithIndex
            .map(x=>val r=x._2%x._1.size;x._1.drop(r)+x._1.take(r)->x._2)
            .sortBy(_._1.toInt)
            .zipWithIndex
            .filter(x=>x._1._2==x._2)
            .size


            Try it online!



            0-indexed. 160 chars after removing indentation and newlines. This prints 6:



            println( f(Seq("8","49","73","102","259","762","2782","3383","9217","37846","89487","7471788")) )





            share|improve this answer











            $endgroup$













              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "200"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f186169%2frotated-position-of-integers%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              22 Answers
              22






              active

              oldest

              votes








              22 Answers
              22






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              10












              $begingroup$


              R, 114 107 bytes



              -5 bytes thanks to Giuseppe.



              Outgolfed by digEmAll.





              function(l)for(j in seq(l))l[j]=rep(l[j]%/%(e=10^(b=nchar(l[j]):1-1))%%10,j+1)[j+0:b]%*%e
              sum(sort(l)==l)


              Try it online!



              0-indexed.



              Ungolfed version:



              function(l) 
              n = length(l) # size of input
              for (j in 1:n)
              b = nchar(l[j]) -1 # number of digits in l[j] -1
              e = 10 ^ (b:0)
              d = l[j] %/% e %% 10 # convert to vector of digits
              l[j] = rep(d, j + 1)[j + 0:b] %*% e # rotate digits and convert back to an integer

              sum(sort(l) == l) # number of integers which are in the same position



              To rotate the b digits of an integer by j positions, the code repeats the digits many times, then takes the digits in positions j+1 to j+b. For instance, to rotate 102 4 times, keep the values marked with an x (positions 5 to 7):



              102102102102
              xxx


              so the result is 021.






              share|improve this answer











              $endgroup$












              • $begingroup$
                111 bytes
                $endgroup$
                – Giuseppe
                May 28 at 16:40










              • $begingroup$
                @Giuseppe Thanks! I need to remember seq(a=...). I expect there is some Map magic to perform, but my attempts left the byte count unchanged at best.
                $endgroup$
                – Robin Ryder
                May 28 at 19:23










              • $begingroup$
                Map might be a bit too expensive since the function boilerplate is at least 9 bytes, but if you switch to 0-indexing, we can do 109 bytes
                $endgroup$
                – Giuseppe
                May 28 at 19:26






              • 1




                $begingroup$
                Good find! Down to 107 by realizing that seq(a=l) can be seq(l) as long as the input has at least 2 elements (I asked whether this is OK).
                $endgroup$
                – Robin Ryder
                May 28 at 21:02






              • 1




                $begingroup$
                Let's change the approach :D
                $endgroup$
                – digEmAll
                May 29 at 12:03
















              10












              $begingroup$


              R, 114 107 bytes



              -5 bytes thanks to Giuseppe.



              Outgolfed by digEmAll.





              function(l)for(j in seq(l))l[j]=rep(l[j]%/%(e=10^(b=nchar(l[j]):1-1))%%10,j+1)[j+0:b]%*%e
              sum(sort(l)==l)


              Try it online!



              0-indexed.



              Ungolfed version:



              function(l) 
              n = length(l) # size of input
              for (j in 1:n)
              b = nchar(l[j]) -1 # number of digits in l[j] -1
              e = 10 ^ (b:0)
              d = l[j] %/% e %% 10 # convert to vector of digits
              l[j] = rep(d, j + 1)[j + 0:b] %*% e # rotate digits and convert back to an integer

              sum(sort(l) == l) # number of integers which are in the same position



              To rotate the b digits of an integer by j positions, the code repeats the digits many times, then takes the digits in positions j+1 to j+b. For instance, to rotate 102 4 times, keep the values marked with an x (positions 5 to 7):



              102102102102
              xxx


              so the result is 021.






              share|improve this answer











              $endgroup$












              • $begingroup$
                111 bytes
                $endgroup$
                – Giuseppe
                May 28 at 16:40










              • $begingroup$
                @Giuseppe Thanks! I need to remember seq(a=...). I expect there is some Map magic to perform, but my attempts left the byte count unchanged at best.
                $endgroup$
                – Robin Ryder
                May 28 at 19:23










              • $begingroup$
                Map might be a bit too expensive since the function boilerplate is at least 9 bytes, but if you switch to 0-indexing, we can do 109 bytes
                $endgroup$
                – Giuseppe
                May 28 at 19:26






              • 1




                $begingroup$
                Good find! Down to 107 by realizing that seq(a=l) can be seq(l) as long as the input has at least 2 elements (I asked whether this is OK).
                $endgroup$
                – Robin Ryder
                May 28 at 21:02






              • 1




                $begingroup$
                Let's change the approach :D
                $endgroup$
                – digEmAll
                May 29 at 12:03














              10












              10








              10





              $begingroup$


              R, 114 107 bytes



              -5 bytes thanks to Giuseppe.



              Outgolfed by digEmAll.





              function(l)for(j in seq(l))l[j]=rep(l[j]%/%(e=10^(b=nchar(l[j]):1-1))%%10,j+1)[j+0:b]%*%e
              sum(sort(l)==l)


              Try it online!



              0-indexed.



              Ungolfed version:



              function(l) 
              n = length(l) # size of input
              for (j in 1:n)
              b = nchar(l[j]) -1 # number of digits in l[j] -1
              e = 10 ^ (b:0)
              d = l[j] %/% e %% 10 # convert to vector of digits
              l[j] = rep(d, j + 1)[j + 0:b] %*% e # rotate digits and convert back to an integer

              sum(sort(l) == l) # number of integers which are in the same position



              To rotate the b digits of an integer by j positions, the code repeats the digits many times, then takes the digits in positions j+1 to j+b. For instance, to rotate 102 4 times, keep the values marked with an x (positions 5 to 7):



              102102102102
              xxx


              so the result is 021.






              share|improve this answer











              $endgroup$




              R, 114 107 bytes



              -5 bytes thanks to Giuseppe.



              Outgolfed by digEmAll.





              function(l)for(j in seq(l))l[j]=rep(l[j]%/%(e=10^(b=nchar(l[j]):1-1))%%10,j+1)[j+0:b]%*%e
              sum(sort(l)==l)


              Try it online!



              0-indexed.



              Ungolfed version:



              function(l) 
              n = length(l) # size of input
              for (j in 1:n)
              b = nchar(l[j]) -1 # number of digits in l[j] -1
              e = 10 ^ (b:0)
              d = l[j] %/% e %% 10 # convert to vector of digits
              l[j] = rep(d, j + 1)[j + 0:b] %*% e # rotate digits and convert back to an integer

              sum(sort(l) == l) # number of integers which are in the same position



              To rotate the b digits of an integer by j positions, the code repeats the digits many times, then takes the digits in positions j+1 to j+b. For instance, to rotate 102 4 times, keep the values marked with an x (positions 5 to 7):



              102102102102
              xxx


              so the result is 021.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited 11 hours ago

























              answered May 28 at 8:27









              Robin RyderRobin Ryder

              1,388216




              1,388216











              • $begingroup$
                111 bytes
                $endgroup$
                – Giuseppe
                May 28 at 16:40










              • $begingroup$
                @Giuseppe Thanks! I need to remember seq(a=...). I expect there is some Map magic to perform, but my attempts left the byte count unchanged at best.
                $endgroup$
                – Robin Ryder
                May 28 at 19:23










              • $begingroup$
                Map might be a bit too expensive since the function boilerplate is at least 9 bytes, but if you switch to 0-indexing, we can do 109 bytes
                $endgroup$
                – Giuseppe
                May 28 at 19:26






              • 1




                $begingroup$
                Good find! Down to 107 by realizing that seq(a=l) can be seq(l) as long as the input has at least 2 elements (I asked whether this is OK).
                $endgroup$
                – Robin Ryder
                May 28 at 21:02






              • 1




                $begingroup$
                Let's change the approach :D
                $endgroup$
                – digEmAll
                May 29 at 12:03

















              • $begingroup$
                111 bytes
                $endgroup$
                – Giuseppe
                May 28 at 16:40










              • $begingroup$
                @Giuseppe Thanks! I need to remember seq(a=...). I expect there is some Map magic to perform, but my attempts left the byte count unchanged at best.
                $endgroup$
                – Robin Ryder
                May 28 at 19:23










              • $begingroup$
                Map might be a bit too expensive since the function boilerplate is at least 9 bytes, but if you switch to 0-indexing, we can do 109 bytes
                $endgroup$
                – Giuseppe
                May 28 at 19:26






              • 1




                $begingroup$
                Good find! Down to 107 by realizing that seq(a=l) can be seq(l) as long as the input has at least 2 elements (I asked whether this is OK).
                $endgroup$
                – Robin Ryder
                May 28 at 21:02






              • 1




                $begingroup$
                Let's change the approach :D
                $endgroup$
                – digEmAll
                May 29 at 12:03
















              $begingroup$
              111 bytes
              $endgroup$
              – Giuseppe
              May 28 at 16:40




              $begingroup$
              111 bytes
              $endgroup$
              – Giuseppe
              May 28 at 16:40












              $begingroup$
              @Giuseppe Thanks! I need to remember seq(a=...). I expect there is some Map magic to perform, but my attempts left the byte count unchanged at best.
              $endgroup$
              – Robin Ryder
              May 28 at 19:23




              $begingroup$
              @Giuseppe Thanks! I need to remember seq(a=...). I expect there is some Map magic to perform, but my attempts left the byte count unchanged at best.
              $endgroup$
              – Robin Ryder
              May 28 at 19:23












              $begingroup$
              Map might be a bit too expensive since the function boilerplate is at least 9 bytes, but if you switch to 0-indexing, we can do 109 bytes
              $endgroup$
              – Giuseppe
              May 28 at 19:26




              $begingroup$
              Map might be a bit too expensive since the function boilerplate is at least 9 bytes, but if you switch to 0-indexing, we can do 109 bytes
              $endgroup$
              – Giuseppe
              May 28 at 19:26




              1




              1




              $begingroup$
              Good find! Down to 107 by realizing that seq(a=l) can be seq(l) as long as the input has at least 2 elements (I asked whether this is OK).
              $endgroup$
              – Robin Ryder
              May 28 at 21:02




              $begingroup$
              Good find! Down to 107 by realizing that seq(a=l) can be seq(l) as long as the input has at least 2 elements (I asked whether this is OK).
              $endgroup$
              – Robin Ryder
              May 28 at 21:02




              1




              1




              $begingroup$
              Let's change the approach :D
              $endgroup$
              – digEmAll
              May 29 at 12:03





              $begingroup$
              Let's change the approach :D
              $endgroup$
              – digEmAll
              May 29 at 12:03












              6












              $begingroup$


              Japt -x, 10 9 bytes



              0-based



              í¶UñÈséYn


              Try it



              í¶UñÈséYn :Implicit input of integer array U
              í :Interleave with
              Uñ :U sorted by
              È :Passing each integer at 0-based index Y through the following function
              s : Convert to string
              é : Rotate right by
              Yn : Y negated
              ¶ :Reduce each pair by testing for equality
              :Implicit output of sum of resulting array





              share|improve this answer











              $endgroup$

















                6












                $begingroup$


                Japt -x, 10 9 bytes



                0-based



                í¶UñÈséYn


                Try it



                í¶UñÈséYn :Implicit input of integer array U
                í :Interleave with
                Uñ :U sorted by
                È :Passing each integer at 0-based index Y through the following function
                s : Convert to string
                é : Rotate right by
                Yn : Y negated
                ¶ :Reduce each pair by testing for equality
                :Implicit output of sum of resulting array





                share|improve this answer











                $endgroup$















                  6












                  6








                  6





                  $begingroup$


                  Japt -x, 10 9 bytes



                  0-based



                  í¶UñÈséYn


                  Try it



                  í¶UñÈséYn :Implicit input of integer array U
                  í :Interleave with
                  Uñ :U sorted by
                  È :Passing each integer at 0-based index Y through the following function
                  s : Convert to string
                  é : Rotate right by
                  Yn : Y negated
                  ¶ :Reduce each pair by testing for equality
                  :Implicit output of sum of resulting array





                  share|improve this answer











                  $endgroup$




                  Japt -x, 10 9 bytes



                  0-based



                  í¶UñÈséYn


                  Try it



                  í¶UñÈséYn :Implicit input of integer array U
                  í :Interleave with
                  Uñ :U sorted by
                  È :Passing each integer at 0-based index Y through the following function
                  s : Convert to string
                  é : Rotate right by
                  Yn : Y negated
                  ¶ :Reduce each pair by testing for equality
                  :Implicit output of sum of resulting array






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited May 28 at 19:20

























                  answered May 28 at 15:25









                  ShaggyShaggy

                  19.6k31768




                  19.6k31768





















                      5












                      $begingroup$


                      05AB1E, 9 bytes



                      ΣN._ï}-_O


                      Try it online!



                      Uses 0-based indexing.



                      Explanation:



                      Σ } # sort the input by
                      N._ # each number rotated its index to the left
                      ï # then cast to int (otherwise the sort is alphabetic)
                      - # subtract the input from the result
                      _O # then count the 0s





                      share|improve this answer









                      $endgroup$

















                        5












                        $begingroup$


                        05AB1E, 9 bytes



                        ΣN._ï}-_O


                        Try it online!



                        Uses 0-based indexing.



                        Explanation:



                        Σ } # sort the input by
                        N._ # each number rotated its index to the left
                        ï # then cast to int (otherwise the sort is alphabetic)
                        - # subtract the input from the result
                        _O # then count the 0s





                        share|improve this answer









                        $endgroup$















                          5












                          5








                          5





                          $begingroup$


                          05AB1E, 9 bytes



                          ΣN._ï}-_O


                          Try it online!



                          Uses 0-based indexing.



                          Explanation:



                          Σ } # sort the input by
                          N._ # each number rotated its index to the left
                          ï # then cast to int (otherwise the sort is alphabetic)
                          - # subtract the input from the result
                          _O # then count the 0s





                          share|improve this answer









                          $endgroup$




                          05AB1E, 9 bytes



                          ΣN._ï}-_O


                          Try it online!



                          Uses 0-based indexing.



                          Explanation:



                          Σ } # sort the input by
                          N._ # each number rotated its index to the left
                          ï # then cast to int (otherwise the sort is alphabetic)
                          - # subtract the input from the result
                          _O # then count the 0s






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered May 28 at 8:52









                          GrimyGrimy

                          3,4031021




                          3,4031021





















                              4












                              $begingroup$


                              Jelly, 9 bytes



                              Dṙ"JḌỤ=JS


                              Try it online!



                              Monadic link that takes a list of integers and returns an integer indicating the number of integers that remain in place after performing the rotation using 1-indexing.



                              Explanation



                              D | Convert to decimal digits
                              ṙ"J | Rotate left by index
                              Ḍ | Convert back to integer
                              Ụ | Index in sorted list
                              =J | Check if equal to index in original list
                              S | Sum





                              share|improve this answer











                              $endgroup$

















                                4












                                $begingroup$


                                Jelly, 9 bytes



                                Dṙ"JḌỤ=JS


                                Try it online!



                                Monadic link that takes a list of integers and returns an integer indicating the number of integers that remain in place after performing the rotation using 1-indexing.



                                Explanation



                                D | Convert to decimal digits
                                ṙ"J | Rotate left by index
                                Ḍ | Convert back to integer
                                Ụ | Index in sorted list
                                =J | Check if equal to index in original list
                                S | Sum





                                share|improve this answer











                                $endgroup$















                                  4












                                  4








                                  4





                                  $begingroup$


                                  Jelly, 9 bytes



                                  Dṙ"JḌỤ=JS


                                  Try it online!



                                  Monadic link that takes a list of integers and returns an integer indicating the number of integers that remain in place after performing the rotation using 1-indexing.



                                  Explanation



                                  D | Convert to decimal digits
                                  ṙ"J | Rotate left by index
                                  Ḍ | Convert back to integer
                                  Ụ | Index in sorted list
                                  =J | Check if equal to index in original list
                                  S | Sum





                                  share|improve this answer











                                  $endgroup$




                                  Jelly, 9 bytes



                                  Dṙ"JḌỤ=JS


                                  Try it online!



                                  Monadic link that takes a list of integers and returns an integer indicating the number of integers that remain in place after performing the rotation using 1-indexing.



                                  Explanation



                                  D | Convert to decimal digits
                                  ṙ"J | Rotate left by index
                                  Ḍ | Convert back to integer
                                  Ụ | Index in sorted list
                                  =J | Check if equal to index in original list
                                  S | Sum






                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited May 28 at 15:39

























                                  answered May 28 at 8:58









                                  Nick KennedyNick Kennedy

                                  2,67969




                                  2,67969





















                                      4












                                      $begingroup$


                                      Python 2, 104 100 97 93 bytes





                                      b=[int((s*-~i)[i:i+len(s)])for i,s in enumerate(input())]
                                      print map(cmp,b,sorted(b)).count(0)


                                      Try it online!



                                      0-based indexing.



                                      First rotates each number, and then compares the result with result, but sorted.




                                      Saved:



                                      • -3 bytes, thanks to Erik the Outgolfer

                                      • -4 bytes, thanks to Kevin Cruijssen (and his rule-change)





                                      share|improve this answer











                                      $endgroup$












                                      • $begingroup$
                                        -3 as a full program.
                                        $endgroup$
                                        – Erik the Outgolfer
                                        May 28 at 16:04










                                      • $begingroup$
                                        @eriktheoutgolfer thanks, I was too busy trying to make a lambda, that I forgot about input() :)
                                        $endgroup$
                                        – TFeld
                                        May 28 at 17:57










                                      • $begingroup$
                                        That's why I first try to make a full program... :D Seriously, if you first try to make a full program, you will then clearly see if it's worth converting to a lambda or not. Don't start with a def right away (they're pretty useless in Python 2, contrary to Python 3).
                                        $endgroup$
                                        – Erik the Outgolfer
                                        May 28 at 18:00











                                      • $begingroup$
                                        I've allowed the input-list as strings now, so you can drop 4 bytes by removing the grave accents surrounding the s.
                                        $endgroup$
                                        – Kevin Cruijssen
                                        May 29 at 6:19















                                      4












                                      $begingroup$


                                      Python 2, 104 100 97 93 bytes





                                      b=[int((s*-~i)[i:i+len(s)])for i,s in enumerate(input())]
                                      print map(cmp,b,sorted(b)).count(0)


                                      Try it online!



                                      0-based indexing.



                                      First rotates each number, and then compares the result with result, but sorted.




                                      Saved:



                                      • -3 bytes, thanks to Erik the Outgolfer

                                      • -4 bytes, thanks to Kevin Cruijssen (and his rule-change)





                                      share|improve this answer











                                      $endgroup$












                                      • $begingroup$
                                        -3 as a full program.
                                        $endgroup$
                                        – Erik the Outgolfer
                                        May 28 at 16:04










                                      • $begingroup$
                                        @eriktheoutgolfer thanks, I was too busy trying to make a lambda, that I forgot about input() :)
                                        $endgroup$
                                        – TFeld
                                        May 28 at 17:57










                                      • $begingroup$
                                        That's why I first try to make a full program... :D Seriously, if you first try to make a full program, you will then clearly see if it's worth converting to a lambda or not. Don't start with a def right away (they're pretty useless in Python 2, contrary to Python 3).
                                        $endgroup$
                                        – Erik the Outgolfer
                                        May 28 at 18:00











                                      • $begingroup$
                                        I've allowed the input-list as strings now, so you can drop 4 bytes by removing the grave accents surrounding the s.
                                        $endgroup$
                                        – Kevin Cruijssen
                                        May 29 at 6:19













                                      4












                                      4








                                      4





                                      $begingroup$


                                      Python 2, 104 100 97 93 bytes





                                      b=[int((s*-~i)[i:i+len(s)])for i,s in enumerate(input())]
                                      print map(cmp,b,sorted(b)).count(0)


                                      Try it online!



                                      0-based indexing.



                                      First rotates each number, and then compares the result with result, but sorted.




                                      Saved:



                                      • -3 bytes, thanks to Erik the Outgolfer

                                      • -4 bytes, thanks to Kevin Cruijssen (and his rule-change)





                                      share|improve this answer











                                      $endgroup$




                                      Python 2, 104 100 97 93 bytes





                                      b=[int((s*-~i)[i:i+len(s)])for i,s in enumerate(input())]
                                      print map(cmp,b,sorted(b)).count(0)


                                      Try it online!



                                      0-based indexing.



                                      First rotates each number, and then compares the result with result, but sorted.




                                      Saved:



                                      • -3 bytes, thanks to Erik the Outgolfer

                                      • -4 bytes, thanks to Kevin Cruijssen (and his rule-change)






                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited May 29 at 6:51

























                                      answered May 28 at 7:20









                                      TFeldTFeld

                                      16.9k31452




                                      16.9k31452











                                      • $begingroup$
                                        -3 as a full program.
                                        $endgroup$
                                        – Erik the Outgolfer
                                        May 28 at 16:04










                                      • $begingroup$
                                        @eriktheoutgolfer thanks, I was too busy trying to make a lambda, that I forgot about input() :)
                                        $endgroup$
                                        – TFeld
                                        May 28 at 17:57










                                      • $begingroup$
                                        That's why I first try to make a full program... :D Seriously, if you first try to make a full program, you will then clearly see if it's worth converting to a lambda or not. Don't start with a def right away (they're pretty useless in Python 2, contrary to Python 3).
                                        $endgroup$
                                        – Erik the Outgolfer
                                        May 28 at 18:00











                                      • $begingroup$
                                        I've allowed the input-list as strings now, so you can drop 4 bytes by removing the grave accents surrounding the s.
                                        $endgroup$
                                        – Kevin Cruijssen
                                        May 29 at 6:19
















                                      • $begingroup$
                                        -3 as a full program.
                                        $endgroup$
                                        – Erik the Outgolfer
                                        May 28 at 16:04










                                      • $begingroup$
                                        @eriktheoutgolfer thanks, I was too busy trying to make a lambda, that I forgot about input() :)
                                        $endgroup$
                                        – TFeld
                                        May 28 at 17:57










                                      • $begingroup$
                                        That's why I first try to make a full program... :D Seriously, if you first try to make a full program, you will then clearly see if it's worth converting to a lambda or not. Don't start with a def right away (they're pretty useless in Python 2, contrary to Python 3).
                                        $endgroup$
                                        – Erik the Outgolfer
                                        May 28 at 18:00











                                      • $begingroup$
                                        I've allowed the input-list as strings now, so you can drop 4 bytes by removing the grave accents surrounding the s.
                                        $endgroup$
                                        – Kevin Cruijssen
                                        May 29 at 6:19















                                      $begingroup$
                                      -3 as a full program.
                                      $endgroup$
                                      – Erik the Outgolfer
                                      May 28 at 16:04




                                      $begingroup$
                                      -3 as a full program.
                                      $endgroup$
                                      – Erik the Outgolfer
                                      May 28 at 16:04












                                      $begingroup$
                                      @eriktheoutgolfer thanks, I was too busy trying to make a lambda, that I forgot about input() :)
                                      $endgroup$
                                      – TFeld
                                      May 28 at 17:57




                                      $begingroup$
                                      @eriktheoutgolfer thanks, I was too busy trying to make a lambda, that I forgot about input() :)
                                      $endgroup$
                                      – TFeld
                                      May 28 at 17:57












                                      $begingroup$
                                      That's why I first try to make a full program... :D Seriously, if you first try to make a full program, you will then clearly see if it's worth converting to a lambda or not. Don't start with a def right away (they're pretty useless in Python 2, contrary to Python 3).
                                      $endgroup$
                                      – Erik the Outgolfer
                                      May 28 at 18:00





                                      $begingroup$
                                      That's why I first try to make a full program... :D Seriously, if you first try to make a full program, you will then clearly see if it's worth converting to a lambda or not. Don't start with a def right away (they're pretty useless in Python 2, contrary to Python 3).
                                      $endgroup$
                                      – Erik the Outgolfer
                                      May 28 at 18:00













                                      $begingroup$
                                      I've allowed the input-list as strings now, so you can drop 4 bytes by removing the grave accents surrounding the s.
                                      $endgroup$
                                      – Kevin Cruijssen
                                      May 29 at 6:19




                                      $begingroup$
                                      I've allowed the input-list as strings now, so you can drop 4 bytes by removing the grave accents surrounding the s.
                                      $endgroup$
                                      – Kevin Cruijssen
                                      May 29 at 6:19











                                      4












                                      $begingroup$


                                      R, 90 88 85 bytes





                                      function(x)sum(rank(as.double(substr(strrep(x,L<-sum(x|1)),y<-1:L,y+nchar(x)-1)))==y)


                                      Try it online!



                                      • 0-indexed rotation

                                      • rotation strategy inspired by @RobinRyder's answer

                                      • -5 bytes thanks to @Giuseppe

                                      Unrolled code with explanation :



                                      function(x)1) # store the length of x

                                      R=strrep(x,L) # repeat each string of vector x L times

                                      S=substring(R,1:L,1:L+nchar(x)-1)) # for each string of R, extract a substring of the same
                                      # length of the original number starting from index 1
                                      # for the 1st element, index 2 for the 2nd and so on
                                      # (this basically rotates the strings )

                                      Y=as.double(S) # convert the strings to numbers

                                      sum(rank(Y)==1:L) # return the number of times the ranks of Y
                                      # match with their original positions






                                      share|improve this answer











                                      $endgroup$

















                                        4












                                        $begingroup$


                                        R, 90 88 85 bytes





                                        function(x)sum(rank(as.double(substr(strrep(x,L<-sum(x|1)),y<-1:L,y+nchar(x)-1)))==y)


                                        Try it online!



                                        • 0-indexed rotation

                                        • rotation strategy inspired by @RobinRyder's answer

                                        • -5 bytes thanks to @Giuseppe

                                        Unrolled code with explanation :



                                        function(x)1) # store the length of x

                                        R=strrep(x,L) # repeat each string of vector x L times

                                        S=substring(R,1:L,1:L+nchar(x)-1)) # for each string of R, extract a substring of the same
                                        # length of the original number starting from index 1
                                        # for the 1st element, index 2 for the 2nd and so on
                                        # (this basically rotates the strings )

                                        Y=as.double(S) # convert the strings to numbers

                                        sum(rank(Y)==1:L) # return the number of times the ranks of Y
                                        # match with their original positions






                                        share|improve this answer











                                        $endgroup$















                                          4












                                          4








                                          4





                                          $begingroup$


                                          R, 90 88 85 bytes





                                          function(x)sum(rank(as.double(substr(strrep(x,L<-sum(x|1)),y<-1:L,y+nchar(x)-1)))==y)


                                          Try it online!



                                          • 0-indexed rotation

                                          • rotation strategy inspired by @RobinRyder's answer

                                          • -5 bytes thanks to @Giuseppe

                                          Unrolled code with explanation :



                                          function(x)1) # store the length of x

                                          R=strrep(x,L) # repeat each string of vector x L times

                                          S=substring(R,1:L,1:L+nchar(x)-1)) # for each string of R, extract a substring of the same
                                          # length of the original number starting from index 1
                                          # for the 1st element, index 2 for the 2nd and so on
                                          # (this basically rotates the strings )

                                          Y=as.double(S) # convert the strings to numbers

                                          sum(rank(Y)==1:L) # return the number of times the ranks of Y
                                          # match with their original positions






                                          share|improve this answer











                                          $endgroup$




                                          R, 90 88 85 bytes





                                          function(x)sum(rank(as.double(substr(strrep(x,L<-sum(x|1)),y<-1:L,y+nchar(x)-1)))==y)


                                          Try it online!



                                          • 0-indexed rotation

                                          • rotation strategy inspired by @RobinRyder's answer

                                          • -5 bytes thanks to @Giuseppe

                                          Unrolled code with explanation :



                                          function(x)1) # store the length of x

                                          R=strrep(x,L) # repeat each string of vector x L times

                                          S=substring(R,1:L,1:L+nchar(x)-1)) # for each string of R, extract a substring of the same
                                          # length of the original number starting from index 1
                                          # for the 1st element, index 2 for the 2nd and so on
                                          # (this basically rotates the strings )

                                          Y=as.double(S) # convert the strings to numbers

                                          sum(rank(Y)==1:L) # return the number of times the ranks of Y
                                          # match with their original positions







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited May 29 at 19:20

























                                          answered May 29 at 17:56









                                          digEmAlldigEmAll

                                          3,859518




                                          3,859518





















                                              3












                                              $begingroup$


                                              J, 28 26 bytes



                                              -2 bytes thanks to Jonah



                                              1#.i.@#=[:/:#".@|.&>":&.>


                                              Try it online!






                                              share|improve this answer











                                              $endgroup$








                                              • 1




                                                $begingroup$
                                                Nice. Looks like you can lose the "0 (Try it online!) but other than that I didn't see a way to golf further.
                                                $endgroup$
                                                – Jonah
                                                May 28 at 22:58










                                              • $begingroup$
                                                @Jonah Thank you! I don't know why I didn't try without it.
                                                $endgroup$
                                                – Galen Ivanov
                                                May 29 at 3:46















                                              3












                                              $begingroup$


                                              J, 28 26 bytes



                                              -2 bytes thanks to Jonah



                                              1#.i.@#=[:/:#".@|.&>":&.>


                                              Try it online!






                                              share|improve this answer











                                              $endgroup$








                                              • 1




                                                $begingroup$
                                                Nice. Looks like you can lose the "0 (Try it online!) but other than that I didn't see a way to golf further.
                                                $endgroup$
                                                – Jonah
                                                May 28 at 22:58










                                              • $begingroup$
                                                @Jonah Thank you! I don't know why I didn't try without it.
                                                $endgroup$
                                                – Galen Ivanov
                                                May 29 at 3:46













                                              3












                                              3








                                              3





                                              $begingroup$


                                              J, 28 26 bytes



                                              -2 bytes thanks to Jonah



                                              1#.i.@#=[:/:#".@|.&>":&.>


                                              Try it online!






                                              share|improve this answer











                                              $endgroup$




                                              J, 28 26 bytes



                                              -2 bytes thanks to Jonah



                                              1#.i.@#=[:/:#".@|.&>":&.>


                                              Try it online!







                                              share|improve this answer














                                              share|improve this answer



                                              share|improve this answer








                                              edited May 29 at 3:48

























                                              answered May 28 at 14:20









                                              Galen IvanovGalen Ivanov

                                              8,38711237




                                              8,38711237







                                              • 1




                                                $begingroup$
                                                Nice. Looks like you can lose the "0 (Try it online!) but other than that I didn't see a way to golf further.
                                                $endgroup$
                                                – Jonah
                                                May 28 at 22:58










                                              • $begingroup$
                                                @Jonah Thank you! I don't know why I didn't try without it.
                                                $endgroup$
                                                – Galen Ivanov
                                                May 29 at 3:46












                                              • 1




                                                $begingroup$
                                                Nice. Looks like you can lose the "0 (Try it online!) but other than that I didn't see a way to golf further.
                                                $endgroup$
                                                – Jonah
                                                May 28 at 22:58










                                              • $begingroup$
                                                @Jonah Thank you! I don't know why I didn't try without it.
                                                $endgroup$
                                                – Galen Ivanov
                                                May 29 at 3:46







                                              1




                                              1




                                              $begingroup$
                                              Nice. Looks like you can lose the "0 (Try it online!) but other than that I didn't see a way to golf further.
                                              $endgroup$
                                              – Jonah
                                              May 28 at 22:58




                                              $begingroup$
                                              Nice. Looks like you can lose the "0 (Try it online!) but other than that I didn't see a way to golf further.
                                              $endgroup$
                                              – Jonah
                                              May 28 at 22:58












                                              $begingroup$
                                              @Jonah Thank you! I don't know why I didn't try without it.
                                              $endgroup$
                                              – Galen Ivanov
                                              May 29 at 3:46




                                              $begingroup$
                                              @Jonah Thank you! I don't know why I didn't try without it.
                                              $endgroup$
                                              – Galen Ivanov
                                              May 29 at 3:46











                                              2












                                              $begingroup$


                                              Stax, 11 10 bytes



                                              ìát'óJ♣á◄·


                                              Run and debug it



                                              This program uses 0-based indexing and takes input as an array of strings. I saved a byte by taking opportunity of the new input clarificatinos.






                                              share|improve this answer











                                              $endgroup$

















                                                2












                                                $begingroup$


                                                Stax, 11 10 bytes



                                                ìát'óJ♣á◄·


                                                Run and debug it



                                                This program uses 0-based indexing and takes input as an array of strings. I saved a byte by taking opportunity of the new input clarificatinos.






                                                share|improve this answer











                                                $endgroup$















                                                  2












                                                  2








                                                  2





                                                  $begingroup$


                                                  Stax, 11 10 bytes



                                                  ìát'óJ♣á◄·


                                                  Run and debug it



                                                  This program uses 0-based indexing and takes input as an array of strings. I saved a byte by taking opportunity of the new input clarificatinos.






                                                  share|improve this answer











                                                  $endgroup$




                                                  Stax, 11 10 bytes



                                                  ìát'óJ♣á◄·


                                                  Run and debug it



                                                  This program uses 0-based indexing and takes input as an array of strings. I saved a byte by taking opportunity of the new input clarificatinos.







                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited May 28 at 20:07

























                                                  answered May 28 at 17:17









                                                  recursiverecursive

                                                  6,2191324




                                                  6,2191324





















                                                      2












                                                      $begingroup$


                                                      Perl 5 -pa, 80 bytes





                                                      map$d$_.substr$_,0,$b%y///c,''=$b++,@F;$+=$d$_==$r++for sort$a-$bkeys%d} 











                                                      2












                                                      $begingroup$


                                                      Perl 5 -pa, 80 bytes





                                                      map$d$_.substr$_,0,$b%y///c,''=$b++,@F;$+=$d$_==$r++for sort$a-$bkeys%dimprove this answer









                                                      $endgroup$
















                                                        $endgroup$




                                                        Perl 5 -pa, 80 bytes





                                                        map$d$_.substr$_,0,$b%y///c,''=$b++,@F;$+=$d$_==$r++for sort$a-$bkeys%d-c


                                                        Try it online!




                                                        JavaScript (Node.js), 113 111 bytes





                                                        a=>[...b=a.map((x,i)=>"".padEnd(x+i,x).substr(i,`$x`.length))].sort((p,q)=>p-q).map((x,i)=>x-b[i]. Also, you can change your first loop to for((i=0;++i<=$#;));.
                                                        $endgroup$
                                                        – Kevin Cruijssen
                                                        May 29 at 13:21










                                                      • $begingroup$
                                                        @KevinCruijssen -- usually I have found Bash and friends needs that space to parse the command line. On this occasion you are correct it may be removed. Nice idea to re-base and pre-increment. 202 bytes.
                                                        $endgroup$
                                                        – PJF
                                                        May 29 at 13:29
















                                                      • 1












                                                        $begingroup$


                                                        Bash, 204 201 bytes



                                                        The only interesting thing here (possibly) is the use of eval. The algorithm is also clunky in that it creates a sorted list then reads it in order to determine changed index/indices.



                                                        1-based solution. My thanks to @RobinRyder for the helpful rotation algorithm.



                                                        for((i=1;i<$#+1;i++));do eval s=$$i;for((j=0;j<i;j++));do eval s=$s$$i;done;eval n=$s:$i:$#$i;echo $n $i;done|sort -nk1,1| i=1;c=0;while read d j;do((i==j))&&((c++));((i++));done;echo $c; 


                                                        Try it online!



                                                        Revised code following Kevin's comments;
                                                        Try it online!






                                                        share|improve this answer











                                                        $endgroup$












                                                        • $begingroup$
                                                          I don't know Bash too well, but I think you can remove the last space between ;}. Also, you can change your first loop to for((i=0;++i<=$#;));.
                                                          $endgroup$
                                                          – Kevin Cruijssen
                                                          May 29 at 13:21










                                                        • $begingroup$
                                                          @KevinCruijssen -- usually I have found Bash and friends needs that space to parse the command line. On this occasion you are correct it may be removed. Nice idea to re-base and pre-increment. 202 bytes.
                                                          $endgroup$
                                                          – PJF
                                                          May 29 at 13:29













                                                        1












                                                        1








                                                        1





                                                        $begingroup$


                                                        Bash, 204 201 bytes



                                                        The only interesting thing here (possibly) is the use of eval. The algorithm is also clunky in that it creates a sorted list then reads it in order to determine changed index/indices.



                                                        1-based solution. My thanks to @RobinRyder for the helpful rotation algorithm.



                                                        for((i=1;i<$#+1;i++));do eval s=$$i;for((j=0;j<i;j++));do eval s=$s$$i;done;eval n=$s:$i:$#$i;echo $n $i;done|sort -nk1,1| i=1;c=0;while read d j;do((i==j))&&((c++));((i++));done;echo $c; 


                                                        Try it online!



                                                        Revised code following Kevin's comments;
                                                        Try it online!






                                                        share|improve this answer











                                                        $endgroup$




                                                        Bash, 204 201 bytes



                                                        The only interesting thing here (possibly) is the use of eval. The algorithm is also clunky in that it creates a sorted list then reads it in order to determine changed index/indices.



                                                        1-based solution. My thanks to @RobinRyder for the helpful rotation algorithm.



                                                        for((i=1;i<$#+1;i++));do eval s=$$i;for((j=0;j<i;j++));do eval s=$s$$i;done;eval n=$s:$i:$#$i;echo $n $i;done|sort -nk1,1| i=1;c=0;while read d j;do((i==j))&&((c++));((i++));done;echo $c; 


                                                        Try it online!



                                                        Revised code following Kevin's comments;
                                                        Try it online!







                                                        share|improve this answer














                                                        share|improve this answer



                                                        share|improve this answer








                                                        edited May 29 at 13:34

























                                                        answered May 29 at 13:17









                                                        PJFPJF

                                                        713




                                                        713











                                                        • $begingroup$
                                                          I don't know Bash too well, but I think you can remove the last space between ;}. Also, you can change your first loop to for((i=0;++i<=$#;));.
                                                          $endgroup$
                                                          – Kevin Cruijssen
                                                          May 29 at 13:21










                                                        • $begingroup$
                                                          @KevinCruijssen -- usually I have found Bash and friends needs that space to parse the command line. On this occasion you are correct it may be removed. Nice idea to re-base and pre-increment. 202 bytes.
                                                          $endgroup$
                                                          – PJF
                                                          May 29 at 13:29
















                                                        • $begingroup$
                                                          I don't know Bash too well, but I think you can remove the last space between ;}. Also, you can change your first loop to for((i=0;++i<=$#;));.
                                                          $endgroup$
                                                          – Kevin Cruijssen
                                                          May 29 at 13:21










                                                        • $begingroup$
                                                          @KevinCruijssen -- usually I have found Bash and friends needs that space to parse the command line. On this occasion you are correct it may be removed. Nice idea to re-base and pre-increment. 202 bytes.
                                                          $endgroup$
                                                          – PJF
                                                          May 29 at 13:29















                                                        $begingroup$
                                                        I don't know Bash too well, but I think you can remove the last space between ;}. Also, you can change your first loop to for((i=0;++i<=$#;));.
                                                        $endgroup$
                                                        – Kevin Cruijssen
                                                        May 29 at 13:21




                                                        $begingroup$
                                                        I don't know Bash too well, but I think you can remove the last space between ;}. Also, you can change your first loop to for((i=0;++i<=$#;));.
                                                        $endgroup$
                                                        – Kevin Cruijssen
                                                        May 29 at 13:21












                                                        $begingroup$
                                                        @KevinCruijssen -- usually I have found Bash and friends needs that space to parse the command line. On this occasion you are correct it may be removed. Nice idea to re-base and pre-increment. 202 bytes.
                                                        $endgroup$
                                                        – PJF
                                                        May 29 at 13:29




                                                        $begingroup$
                                                        @KevinCruijssen -- usually I have found Bash and friends needs that space to parse the command line. On this occasion you are correct it may be removed. Nice idea to re-base and pre-increment. 202 bytes.
                                                        $endgroup$
                                                        – PJF
                                                        May 29 at 13:29











                                                        1












                                                        $begingroup$


                                                        Scala, 200 160 bytes





                                                        def f(a:Seq[String])=
                                                        a.zipWithIndex
                                                        .map(x=>val r=x._2%x._1.size;x._1.drop(r)+x._1.take(r)->x._2)
                                                        .sortBy(_._1.toInt)
                                                        .zipWithIndex
                                                        .filter(x=>x._1._2==x._2)
                                                        .size


                                                        Try it online!



                                                        0-indexed. 160 chars after removing indentation and newlines. This prints 6:



                                                        println( f(Seq("8","49","73","102","259","762","2782","3383","9217","37846","89487","7471788")) )





                                                        share|improve this answer











                                                        $endgroup$

















                                                          1












                                                          $begingroup$


                                                          Scala, 200 160 bytes





                                                          def f(a:Seq[String])=
                                                          a.zipWithIndex
                                                          .map(x=>val r=x._2%x._1.size;x._1.drop(r)+x._1.take(r)->x._2)
                                                          .sortBy(_._1.toInt)
                                                          .zipWithIndex
                                                          .filter(x=>x._1._2==x._2)
                                                          .size


                                                          Try it online!



                                                          0-indexed. 160 chars after removing indentation and newlines. This prints 6:



                                                          println( f(Seq("8","49","73","102","259","762","2782","3383","9217","37846","89487","7471788")) )





                                                          share|improve this answer











                                                          $endgroup$















                                                            1












                                                            1








                                                            1





                                                            $begingroup$


                                                            Scala, 200 160 bytes





                                                            def f(a:Seq[String])=
                                                            a.zipWithIndex
                                                            .map(x=>val r=x._2%x._1.size;x._1.drop(r)+x._1.take(r)->x._2)
                                                            .sortBy(_._1.toInt)
                                                            .zipWithIndex
                                                            .filter(x=>x._1._2==x._2)
                                                            .size


                                                            Try it online!



                                                            0-indexed. 160 chars after removing indentation and newlines. This prints 6:



                                                            println( f(Seq("8","49","73","102","259","762","2782","3383","9217","37846","89487","7471788")) )





                                                            share|improve this answer











                                                            $endgroup$




                                                            Scala, 200 160 bytes





                                                            def f(a:Seq[String])=
                                                            a.zipWithIndex
                                                            .map(x=>val r=x._2%x._1.size;x._1.drop(r)+x._1.take(r)->x._2)
                                                            .sortBy(_._1.toInt)
                                                            .zipWithIndex
                                                            .filter(x=>x._1._2==x._2)
                                                            .size


                                                            Try it online!



                                                            0-indexed. 160 chars after removing indentation and newlines. This prints 6:



                                                            println( f(Seq("8","49","73","102","259","762","2782","3383","9217","37846","89487","7471788")) )






                                                            share|improve this answer














                                                            share|improve this answer



                                                            share|improve this answer








                                                            edited May 30 at 12:23

























                                                            answered May 28 at 23:28









                                                            Kjetil S.Kjetil S.

                                                            67725




                                                            67725



























                                                                draft saved

                                                                draft discarded
















































                                                                If this is an answer to a challenge…



                                                                • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                                • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                  Explanations of your answer make it more interesting to read and are very much encouraged.


                                                                • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.


                                                                More generally…



                                                                • …Please make sure to answer the question and provide sufficient detail.


                                                                • …Avoid asking for help, clarification or responding to other answers (use comments instead).




                                                                draft saved


                                                                draft discarded














                                                                StackExchange.ready(
                                                                function ()
                                                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f186169%2frotated-position-of-integers%23new-answer', 'question_page');

                                                                );

                                                                Post as a guest















                                                                Required, but never shown





















































                                                                Required, but never shown














                                                                Required, but never shown












                                                                Required, but never shown







                                                                Required, but never shown

































                                                                Required, but never shown














                                                                Required, but never shown












                                                                Required, but never shown







                                                                Required, but never shown







                                                                Popular posts from this blog

                                                                Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                                                                Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                                                                Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form