Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
math.gcd solution in Clear category for Evenly Spaced Trees by Olpag
from math import gcd
from functools import reduce
def evenly_spaced_trees(trees):
intervals = [x-y for x,y in zip(trees[1:], trees[:-1])]
gcd_intervals = reduce(gcd, intervals)
return sum(interval // gcd_intervals - 1 for interval in intervals)
Jan. 31, 2020
Comments: