#How to calculate overlap and union of two sets after inputing 4 values?

4 messages · Page 1 of 1 (latest)

thorn osprey
#

I'm trying to get a hang of for-loops and set logic but I can't seem to get my test cases correct

https://pastebin.com/D6vgTPfv

//Test case example:
[10 to 20] 11 values eg: 10,11,12,13,14, 15,16,17,18,19, 20
[15 to 20] 6 values eg: 15,16,17,18,19,20

Overlap ie: intersection; values present in A and B would: 6
Union ie: values present in A or B: 11

Percent overlap formula: (Overlap/Union) * 100
Percent overlap eg: (6/11) * 100 = 54.5%

Program would just be 4 inputs and spit out the final value so user input:
10
20
15
20

and the answer is supposed to be 54.5% but I'm getting 100% as an answer...

kindred coralBOT
#

Hey, @thorn osprey!
Please remember to /close this post once your question has been answered!

thorn osprey
#

I figured it out