Two Lines Only Solution

```javascript []
const operations = (a, i) => a.reduce((s, v, j) => s + (v === '1' ? Math.abs(i - j) : 0), 0);

const minOperations = (boxes) => boxes.split('').map((_, i, a) => operations(a, i));

```
['JavaScript']