The way I do it, for a 5-card hand, is to ensure that there are no duplicates, find the minimum and maximum values, and see if there is a difference of 4 between max and min. If it doesn't produce a straight, and min is 1, I reassign the A to its high value, set it as max, find the new min, and do it again.