There are 2^22 number of combinations I believe (4,194,304). One of my favorite ways of doing this is with SQL. Create a temp table with 2 records-- "yes" and "no". Now, join that table to itself 22 times. Each join will give you a Cartesian product, or all possible combinations.
untested, but you get the idea... DECLARE @question TABLE (answer char(1)) INSERT INTO @question VALUES (0) INSERT INTO @question VALUES (1) SELECT q1.answer + q2.answer + q3.answer + q4.answer + q5.answer + q6.answer + q7.answer + q8.answer + q9.answer ... + q22.answer FROM @question q1 INNER JOIN @question q2 ON 1 = 1 INNER JOIN @question q3 ON 1 = 1 INNER JOIN @question q4 ON 1 = 1 INNER JOIN @question q5 ON 1 = 1 INNER JOIN @question q6 ON 1 = 1 INNER JOIN @question q7 ON 1 = 1 INNER JOIN @question q8 ON 1 = 1 INNER JOIN @question q9 ON 1 = 1 .... INNER JOIN @question q22 ON 1 = 1 So, one possible output for example would be 1010101010101010101010 where each odd numbered question was marked true, and each even numbered question was marked false. It may take a while to churn out all 4 million combinations, but it will work. May I ask why on earth you are doing this? :) ~Brad -------- Original Message -------- Subject: Working out yes/no possibilities From: Thane Sherrington <[email protected]> Date: Mon, November 23, 2009 7:19 pm To: cf-talk <[email protected]> I have a yes/no questionnaire that I want to fill out with every possible pattern of answers - there are 22 questions in total, and I'm trying to come up with an algorithm that will give me every pattern of answers, but I'm just not bright enough to do it. :) Can anyone point me in the right direction? Thanks, T ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328639 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

