Solution:
For each f,g∈X, we define
d(f,g):=0≤i≤2016min(max(f(i),g(i)))−0≤i≤2016max(min(f(i),g(i)))
Thus we desire maxg∈Xd(f,g)=2015.
First, we count the number of functions f∈X such that
∃g:iminmax{f(i),g(i)}≥2015 and ∃g:iminmax{f(i),g(i)}=0.
That means for every value of i, either f(i)=0 (then we pick g(i)=2015) or f(i)≥2015 (then we pick g(i)=0). So there are A=32017 functions in this case.
Similarly, the number of functions such that
∃g:iminmax{f(i),g(i)}=2016 and ∃g:iminmax{f(i),g(i)}≤1
is also B=32017.
Finally, the number of functions such that
∃g:iminmax{f(i),g(i)}=2016 and ∃g:iminmax{f(i),g(i)}=0
is C=22017.
Now A+B−C counts the number of functions with maxg∈Xd(f,g)≥2015 and C counts the number of functions with maxg∈Xd(f,g)≥2016, so the answer is A+B−2C=2⋅(32017−22017).