Let c represents cat, d represents dog, t represents turtle.
The largest possible number of house to have all three c,d,t would be to maximize the overlap which happens when houses having turtle will be a subset, i.e all three animals are present in those houses which have tuetles.
Therefore, x = 1182.
To calculate y, the minimal number of houses to have all three animals would be to minimize the overlap.
We can find the minimal number of house by assuming there are only two types of houses; one which has 2 types of animals (any one of ct / cd / dt) and another type of house in which all animals are present and then form linear equation and solve it;
ct + dt + cd + all = 2017 ; (cd / dt / ct represents the house which have only two types of animals in their house and all represents the number of house which has all three types of animals) -eq 0
ct + dt + all = 1182 ( Number of houses with turtles) -eq 1
cd + ct + all = 1651 (# houses with cats) -eq 2
cd + dt + all = 1820 (#houses with dogs) -eq 3
Solving the above the linear equations;
subtracting eq 1 from eq 0;
cd = 835
subtracting eq 3 from eq 0;
ct = 197
And from eq 2;
835 + 197 + all = 1651
all = 619 , which is equal to y
Hence, x-y = 1182 – 619 = 563
**************************************************
Also refer to article shared by Srken
https://math.stackexchange.com/questions/2389581/venn-diagram-question-involving-maximum-and-minimum-values