одну строчку решил =)
console.table(
[[[0 ], [0 ]],
[[1 ], [1 ]],
[[0,0,0,0,0], [0,0,0,0,0]],
[[1,0,0,0,0], [1,1,1,1,1]],
[[0,1,0,0,0], [0,1,1,1,1]],
[[1,0,2,0,0], [1,1,2,2,2]],
[[0,1,0,0,2], [0,1,1,1,2]],
[[0,0,0,1,2], [0,0,0,1,2]],
[[1,0,0,1,2], [1,1,1,1,2]],
[[0,1,0,1,2], [0,1,1,1,2]]]
.map(([source, target])=>[
source.join(','),
source.reduce((sum,x,i)=> (sum.push(i==0||x!=0?x:sum[i-1]),sum),[]).join(','),
target.join(',')
]).map(([source, source_transformed, target])=>({
"source": source,
"source_transformed": source_transformed,
"target": target,
"s->t" : source_transformed===target
})))
select arrayMap(i-> arrayFilter(y -> y != 0, arraySlice(x,1,i+1))[-1] , range(length(x))) from (select [0,1,0,2,0,0] x) но вообще это бред.
Обсуждают сегодня