Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,

Soon I may be required to serialise many thousands of devices labelling them with an integer number.

The purpose of the number is to allow the device to be activated by entering the number assigned to it via an interface on a mobile phone. The process relates to real money transactions and therefore minimising the risk of accidentally activating the wrong device is essential.

I want the numbers assigned to the devices to be none sequential so going one number up or down doesn't activate another device.

The keypad is a standard numeric pad with 0 at the bottom below the number 8.

I want to minimise the risk of a single miss-key activating the wrong device.

So no single miss-key where by accidentally pressing any adjacent number key would match a valid device id. I'm happy to ignore matches where there are two miss-keys.

So I'm guessing this is more a question for the mathematicians of the group.

An example...

If a valid device ID was 12345. Where 2 and 4 are adjacent to 1, 22345 and 42345 would be excluded from the list of possible device ids.

Is there a way to generate this list using mathematical techniques or will I have to write an routine which starts with the first number, say 10000, and then work up from there testing each number in the sequence for clashes based on these rules?
Posted

1 solution

I would change it slightly, by putting a check digit either at the start or end of the number:
If you use a (sum-of-digits plus digit-position-number) modulo 10 then your are unlikely to get the same check digit by a simple mistake. This would also protect against transposed digits: 12435 instead of 12345 for example.
 
Share this answer
 
Comments
Stephen Hewison 6-Jul-12 8:48am    
Excellent idea +5
Manas Bhardwaj 6-Jul-12 9:01am    
v. good +5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900