1
I need to remove elements from a list whose item reference for removal is in another list:
# Esta lista foi gerada por combinação
lista original=[
(182361, 243148, 360624, 364188),
(182361, 243148, 360624, 547083),
(182361, 243148, 360624, 486296),
(182361, 243148, 360624, 368820),
(182361, 243148, 360624, 365256),
(182361, 243148, 364188, 547083),
(182361, 243148, 364188, 486296),
(182361, 243148, 364188, 368820),
(182361, 243148, 364188, 365256),
(182361, 243148, 547083, 486296),
(182361, 243148, 547083, 368820),
(182361, 243148, 547083, 365256),
(182361, 243148, 486296, 368820),
(182361, 243148, 486296, 365256),
(182361, 243148, 368820, 365256),
(182361, 360624, 364188, 547083),
(182361, 360624, 364188, 486296),
(182361, 360624, 364188, 368820),
(182361, 360624, 364188, 365256),
(182361, 360624, 547083, 486296),
(182361, 360624, 547083, 368820),
(182361, 360624, 547083, 365256),
(182361, 360624, 486296, 368820),
(182361, 360624, 486296, 365256),
(182361, 360624, 368820, 365256),
(182361, 364188, 547083, 486296),
(182361, 364188, 547083, 368820),
(182361, 364188, 547083, 365256),
(182361, 364188, 486296, 368820),
(182361, 364188, 486296, 365256),
(182361, 364188, 368820, 365256),
(182361, 547083, 486296, 368820),
(182361, 547083, 486296, 365256),
(182361, 547083, 368820, 365256),
(182361, 486296, 368820, 365256),
(243148, 360624, 364188, 547083),
(243148, 360624, 364188, 486296),
(243148, 360624, 364188, 368820),
(243148, 360624, 364188, 365256),
(243148, 360624, 547083, 486296),
(243148, 360624, 547083, 368820),
(243148, 360624, 547083, 365256),
(243148, 360624, 486296, 368820),
(243148, 360624, 486296, 365256),
(243148, 360624, 368820, 365256),
(243148, 364188, 547083, 486296),
(243148, 364188, 547083, 368820),
(243148, 364188, 547083, 365256),
(243148, 364188, 486296, 368820),
(243148, 364188, 486296, 365256),
(243148, 364188, 368820, 365256),
(243148, 547083, 486296, 368820),
(243148, 547083, 486296, 365256),
(243148, 547083, 368820, 365256),
(243148, 486296, 368820, 365256),
(360624, 364188, 547083, 486296),
(360624, 364188, 547083, 368820),
(360624, 364188, 547083, 365256),
(360624, 364188, 486296, 368820),
(360624, 364188, 486296, 365256),
(360624, 364188, 368820, 365256),
(360624, 547083, 486296, 368820),
(360624, 547083, 486296, 365256),
(360624, 547083, 368820, 365256),
(360624, 486296, 368820, 365256),
(364188, 547083, 486296, 368820),
(364188, 547083, 486296, 365256),
(364188, 547083, 368820, 365256),
(364188, 486296, 368820, 365256),
(547083, 486296, 368820, 365256)
]
# pares de elementos que preciso remover da lista original, ou seja,
# se na lista original contiver qualquer desses pares que eles sejam
# substituidos por zero.
lista de remoção=[
[182361, 547083],
[243148, 486296],
[360624, 368820],
[364188, 365256]
]
I need the output to be a list composed of elements in groups of 4 (as in the original list), whose elements do not contain elements of the removal pair reference list. Where there is the presence of a pair anywhere on the removal list, let that element be replaced by zero.
I’d like to keep it that way:
lista final =[ (182361, 243148, 360624, 364188), (0, 243148, 360624, 0), (182361, 0, 360624, 0), (182361, 243148, 0, 0), (182361, 243148, 360624, 365256), (0, 243148, 364188, 0), (182361, 0, 364188, 0),
(182361, 243148, 364188, 368820), (182361, 243148, 0,0),
(0, 0, 0, 0), (0, 243148, 0, 368820), (0, 243148, 0, 365256),
(182361, 0,0, 368820), (182361, 0,0, 365256), (182361, 243148, 368820, 365256), (0, 360624, 364188, 0), (182361, 360624, 364188, 486296),
(182361, 0, 364188, 0), (182361, 360624, 0,0), (0, 360624, 0, 486296),
(0, 0, 0, 0), (0, 360624, 0, 365256), (182361, 0, 486296, 0),
(182361, 360624, 486296, 365256), (182361, 0, 0, 365256),
(0, 364188, 0, 486296), (0, 364188, 0, 368820), (0, 0, 0, 0),
(182361, 364188, 486296, 368820), (182361, 0, 486296, 0),
(182361, 0, 368820, 0), (0,0, 486296, 368820), (0,0, 486296, 365256),
(0,0, 368820, 365256), (182361, 486296, 368820, 365256), (243148, 360624, 364188, 547083), (0, 360624, 364188, 0), (243148, 0, 364188, 0),
(243148, 360624, 0,0), (0, 360624, 547083, 0), (243148, 0, 547083, 0),
(243148, 360624, 547083, 365256), (0, 0, 0, 0), (0, 360624, 0, 365256),
(243148, 0, 0, 365256), (0, 364188, 547083, 0), (243148, 364188, 547083, 368820), (243148, 0, 547083, 0), (0, 364188, 0, 368820), (0, 0, 0, 0),
(243148, 0, 368820, 0), (0, 547083, 0, 368820), (0, 547083, 0, 365256),
(243148, 547083, 368820, 365256), (0,0, 368820, 365256), (360624, 364188, 547083, 486296), (0, 364188, 547083, 0),(360624, 0, 547083, 0),
(0, 364188, 486296, 0), (360624, 0, 486296, 365256), (0, 364188, 0, 365256),
(0, 547083, 486296, 0), (360624, 547083, 486296, 365256), (0, 547083, 0, 365256), (0, 486296, 0, 365256), (364188, 547083, 486296, 368820),
(0, 547083, 486296, 0), (0, 547083, 368820, 0), (0, 486296, 368820, 0),
(547083, 486296, 368820, 365256)]
This would be the final list after the exclusion of pairs of elements from the exclusion list.
To facilitate understanding, you could edit your answer and add an example of a pair that should be removed and show how you would like it to look after the algorithm runs.
– fernandosavio
See if this helps you with anything: https://answall.com/q/190078/5878
– Woss
Thanks, I’ll take a closer look today..
– Jurandir Portela