Matrix ComSec interview question

find shortest value using loop.