[algorithms][is_valid] remove trailing space
[test][is_valid] add a few more test cases
[algorithms][is_valid] move implementation of number_of_distinct_points
in separate file; re-design implementation of is_valid for linestrings;
[algorithms][is_valid] make implementation of number_of_distinct_points
more generic: number_of_distinct_values for ranges that also takes an
additional template parameter to indicate how many distinct values
to search for