Draft solution for 1078 ("Segments"). WA #2.