Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Map Reduce solution in Clear category for [old] Weak Point by juacompe
"use strict";
function weakPoint(durabilityMap) {
let sumRows = durabilityMap.map(sum)
let sumCols = cols(durabilityMap).map(sum)
return [minIndex(sumRows), minIndex(sumCols)]
}
let cols = (rows) => {
let cols = []
for(let c in rows)
cols.push(rows.map(r=>r[c]))
return cols
}
let minIndex = (a) => a.indexOf(min(a))
let min = (a) => a.reduce(less)
let sum = (a) => a.reduce(add)
let add = (x,y) => x+y
let less = (x,y) => x
June 1, 2019
Comments: