Matlab (121)(119)
This is a program that takes two lists throu stdin and prints the result to stdout. It is a strightfwd approcht and I tried to golf it as much as possible. K(a)
returns a function that calculates x -> F(a,x)
. Then the anonymous function @(x)abs(g(x)-h(x))
which corresponds to the function D
is applied to every possible integer of 0:max([a,b])
and the maximum of the results is displayed. (arrayfun
does the same as map
in other languages: it applies a function to every element of a array)
a=input('');b=input('');
K=@(a)@(x)sum(a<=x)/numel(a);
g=K(a);h=K(b);
disp(max(arrayfun(@(x)abs(g(x)-h(x)),0:max([a,b]))))