Avengers end game(not so easy math) one test case going wrong

I have tried the avengers end game problem on hackeblocks using the inclusion-exclusion principle. It is not able to pass the test case 0. Please tell me the mistake in my code
code:

Hey @gaganwalia212
Please explaine line 41-44

I mean logic behind it

union(a,b,c)=a+b+c-intersection(a,b)-intersection (a,c)-intersection(b,c)+intersection(a,b,c)
in this formula if we have odd terms then we are adding. If we have even terms then we are subtracting the no of elements
line 41-checks how may numbers we are considering for a given set
line 42-if the number is odd then we will add the total number of elements to our ans
line 44-if the number is even then we will subtract from our ans

I am following the inclusion-exclusion principle. Is there anything wrong in my understanding of concept?

Hey @gaganwalia212

So issue is u did < instead of <= in for loop comdition

Rest code and logic is good :slight_smile:

Thank You very much sir.

1 Like