How can I create an array of indexes of the most common value of an array (empty strings should be excluded). My array is always of size three, which should simplify the problem but I have yet to find a way to solve this. I'm using JavaScript (ES5), so no access to Set.
E.g. the following would all return an empty array (consider " " as an empty string):
[" ", " ", " "] => []
["a", " ", " "] => []
[" ", "b", " "] => []
[" ", " ", "c"] => []
["a", "b", " "] => []
[" ", "b", "c"] => []
["a", " ", "c"] => []
["a", "b", "c"] => []
and the following would return:
["a", "a", " "] => [0, 1]
["a", "a", "c"] => [0, 1]
[" ", "b", "b"] => [1, 2]
["a", "b", "b"] => [1, 2]
["c", " ", "c"] => [0, 2]
["c", "b", "c"] => [0, 2]
["c", "c", "c"] => [0, 1, 2]