Coding Challenge

Peter Haworth pete at mollysrevenge.com
Tue Mar 8 14:33:03 EST 2011


I've got a feeling that any mathematician lurking on this list could give the algorithm to do this in no time - something to do with "set theory"?.  My clumsy attempt at doing would probably involve creating an array with the person's name as the key and the assigned pseudo age as the value.  Then I'd probably make multiple passes through the list assigning the ages based on the relationship and whether there is a key in the array for the person.  After that, it's easy to compare:

if Array["Bjornke"] > Array["Malte"] then
	do true stuff
else
	do false stuff
end if	

Pete Haworth

On Mar 8, 2011, at 11:14 AM, Bob Sneidar wrote:

> Dang I was just formulating that, but you would have to build a list of already assigned people and then pop them in the middle as logic dictates. 
> 
> Bob
> 
> 
> On Mar 8, 2011, at 11:05 AM, Peter Haworth wrote:
> 
>> Would it work to assign "pseudo ages" to each of the people based on the given relationships, starting with the first?  In your example:
>> 
>> Malte (1000) is older than Bjornke(500)
>> Mark (1500) is older than Malte
>> 
>> Then you can sort by the age as others have suggested.  Seems to work well on this small sample size but I guess it could get pretty complicated to assign the pseudo ages if there is a large number of people.
>> 
>> Pete Haworth
>> 
>> On Mar 8, 2011, at 10:49 AM, Malte Brill wrote:
>> 
>>> Thanks for the head ups folks,
>>> 
>>> Björnke and Mark: I do not have the exact ages to sort by. All I do have is relations:
>>> 
>>> Malte is older than Björnke
>>> Mark is older than Malte
>>> 
>>> And now I need to compute if it is valid to say: 
>>> - Björnke is older than Mark  (obviously not)
>>> - Björnke is the same age as Mark (obviously not)
>>> - Björnke is younger than Mark. (That´s the one)
>>> 
>>> What comes easy to the human brain in fact appears to be a lot more difficult when having to be tackled computationaly.
>>> 
>>> Chris: Yes, I want such a list in the end. But in order to finally get this I will need to tell the machine which relations are legal first (the user tells which relations there are) and ideally filter out the data for relations that make no sense. Now I wish it was easy to tell the machine to just use logic and make sense itself :D This comparison has to be done for thousands of entities (children in this case). 
>>> 
>>> 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
>>> 
>> 
>> 
>> _______________________________________________
>> 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
> 
> 
> _______________________________________________
> 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