Sobes.tech
Junior — Senior

Length of the free part of the main segment

livecode

Task condition

Given a main segment [start, finish] and an arbitrary number of auxiliary segments. It is required to calculate the total length of the part of the main segment where none of the auxiliary segments overlap.

# start = 15, finish = 165
# seg1 [37, 68]
# seg2 [52, 74]
# seg3 [118, 146]
# seg4 [35, 44]
# seg5 [37, 65]
# seg6 [46, 74]

# Answer: 83
Length of the free part of the main segment - Live… - sobes.tech