All pastes #1403568 Raw Edit

in-order cards in a poker hand

public java v1 · immutable
#1403568 ·published 2009-04-26 19:07 UTC
rendered paste body
import java.util.*;public class foo{    public static void main(String args[])    {	List<Integer> hand = Arrays.asList(2, 5, 3, 6, 4, 2, 9);	Collections.sort(hand);		int inOrder = 0;	int idx = 0;	int prev = hand.get(0);	for (int i = 0; i < hand.size(); i++) {	    if ( hand.get(i) > prev ) {		inOrder++;	    } else {		idx = i;	    }	}	System.out.println("Hand: " + hand);	System.out.format("Max consecutive: %d at index %d\n", inOrder, idx);    }}