Skip to main content
Notice removed Reward existing answer by naffetS
Bounty Ended with south's answer chosen by naffetS
Tweeted twitter.com/StackCodeGolf/status/1590177355041230848
Notice added Reward existing answer by naffetS
Bounty Started worth 100 reputation by naffetS

Given a string of digits or an integer as input, you will have to indexize it.

This is how you modify the input. We will use 30043376111 as an example:

First, find the sum of the indices of each occurrence of the respective digits:

0: 1 + 2 = 3
1: 8 + 9 + 10 = 27
3: 0 + 4 + 5 = 9
4: 3
6: 7
7: 6

Then, construct a new integer or string where the digits above go in the order of the sums of their indices. In the case that multiple digits yield the same sum, the smaller digit comes before the larger one:

047631

Finally, remove any leading zeroes, and return or print the result:

47631

You must write a program or function which returns or prints the input indexized.

This is , so shortest code in bytes wins!

More test cases can be added if requested.

Given a string of digits or an integer as input, you will have to indexize it.

This is how you modify the input. We will use 30043376111 as an example:

First, find sum the indices of each occurrence of the respective digits:

0: 1 + 2 = 3
1: 8 + 9 + 10 = 27
3: 0 + 4 + 5 = 9
4: 3
6: 7
7: 6

Then, construct a new integer or string where the digits above go in the order of the sums of their indices. In the case that multiple digits yield the same sum, the smaller digit comes before the larger one:

047631

Finally, remove any leading zeroes, and return or print the result:

47631

You must write a program or function which returns or prints the input indexized.

This is , so shortest code in bytes wins!

More test cases can be added if requested.

Given a string of digits or an integer as input, you will have to indexize it.

This is how you modify the input. We will use 30043376111 as an example:

First, find the sum of the indices of each occurrence of the respective digits:

0: 1 + 2 = 3
1: 8 + 9 + 10 = 27
3: 0 + 4 + 5 = 9
4: 3
6: 7
7: 6

Then, construct a new integer or string where the digits above go in the order of the sums of their indices. In the case that multiple digits yield the same sum, the smaller digit comes before the larger one:

047631

Finally, remove any leading zeroes, and return or print the result:

47631

You must write a program or function which returns or prints the input indexized.

This is , so shortest code in bytes wins!

More test cases can be added if requested.

Source Link
Daniel
  • 6.7k
  • 1
  • 23
  • 58

Indexize a number

Given a string of digits or an integer as input, you will have to indexize it.

This is how you modify the input. We will use 30043376111 as an example:

First, find sum the indices of each occurrence of the respective digits:

0: 1 + 2 = 3
1: 8 + 9 + 10 = 27
3: 0 + 4 + 5 = 9
4: 3
6: 7
7: 6

Then, construct a new integer or string where the digits above go in the order of the sums of their indices. In the case that multiple digits yield the same sum, the smaller digit comes before the larger one:

047631

Finally, remove any leading zeroes, and return or print the result:

47631

You must write a program or function which returns or prints the input indexized.

This is , so shortest code in bytes wins!

More test cases can be added if requested.