@@ -0,0 +1,1298 @@
+package codingbat.warmup2;%0A%0A/*%0A * Given an array of ints, return true if it contains a 2, 7, 1 pattern --%0A * a value, followed by the value plus 5, followed by the value minus 1. %0A * Additionally the 271 counts even if the %221%22 differs by 2 or less from %0A * the correct value. %0A * %0A * has271(%7B1, 2, 7, 1%7D) = true%0A * has271(%7B1, 2, 8, 1%7D) = false%0A * has271(%7B2, 7, 1%7D) = true%0A * has271(%7B4, 5, 3, 8, 0%7D) = true%0A * has271(%7B2, 7, -1%7D) = true%0A */%0A%0Apublic class Has271Test %7B%0A%0A  public static void main(String%5B%5D args) %7B%0A%0A    Has271Test test = new Has271Test();%0A%0A    System.out.println(%22%3E%22 + test.has271(new int%5B%5D %7B1, 2, 7, 1%7D) + %22%3C%22);%0A    System.out.println(%22%3E%22 + test.has271(new int%5B%5D %7B1, 2, 8, 1%7D) + %22%3C%22);%0A    System.out.println(%22%3E%22 + test.has271(new int%5B%5D %7B2, 7, 1%7D) + %22%3C%22);%0A    System.out.println(%22%3E%22 + test.has271(new int%5B%5D %7B4, 5, 3, 8, 0%7D) + %22%3C%22);%0A    System.out.println(%22%3E%22 + test.has271(new int%5B%5D %7B2, 7, -1%7D) + %22%3C%22);%0A  %7D%0A%0A  public boolean has271(int%5B%5D nums) %7B%0A    boolean result = false;%0A%0A    if(nums.length %3C 3)%7B return result;%7D%0A    %0A    for(int i = 0; i%3Cnums.length-2;i++)%7B%0A      boolean diff5 = nums%5Bi+1%5D - nums%5Bi%5D == 5;%0A      boolean diff1 = nums%5Bi%5D - nums%5Bi+2%5D %3E= -1 && nums%5Bi%5D - nums%5Bi+2%5D %3C= 3;%0A    %0A      if(diff5 && diff1)%7B%0A        result = true;%0A      %7D%0A    %7D%0A    %0A    return result;%0A  %7D%0A%0A%7D%0A

add task has271