is among - problem

Thomas J McGrath III 3mcgrath at adelphia.net
Sat Nov 22 07:58:39 EST 2003


AAWW, But Geoff, you cheated because NOW you know there are only 35 
possibles. At the beginning of this 'I' didn't know how many possible 
groups of three there would be.

But, I like your first solution and will play with it today to increase 
my understanding of transcript,

Thank you

Tom

On Nov 22, 2003, at 3:19 AM, Geoff Canyon wrote:

> So the first question is, you have a list of three digit numbers, some 
> of which are transposed copies of each other. You want to filter the 
> list so that any transposed duplicates are removed. This should work:
>
>   put empty into tNewList
>   repeat for each line L in tList
>     put sortChars(L) into tCandidate
>     if tHitList[tCandidate] is not empty then next repeat
>     put 1 into tHitList[tCandidate]
>     put L & return after tNewList
>   end repeat
>
> function sortChars p
>   put empty into r
>   repeat for each char c in p
>     put c & comma after r
>   end repeat
>   sort items of r
>   replace comma with empty in r
>   return r
> end sortChars
>
> On to the second problem, which is really the first since you wouldn't 
> have the above problem to solve if you could generate the answer to 
> the below directly. This code should do the trick. It produces a list 
> of 35 three-digit numbers, which we'll verify as the right number:
>
> on mouseUp
>   put empty into tList
>   repeat with i = 1 to 5
>     repeat with j = i + 1 to 6
>       repeat with k = j + 1 to 7
>         put i & j & k & cr after tList
>       end repeat
>     end repeat
>   end repeat
>   put tList
> end mouseUp
>
> It's hard-coded, but for this case that isn't much of an issue. To 
> verify that there are 35 solutions, consider that this problem 
> translates to: choose three numbers from the set "1,2,3,4,5,6,7" To 
> solve that, find 7C3, which is (7*6*5)/(3*2*1) That's 210/6, or 35
>
> regards,
>
> Geoff Canyon
> gcanyon at inspiredlogic.com
>
> On Nov 21, 2003, at 5:59 PM, Thomas J McGrath III wrote:
>
>> A group of three items from the list 1,2,3,4,5,6,7 with no duplicates 
>> in any order = 123 but no 213 or 312 or 231 or 321 and no doubles or 
>> triples = 111 or 112 or 323 or 322 etc. (WOW my daughter is only 13 
>> and this in my opinion is complex until I figured it out)
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>

Macintosh PowerBook G-4 OSX 10.3.1, OS 9.2.2, 1.25 GHz, 512MB RAM, Rev 
2.1.2


Advanced Media Group
Thomas J McGrath III 	 ð 2003 ð	3mcgrath at adelphia.net
220 Drake Road, Bethel Park, PA 15102





More information about the use-livecode mailing list