I'm new to coding and python. I've taken an intro comp sci class but I still feel out of my depth when trying to understand most code so please forgive me if this question seems poorly placed.
I'm taking an algorithms class on Edx, which has an automatic grader. Starter code is provided for each problem and contains a section like the one below. This section is particularly difficult for me to understand.
I believe what will be fed into the function I write is a list that will look like this [1:2,4:6,7:10], but I'm not really sure.
I'm hoping someone could help me understand this code, so I can design a function around the data.
if __name__ == '__main__':
input = sys.stdin.read()
data = list(map(int, input.split()))
n = data[0]
m = data[1]
starts = data[2:2 * n + 2:2]
ends = data[3:2 * n + 2:2]
points = data[2 * n + 2:]
#use fast_count_segments
cnt = naive_count_segments(starts, ends, points)
for x in cnt:
print(x, end=' ')
Further, I don't really understand how to test this code on my own computer so that I can figure it out on my own. Any help would be much appreaciated. Thanks in advance.