Post History
JavaScript (Node.js), 68 bytes f=(a)=>a.map((x)=>[...x.entries()].filter((e)=>e[1]).map((e)=>e[0])) Run the function f on your input, e.g. f([[1,0,1],[1,0,1],[0,1,0]]). The output ...
Answer
#1: Initial revision
## JavaScript (Node.js), 68 bytes ``` f=(a)=>a.map((x)=>[...x.entries()].filter((e)=>e[1]).map((e)=>e[0])) ``` Run the function f on your input, e.g. `f([[1,0,1],[1,0,1],[0,1,0]])`. The output looks like this: ``` [[0, 2], [0, 2], [1]] ``` with one subarray for each input subarray. --- Explanation: ``` f=(a)=> // creates a function to run the input on a.map((x)=> // for each outer array: [...x.entries()] // creates things like this: [index, value] .filter((e)=>e[1]) // keep ones where the value acts like true .map((e)=>e[0]) // return the indices for each one )