Sum according with multiple lists

I need to do the follow operations:

first loop:
[1] green == bold number - [1] blue
[1] red == [1] pink + [1] green

second loop:
[2] green == [1] red - [2] blue
[2] red == [2] pink + [2] green

and so on. The bold number comes from another list and it is the start the sum. Any suggestion of how to do this?

logic

I have 0 clue what you want the output to be or how you want it laid out but this basic python will at least get you the green and red numbers:

greenredbluepink

Python:

bold = IN[0]
blues = IN[1]
pinks = IN[2]

greens = []
reds = []
g = bold - blues.pop(0)
greens.append(g)

for b, p in zip(blues, pinks):
	r = p + g
	g = r - b
	reds.append(r)
	greens.append(g)

OUT = [greens, reds]

Doing this by nodes would probably be really hard. I am sure you could do it as an Imperative function inside a codeblock but python is just easier for me.

2 Likes

Oh, sorry for not be clearly enough, but you read my mind. I wanted both the red and greens outputs. You script works very well.

Thank you for the help.

example