package codingbat.array2;

/*
 * Return the sum of the numbers in the array, 
 * except ignore sections of numbers starting with a 6 and extending to 
 * the next 7 (every 6 will be followed by at least one 7). 
 * Return 0 for no numbers. 
 * 
 * sum67({1, 2, 2}) = 5
 * sum67({1, 2, 2, 6, 99, 99, 7}) = 5
 * sum67({1, 1, 6, 7, 2}) = 4
 * 
 */

public class Sum67Test {

  public static void main(String[] args) {
    Sum67Test test = new Sum67Test();

    System.out.println(">" + test.sum67(new int[] {1, 2, 2}) + "<");
    System.out.println(">" + test.sum67(new int[] {1, 2, 2, 6, 99, 99, 7})
        + "<");
    System.out.println(">" + test.sum67(new int[] {1, 1, 6, 7, 2}) + "<");
  }

  public int sum67(int[] nums) {
    return 0;
  }

}

@@ -591,16 +591,31 @@
 99, 7%7D)%0A
+               
         
@@ -614,32 +614,32 @@
         + %22%3C%22);%0A
-
     System.out.p
@@ -743,21 +743,326 @@
     
-return 0
+int sum = 0;%0A    boolean ignore = false;%0A    %0A    for (int i = 0; i %3C nums.length; i++) %7B%0A      %0A      if (nums%5Bi%5D == 6) %7B%0A        ignore = true;%0A      %7D%0A      else if (i %3E 0 && nums%5Bi-1%5D == 7) %7B%0A        ignore = false;%0A      %7D%0A     %0A      if (!ignore) %7B%0A        sum += nums%5Bi%5D;%0A      %7D%0A %0A    %7D%0A    %0A    return sum
 ;%0A  %7D%0A%0A
+
 %7D
-%0A

complete task sum67