Find Evenly Spaced Trees

Find Evenly Spaced Trees

You have to find evenly spaced trees in a grove.

You are given the position of the trees (a set of integers) as input values. You have to find and return the maximum number of the evenly spaced trees. If the answer is less than or equal to 2, return None.

Examples:

assert find_evenly_spaced_trees({0, 2, 4, 7}) == 3
assert find_evenly_spaced_trees({0, 2, 3, 5, 9}) == None
assert find_evenly_spaced_trees({0, 3, 6, 8, 11, 14, 17}) == 4
assert find_evenly_spaced_trees({0, 4, 6, 8, 12, 16, 18}) == 5

example_01 example_02
example_03 example_04

Input: The position of the trees (a set of integers).

Output: The maximum number of the evenly spaced trees (An integer or None).

Precondition:

  • 3 ≤ number of trees ≤ 80
  • 0 ≤ position ≤ 99