### Question:
InvertListNumber implements ListNumber { static int index(int[] coords, ListInt sizes, boolean[] invert) { int index = 0; for (int i = 0; i < coords.length; i++) { index *= sizes.getInt(i); if (!invert[i]) { index += coords[i]; } else { index += sizes.getInt(i) - coords[i] - 1; } } return index; }    }### Answer:
@Test public void index1() { ListInt sizes = new ArrayInt(15,3,2); int[] actualCoords = new int[] {10,0,1}; boolean[] invert = new boolean[] {false, false, false}; int index = (10 * 3 + 0) * 2 + 1; assertThat(InvertListNumber.index(actualCoords, sizes, invert), equalTo(index)); }
@Test public void index2() { ListInt sizes = new ArrayInt(15,3,2); int[] actualCoords = new int[] {10,0,1}; boolean[] invert = new boolean[] {false, true, false}; int index = (10 * 3 + 2) * 2 + 1; assertThat(InvertListNumber.index(actualCoords, sizes, invert), equalTo(index)); }
@Test public void index3() { ListInt sizes = new ArrayInt(15,3,2); int[] actualCoords = new int[] {10,0,1}; boolean[] invert = new boolean[] {true, true, false}; int index = (4 * 3 + 2) * 2 + 1; assertThat(InvertListNumber.index(actualCoords, sizes, invert), equalTo(index)); }