APL Interview Question

Most difficult task I completed