6 kyu

Arrays of Lists of Sets

223 of 392KenKamau

Description:

In this Kata, you will be given a list of strings and your task will be to find the strings that have the same characters and return the sum of their positions as follows:

solve(["abc","abbc", "ab", "xyz", "xy", "zzyx"]) = [1,8]
-- we see that the elements at indices 0 and 1 have the same characters, as do those at indices 3 and 5.
-- we therefore return [1,8] because [0+1,3+5] = [1,8]. This result is sorted. 
-- ignore those that don't have at least one matching partner, such as "ab" and "xy".

Another example...
solve(["wkskkkkkk","fokoo","wkskk","uizzzz","fokooff","wkskkkk","uizzzzzzz"]),[5,7,9]);
--The element at index 0 is similar to those at indices 2 and 5; so 0 + 2 + 5 = 7.
--The element at index 1 is similar to that at index 4; so 1 + 4 = 5. 
--The element at index 3 is similar to that at index 6; so 3 + 6 = 9.
--The result must be sorted. We get [5,7,9].

More examples in the test cases.

Good luck!

Strings
Arrays
Algorithms

Stats:

CreatedDec 7, 2017
PublishedDec 7, 2017
Warriors Trained816
Total Skips8
Total Code Submissions1889
Total Times Completed392
Python Completions223
JavaScript Completions130
Ruby Completions42
Haskell Completions25
Total Stars21
% of votes with a positive feedback rating94% of 133
Total "Very Satisfied" Votes117
Total "Somewhat Satisfied" Votes15
Total "Not Satisfied" Votes1
Total Rank Assessments6
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • KenKamau Avatar
  • raulbc777 Avatar
  • solitude Avatar
  • saudiGuy Avatar
Ad