Generating index numbers of inner branches in a symmetric network in Python
Question:
Answers:
I found a solution to solve this problem but I think is not the smartest way however it works ! I have admitted the network is a square, tell me if I was wrong.
I calculate all boundaries one by one then I remove the set of boundaries in the set of branches of the network.
# size of a side of the network
N = 3
top = [i for i in range(N)]
left = [N + i * (2 * N + 1) for i in range(N)]
right = [2 * N + i * (2 * N + 1) for i in range(N)]
bottom = [i for i in range(right[-1] + 1, right[-1] + 1 + N)]
total = set(i for i in range(bottom[-1] + 1))
outer = {*top, *left, *right, *bottom}
result = total - outer
print(result)
I found a solution to solve this problem but I think is not the smartest way however it works ! I have admitted the network is a square, tell me if I was wrong.
I calculate all boundaries one by one then I remove the set of boundaries in the set of branches of the network.
# size of a side of the network
N = 3
top = [i for i in range(N)]
left = [N + i * (2 * N + 1) for i in range(N)]
right = [2 * N + i * (2 * N + 1) for i in range(N)]
bottom = [i for i in range(right[-1] + 1, right[-1] + 1 + N)]
total = set(i for i in range(bottom[-1] + 1))
outer = {*top, *left, *right, *bottom}
result = total - outer
print(result)