package org.lila.clockencoder;

public class LinearEstimator {
    // Input: Array of absolute clock times for a players move
    // Output: Encoded array of clock times.
    public static int[] encode(int[] src) {
       return encodeDecode(src, true);
    }

    public static int[] decode(int[] src) {
        return encodeDecode(src, false);
    }

    private static int[] encodeDecode(int[] src, boolean isEncoding) {
        int size = src.length;
        int[] dest = new int[size];
        dest[0] = src[0];
        dest[size - 1] = src[size - 1];

        int[] realValues = isEncoding ? src : dest;
        encodeHelper(src, dest, realValues, 0, size - 1);

        return dest;
    }

    private static void encodeHelper(int[] src, int[] dest, int[] realValues,
                                     int startIdx, int endIdx) {
        int l = endIdx - startIdx;
        if (l == 0) return;

        int midIdx = startIdx + l / 2;

        // It's important to save estimate in fixed precision to ensure
        // the encode and decode math behaves identically.
        int estimate = (realValues[startIdx] * (endIdx - midIdx) +
                        realValues[endIdx]   * (midIdx - startIdx)) / l;

        dest[midIdx] = estimate - src[midIdx];

        encodeHelper(src, dest, realValues, startIdx, midIdx);
        encodeHelper(src, dest, realValues, midIdx, endIdx);
    }
}
@@ -603,32 +603,39 @@
 : dest;%0A        
+return 
 encodeHelper(src
@@ -671,30 +671,8 @@
  1);
-%0A%0A        return dest;
 %0A   
@@ -698,12 +698,13 @@
 tic 
-void
+int%5B%5D
  enc
@@ -884,48 +884,13 @@
 turn
-;%0A%0A        int midIdx = startIdx + l / 2
+ dest
 ;%0A%0A 
@@ -1068,86 +1068,58 @@
 dx%5D 
-* (endIdx - midIdx) +%0A                        realValues%5BendIdx%5D   * (
++ realValues%5BendIdx%5D) %3E%3E%3E 1;%0A%0A        int 
 midIdx 
--
+=
  sta
@@ -1127,14 +1127,20 @@
 tIdx
-)) / l
+ + (l %3E%3E%3E 1)
 ;%0A%0A 
@@ -1249,32 +1249,39 @@
 idIdx);%0A        
+return 
 encodeHelper(src

Simplify LinearEstimator