title: Get longest streak from list
body: <p>In Java I am writing code to analyze the longest streak of a color from the output of another program. The program can output three colors: Red, green, and black. Green counts as whichever color is being checked (e.g. RRGR = Red x4). The current code I am using is:</p>
  
  <pre><code>private static boolean isStreak(int color, int... lst){
      for(int i:lst){
          if(i!=color){//Whichever color is being checked
              if(i!=-12280508)//Green counts as whichever color is being checked
                  return false;
          }
      }
      return true;
  }
  </code></pre>
  
  <p>While this code works, I need several if/else blocks to effectively catch all the streaks from 1-7, such as:</p>
  
  <pre><code>if(isStreak(Color.RED.value,last[lSize-1],last[lSize-2],last[lSize-3],last[lSize-4],last[lSize-5],last[lSize-6],last[lSize-7])){
      if(!lb.was7){
          log("red 7x");
          doBet(bet*64);
          betBlack();
          lb.was7=true;
      }
  }else if(isStreak(Color.BLACK.value,last[lSize-1],last[lSize-2],last[lSize-3],last[lSize-4],last[lSize-5],last[lSize-6],last[lSize-7])){
      if(!lb.was7){
          log("red 7x");
          doBet(bet*64);
          betRed();
          lb.was7=true;
      }
  }else if(isStreak(Color.RED.value,last[lSize-1],last[lSize-2],last[lSize-3],last[lSize-4],last[lSize-5],last[lSize-6])){
      log("red 6x");
      doBet(bet*32);
      betBlack();
  }else if(isStreak(Color.BLACK.value,last[lSize-1],last[lSize-2],last[lSize-3],last[lSize-4],last[lSize-5],last[lSize-6])){
      log("black 6x");
      doBet(bet*32);
      betRed();
  }
  </code></pre>
  
  <p>and so on. I was wondering if there was a way to write some code that would take the arguments of a list like:</p>
  
  <pre><code>getStreak(int[] list)
  </code></pre>
  
  <p>and would return the length of the streak and the color of the streak. I have no idea where to go or where to start, so any help would be appreciated.</p>
  
  <p>Thanks in advance!</p>