in reply to RFC: Algorithm::CouponCode

Very cool and most impressive.

I am currently working on a project that will involve typing coupon codes into web forms using a mobile phone based browser, so the user will be able to type numbers much more easily than mixed numbers and letters.

Could we have an extension or flag to your module for numeric only CouponCodes. (But still with the JavaScript based validation).

Replies are listed 'Best First'.
Re^2: RFC: Algorithm::CouponCode
by grantm (Parson) on Apr 07, 2011 at 22:06 UTC

    I take your point about the ease of entering numbers on phones - although that may become less relevant as smart phones take over the world (on my low-end Android phone for example it's easier to enter letters rather than numbers in web forms).

    My CouponCode algorithm embodies a number of trade-offs. I went for a base-32 encoding scheme to increase information density while avoiding having to use upper and lower case characters. The checkdigit on each part then adds extra data entry overhead but hopefully the instant feedback benefits outweigh that.

    With a numbers only code, the base-10 encoding would significantly reduce the information density. So a 4-digit part could only encode a key-space of 1000 possible codes vs 32768 for my alphanumeric codes. To get the same keyspace as my three part codes (XXXX-XXXX-XXXX) a numeric-only code would need 5 parts (XXXX-XXXX-XXXX-XXXX-XXXX) which is probably a bit unweildy.