Exercise 8: Islands of 1s (Distance Solution)