avatar Bite 287. Sum indices

Write a function that accepts a list of strings and returns the total of the indices of the items.   

Example 1: ['a', 'b', 'c'] => 0 + 1 + 2 = 3

The indices for duplicate items should be accumulated in the total as they appear.  

Example 2:  ['a', 'b', 'b', 'c'] => 0 + 1 + (1+2) + 3 = 7

Example 3: ['a', 'b', 'b', 'c', 'a', 'b', 'a'] => 0 + 1 + (1+2) + 3 + (0+4) + (1+2+5) + (0+4+6) = 29

 

Login and get coding
go back Intermediate level
Bitecoin 3X

60 out of 62 users completed this Bite.
Will you be the 61st person to crack this Bite?
Resolution time: ~38 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 3.0 on a 1-10 difficulty scale.
» You can do it! 😌

Focus on this Bite hiding sidebars, turn on Focus Mode.

Ask for Help