There are two factors to consider when deciding how to handle the problem of a work sample: sample size and population characteristics. Sample size is determined by a formula based on the power of the sample or its ability to represent the population with a predictable margin of error.
The resulting complexity makes card type detection code difficult to write, read, and maintain. As an example of this complexity, consider this JavaScript regular expression used to detect Discover card numbers starting with 6011, 622126-622925, 644-649, and 65:
The first digit indicates the type of card. For example, digit 3 is American Express, number 4 is VISA and 5 is MasterCard. This is also one of the first lines of defense against fraud - if in the randomly generated card number the first figure does not match the type of card, it will signal that the card is a fake.