Source ¶
~cpp def jolly(values): return sum(i-e for i,e in zip(range(1,len(values)+1), sorted((abs(values[i]-values[i+1]) for i in range(len(values)-1))))) == 0 for e in [[1,4,2,3],[1,4,2,-1,6]]: print jolly(e)
~cpp def jolly(values): return sum(i-e for i,e in zip(range(1,len(values)+1), sorted((abs(values[i]-values[i+1]) for i in range(len(values)-1))))) == 0 for e in [[1,4,2,3],[1,4,2,-1,6]]: print jolly(e)