// Path: src/main/java/pl/joegreen/sergeants/api/util/MapPatcher.java
// public class MapPatcher {
// 
//     public static int[] patch(int[] patch, int[] old) {
//         ArrayList<Integer> newArrayList = new ArrayList<>();
//         int patchIndex = 0;
//         while (patchIndex < patch.length) {
//             //matching
//             int matchingElements = patch[patchIndex++];
//             int startingIndex = newArrayList.size();
//             for (int oldIndex = startingIndex; oldIndex < startingIndex + matchingElements; ++oldIndex) {
//                 if (oldIndex < old.length) {
//                     newArrayList.add(old[oldIndex]);
//                 } else {
//                     newArrayList.add(0);
//                 }
//             }
// 
//             //mismatching
//             if (patchIndex < patch.length) {
//                 int misMatchingElements = patch[patchIndex++];
//                 while (misMatchingElements > 0) {
//                     newArrayList.add(patch[patchIndex++]);
//                     misMatchingElements--;
//                 }
//             }
//         }
//         return newArrayList.stream().mapToInt(i -> i).toArray();
//     }
// }


import org.junit.Assert;
import org.junit.Test;
import pl.joegreen.sergeants.api.util.MapPatcher;
package pl.joegreen.sergeants;


public class MapPatcherTest {

    @Test
    public void testExample1(){
        int[] old = new int[]{0,0};
        int[] patch = new int[]{1,1,3};
        int[] expectedNew = new int[]{0,3};
// Path: src/main/java/pl/joegreen/sergeants/api/util/MapPatcher.java
// public class MapPatcher {
// 
//     public static int[] patch(int[] patch, int[] old) {
//         ArrayList<Integer> newArrayList = new ArrayList<>();
//         int patchIndex = 0;
//         while (patchIndex < patch.length) {
//             //matching
//             int matchingElements = patch[patchIndex++];
//             int startingIndex = newArrayList.size();
//             for (int oldIndex = startingIndex; oldIndex < startingIndex + matchingElements; ++oldIndex) {
//                 if (oldIndex < old.length) {
//                     newArrayList.add(old[oldIndex]);
//                 } else {
//                     newArrayList.add(0);
//                 }
//             }
// 
//             //mismatching
//             if (patchIndex < patch.length) {
//                 int misMatchingElements = patch[patchIndex++];
//                 while (misMatchingElements > 0) {
//                     newArrayList.add(patch[patchIndex++]);
//                     misMatchingElements--;
//                 }
//             }
//         }
//         return newArrayList.stream().mapToInt(i -> i).toArray();
//     }
// }


// Path: src/test/java/pl/joegreen/sergeants/MapPatcherTest.java
import org.junit.Assert;
import org.junit.Test;
import pl.joegreen.sergeants.api.util.MapPatcher;

package pl.joegreen.sergeants;


public class MapPatcherTest {

    @Test
    public void testExample1(){
        int[] old = new int[]{0,0};
        int[] patch = new int[]{1,1,3};
        int[] expectedNew = new int[]{0,3};
        Assert.assertArrayEquals(expectedNew, MapPatcher.patch(patch, old));