Coldfusion/SQL Randomize Algorithm
Posted on 2013-11-07
1) This may not exactly be a ColdFusion question, but I am going to program it in CF v10 and you guys are very smart! SQL Guys too!!!!
Problem: I need to generate in a random sequence a list if all possible 4 digit numbers only using the set of digits (1,2,3,4,5)
ex: 1234, 4455, 5555, 1111.
I'm not sure how to do this best. I could
- generate a random 4 digit number from the set of (1,2,3,4,5). I think I did that somewhere before in a CAPTCHA routine.
- Search a table to make sure I didn't pick it already. If I did retry otherwise store the number in the next slot of the table.
But at the end, it will be like looking for a needle in a haystack when I only have a few possibilities left?
2) FYI. I also use SQL Server 2012 and this could be part of the solution.
-- Insert rows (Sequential number column, random column)
- Select all rows order by random column
3) ColdFusion guys: How do I generate the numbers sequentially between 1111 - 5555 only using the digits 1,2,3,4,5?
Thanks in advance,