Coding Challenge

Alex Tweedly alex at tweedly.net
Fri Mar 11 06:02:57 EST 2011


Sorry Malte - I didn't handle > relationships, only = and <.
That part of the script should be changed to be
>    -- now normalize the direct relationships
>    put empty into gRelate
>    repeat for each line  L in tData
>       if word 2 of L = "<" then
>          put sample(word 1 of L) into t1
>          put sample(word 3 of L) into t2
>          put t1 && t2 & CR after tUnequal
>       else if word 2 of L = "<" then
>          put sample(word 1 of L) into t1
>          put sample(word 3 of L) into t2
>          put t2 && t1 & CR after tUnequal
>       end if
>    end repeat

You asked
> function testValidRelationships pPerson1,pPerson2
>
>
> which returns a triplet like
>
> false,true,false
>
> -- can not be older,can be younger, can not be the same age.
>
> Do you think your script can be expanded to check this?
Yes, though I would prefer a different function / result.  You have "can 
not be older" - but that means either "is younger" or  "is same" and you 
know which it is.

How about
function getRelationship p1, p2
-- returns one of
-- older (p1 is older than p2)
-- younger (p1 is younger)
-- same
-- unknown  (not enough info to tell anything about their relationship)


Here it is ...
> function getRelationship p1, p2
>    -- returns one of
>    -- older (p1 is older than p2)
>    -- younger (p1 is younger)
>    -- same
>    put sample(p1) into p1
>    put sample(p2) into p2
>    if p1 = p2 then return "same"
>    if p2 is among the lines of gOlder[p1] then return "younger"
>    if p1 is among the lines of gOlder[p2] then return "older"
>    return "unknown"
> end getRelationship

-- Alex.





On 11/03/2011 09:31, Malte Brill wrote:
> Hi Alex,
>
> thanks for taking the time to look into this. (and not late to the party at all)
>
> If I provide this data to your Script:
>
> Steffen>  Malte
> Sascha<  Malte
> Fritz = Sascha
>
> I get back
>
> Fritz----->
> Malte
>
> in the field. Which is true, but it leaves steffen untouched in this case. I guess what I would be looking for is something like
>
> function testValidRelationships pPerson1,pPerson2
>
>
> which returns a triplet like
>
> false,true,false
>
> -- can not be older,can be younger, can not be the same age.
>
> Do you think your script can be expanded to check this?
>
> Thanks a heap again for taking the time to look into this.
>
> Cheers,
>
> Malte
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>





More information about the use-livecode mailing list