package com.mycompany.codekata.kata02;

/**
 * Kata 2 from http://codekata.com/,
 *
 */
public class Day2 {

  /**
   * Binary search for value in array. Recursive version.
   *
   * @param val value to search for
   * @param arr array to search in
   * @return position of val in arr or -1 if not found
   */
  public static int chop(int val, int[] arr, int start, int length) {
    int cut;

    if (length == 1) {
      return arr[start] == val ? start : -1;
    }

    cut = length / 2;

    if (arr[start + cut] > val) {
      return chop(val, arr, start, cut);
    } else {
      return chop(val, arr, start + cut, cut);
    }
  }

  public static int chop(int val, int[] arr) {
    return chop(val, arr, 0, arr.length);

  }
}

@@ -387,16 +387,68 @@
 t cut;%0A%0A
+    if (arr.length == 0)  %7B%0A      return -1;%0A    %7D%0A%0A
     if (
@@ -458,24 +458,24 @@
 gth == 1) %7B%0A
-
       return
@@ -566,16 +566,27 @@
 ut%5D 
-%3E
+%3C=
  val) %7B
+  // right
 %0A   
@@ -615,17 +615,32 @@
 r, start
-,
+ + cut, length -
  cut);%0A 
@@ -650,16 +650,47 @@
 %7D else %7B
+                        // left
 %0A      r
@@ -715,22 +715,16 @@
 r, start
- + cut
 , cut);%0A

Fix day 2 implementation