Re: Coding challenge
I'm interested that nobody went recursive. My first solution (I read Mark's email and stopped reading until I'd done a version) was command testChange local t put empty into t repeat 10 times get random(99) put format(to make %d:%s\n, it, makeChange(it)) after t end repeat put t end testChange function makeChange iAmount, tChangeSoFar constant kCoins = 50 20 10 5 2 1 if iAmount 1 then return tChangeSoFar repeat for each word c in kCoins if iAmount = c then return makeChange(iAmount - c, tChangeSoFar c) end if end repeat return error end makeChange (note the especially crafty thing here: that by citing my test function, I've justified leaving a leading space in my output...). So far, effectively like the rest - I don't think the recursion is better, I was just surprised that nobody else naturally went that way. When I replaced the coins list with the unusual denominations of Craig$, 6 came out as 4+1+1, as you'd expect. Here I think is where recursion makes things better, because it's easy to adjust: function makeChange iAmount, tChangeSoFar local tCandidates constant kCoins = 40 30 10 4 3 1 -- 50 20 10 5 2 1 if iAmount 1 then return tChangeSoFar put empty into tCandidates repeat for each word c in kCoins if iAmount c then next repeat put makeChange(iAmount - c, c) return after tCandidates end repeat sort lines of tCandidates ascending numeric by the number of words in each return tChangeSoFar first line of tCandidates end makeChange With these small changes this works, and I'm confident returns the optimal solution - but it gets shockingly slow for values above about 20. The first reason it was so slow is because I'm being lazy above - allowing the code to try options in the wrong order, as each call tries the full set of coins again. I tried speeding it up by making it having found a coin it can use, try with that and the next one down, but not all possibles. I'm reasonably confident that this produced the right result for all cases with Craig's currency - but I wasn't absolutely sure, and it's certainly not a general solution, eg asked to make 27 out of 40 30 23 20 9 1 - admittedly a really crazy currency - it would offer 23 1 1 1 1 rather than the optimal 9 9 9. So in the end I had to rewrite it more substantially: command testChange constant kCoins = 40 30 10 4 3 1 -- 50 20 10 5 2 1 local t put empty into t repeat 10 times get random(99) put format(to make %d:%s\n, it, makeChange(it, kCoins)) after t end repeat put t end testChange function makeChange iAmount, tCoins, tChangeSoFar local tCandidates, i, c, j if iAmount 1 then return tChangeSoFar -- trim coins that couldn't possibly be used repeat with i = number of words in tCoins down to 1 if word i of tCoins iAmount then delete word i of tCoins end repeat -- find possible combinations put empty into tCandidates repeat with i = 1 to number of words in tCoins put word i of tCoins into c put makeChange(iAmount - c, word i to -1 of tCoins, c) \ return after tCandidates end repeat -- return shortest combination sort lines of tCandidates ascending numeric by the number of words in each return tChangeSoFar first line of tCandidates end makeChange This definitely returns the optimal combination. It's quite slow (fractions of a second, but noticeable fractions). But I feel entirely justified in playing LiveCode's joker: local saAmountCoins2Change function makeChange iAmount, tCoins, tChangeSoFar local tCandidates, i, c, j if iAmount 1 then return tChangeSoFar -- have we done this before? get saAmountCoins2Change[iAmount, tCoins] if it empty then return tChangeSoFar it -- trim coins that couldn't possibly be used repeat with i = number of words in tCoins down to 1 if word i of tCoins iAmount then delete word i of tCoins end repeat -- find possible combinations put empty into tCandidates repeat with i = 1 to number of words in tCoins put word i of tCoins into c put makeChange(iAmount - c, word i to -1 of tCoins, c) \ return after tCandidates end repeat -- return shortest combination sort lines of tCandidates ascending numeric by the number of words in each put first line of tCandidates into saAmountCoins2Change[iAmount, tCoins] return tChangeSoFar first line of tCandidates end makeChange Interestingly, even if the array is emptied before each run of tests, this changes the typical time for a run of tests from approx 1 second for the ten, to approx 7 milliseconds for the ten. Of course, if the array isn't emptied, after a few runs it approaches zero. (If the array is emptied before each single test, which could be described as fairer, it averages around 20 milliseconds for ten tests). But of course, all of that is only necessary if we move to
Re: Coding challenge
Paul. As six pennies. As long as you have a 1, you should be OK. Craig Newman -Original Message- From: Paul D. DeRocco pdero...@ix.netcom.com To: 'How to use LiveCode' use-livecode@lists.runrev.com Sent: Thu, Jan 31, 2013 12:57 am Subject: RE: Coding challenge From: Mark Wieder Now how would you do it if the available coin values were: 40,30,10,4,3,1 That's a more interesting problem, but probably a less interesting coding test, because I think it would involve a more brute force approach, less elegance. I'm missing something. Why would that be different? How would you represent 6? -- Ciao, Paul D. DeRocco Paulmailto:pdero...@ix.netcom.com ___ use-livecode mailing list use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
The question was Determine the minimum number of coins for change. so the correct answer here would be 2 coins (3+3) rather than 6 coins (1+1+...) That's what makes this a more challenging case, but probably without as elegant an answer ... -- Alex. On 31/01/2013 13:54, dunb...@aol.com wrote: Paul. As six pennies. As long as you have a 1, you should be OK. Craig Newman -Original Message- From: Paul D. DeRocco pdero...@ix.netcom.com To: 'How to use LiveCode' use-livecode@lists.runrev.com Sent: Thu, Jan 31, 2013 12:57 am Subject: RE: Coding challenge From: Mark Wieder Now how would you do it if the available coin values were: 40,30,10,4,3,1 That's a more interesting problem, but probably a less interesting coding test, because I think it would involve a more brute force approach, less elegance. I'm missing something. Why would that be different? How would you represent 6? ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
Here's my one: on makeChange Amt answer 100-Amt end makeChange Oh wait, that's for showing the maximum number of coins… ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
Alex- Thursday, January 31, 2013, 6:53:36 AM, you wrote: The question was Determine the minimum number of coins for change. so the correct answer here would be 2 coins (3+3) rather than 6 coins (1+1+...) That's what makes this a more challenging case, but probably without as elegant an answer ... In any of the submitted examples, replacing the string 50,20,10,5,2,1 with 40,30,10,4,3,1 does the right string. No more challenging than the original question. And yes, the minimum number of coins to represent 6 in this case is 3+3 and the next in line would be 4+1+1. And then six coins. -- -Mark Wieder mwie...@ahsoftware.net ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
Hi. I sped-read your comment, and answered generically. You might say that I answered for the number 4, with only 20,10,5,1 as options. But all the several solutions sent to Mark ran from high denominations to low. So two 3's would appear before it was ever an issue to load a bunch of 1's. The minimum number of coins was always the result. Craig Newman -Original Message- From: Alex Tweedly a...@tweedly.net To: use-livecode use-livecode@lists.runrev.com Sent: Thu, Jan 31, 2013 9:54 am Subject: Re: Coding challenge The question was Determine the minimum number of coins for change. so the correct answer here would be 2 coins (3+3) rather than 6 coins (1+1+...) That's what makes this a more challenging case, but probably without as elegant an answer ... -- Alex. On 31/01/2013 13:54, dunb...@aol.com wrote: Paul. As six pennies. As long as you have a 1, you should be OK. Craig Newman -Original Message- From: Paul D. DeRocco pdero...@ix.netcom.com To: 'How to use LiveCode' use-livecode@lists.runrev.com Sent: Thu, Jan 31, 2013 12:57 am Subject: RE: Coding challenge From: Mark Wieder Now how would you do it if the available coin values were: 40,30,10,4,3,1 That's a more interesting problem, but probably a less interesting coding test, because I think it would involve a more brute force approach, less elegance. I'm missing something. Why would that be different? How would you represent 6? ___ use-livecode mailing list use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
Colin. At least you are true-to-form, in providing a minimum line solution. Feels like old times. How about: on x end x Doesn't do much that is useful, true, but is the shortest possible handler. Craig -Original Message- From: Colin Holgate co...@verizon.net To: How to use LiveCode use-livecode@lists.runrev.com Sent: Thu, Jan 31, 2013 10:05 am Subject: Re: Coding challenge Here's my one: on makeChange Amt answer 100-Amt end makeChange Oh wait, that's for showing the maximum number of coins… ___ use-livecode mailing list use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
This is one case where Lingo (the main language used in Director) would be better, you don't have to include the end line. So this would be just as good (or bad, depending on how you look at it): on x On Jan 31, 2013, at 12:44 PM, dunb...@aol.com wrote: on x end x Doesn't do much that is useful, true, but is the shortest possible handler. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
RE: Coding challenge
Mark Wieder In any of the submitted examples, replacing the string 50,20,10,5,2,1 with 40,30,10,4,3,1 does the right string. No more challenging than the original question. And yes, the minimum number of coins to represent 6 in this case is 3+3 and the next in line would be 4+1+1. And then six coins. Yes, and the examples so far would render 6 as 4+1+1, not 3+3, which is the wrong answer. -- Ciao, Paul D. DeRocco Paulmailto:pdero...@ix.netcom.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
Someone should post Jacques as an example of how coding in Livecode is so much more compact. Bob On Jan 30, 2013, at 8:45 PM, J. Landman Gay wrote: On 1/30/13 10:29 PM, Mark Wieder wrote: And everyone but me seemed to think of listing the number of coin types. I got lazy and just repeated the coin if necessary. Regardless, all the solutions are way more readable than the web page examples. -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com ___ use-livecode mailing list use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
Ah, but you DID remember it! Which is more that I seem capable of these days. :-) Bob On Jan 30, 2013, at 8:56 PM, J. Landman Gay wrote: On 1/30/13 10:38 PM, dunb...@aol.com wrote: I think, as usual, Jacque's is the most original. Thanks, but it's really just a variation on calculating digital time (hours, mins, secs) from seconds. I didn't think up that one. -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com ___ use-livecode mailing list use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
Ah. Paul is right, the descending scheme finds 4,1,1 instead of 3,3, because since the 4 is used first this leaves only 1's available for the rest of the work. Ah. This is now a more interesting challenge. It requires that the nextmost lower value be considered as a candidate. And maybe even lower nextmost ones? Craig. -Original Message- From: Paul D. DeRocco pdero...@ix.netcom.com To: 'How to use LiveCode' use-livecode@lists.runrev.com Sent: Thu, Jan 31, 2013 12:55 pm Subject: RE: Coding challenge Mark Wieder In any of the submitted examples, replacing the string 50,20,10,5,2,1 with 40,30,10,4,3,1 does the right string. No more challenging than the original question. And yes, the minimum number of coins to represent 6 in this case is 3+3 and the next in line would be 4+1+1. And then six coins. Yes, and the examples so far would render 6 as 4+1+1, not 3+3, which is the wrong answer. -- Ciao, Paul D. DeRocco Paulmailto:pdero...@ix.netcom.com ___ use-livecode mailing list use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
4 and 2 1's? Isn't the test to produce the result with the least amount of coins? This would still work. The idea is to try and fit the largest coin value into the remainder each time, until the remainder is zero. Bob On Jan 31, 2013, at 5:54 AM, dunb...@aol.com wrote: Paul. As six pennies. As long as you have a 1, you should be OK. Craig Newman -Original Message- From: Paul D. DeRocco pdero...@ix.netcom.com To: 'How to use LiveCode' use-livecode@lists.runrev.com Sent: Thu, Jan 31, 2013 12:57 am Subject: RE: Coding challenge From: Mark Wieder Now how would you do it if the available coin values were: 40,30,10,4,3,1 That's a more interesting problem, but probably a less interesting coding test, because I think it would involve a more brute force approach, less elegance. I'm missing something. Why would that be different? How would you represent 6? -- Ciao, Paul D. DeRocco Paulmailto:pdero...@ix.netcom.com ___ use-livecode mailing list use-livecode@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@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
OIC now. 3 3 is the best answer but the algorithm produces 4 + 1 + 1. Well I think the issue here is that currency is never (or almost never) designed this way. No one would make a 3 dollar bill coincidentally with a 4 dollar bill. There would be no practical reason to. And yet I remember for a time the USA produced a one dollar bill and a two dollar bill. So never say never! :-) It seems that when creating currency values, one of the overriding principles OUGHT to be that each smaller value ought to divide evenly into all the larger values. I'm sure this is what was intended with American currency when it was first created in it's present form. Otherwise making change becomes rather tedious. Bob On Jan 30, 2013, at 9:56 PM, Paul D. DeRocco wrote: From: Mark Wieder Now how would you do it if the available coin values were: 40,30,10,4,3,1 That's a more interesting problem, but probably a less interesting coding test, because I think it would involve a more brute force approach, less elegance. I'm missing something. Why would that be different? How would you represent 6? -- Ciao, Paul D. DeRocco Paulmailto:pdero...@ix.netcom.com ___ use-livecode mailing list use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
On 1/31/13 9:43 AM, Mark Wieder wrote: Alex- Thursday, January 31, 2013, 6:53:36 AM, you wrote: The question was Determine the minimum number of coins for change. so the correct answer here would be 2 coins (3+3) rather than 6 coins (1+1+...) That's what makes this a more challenging case, but probably without as elegant an answer ... In any of the submitted examples, replacing the string 50,20,10,5,2,1 with 40,30,10,4,3,1 does the right string. No more challenging than the original question. And yes, the minimum number of coins to represent 6 in this case is 3+3 and the next in line would be 4+1+1. And then six coins. Actually, after replacing the coin values in my original solution, change for 6 comes out: 4=1 1=2 Which is the correct change but not the minimum number of coins. -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
Paul D. DeRocco pderocco@... writes: Yes, and the examples so far would render 6 as 4+1+1, not 3+3, which is the wrong answer. Ah. Right you are. -- Mark Wieder mwie...@ahsoftware.net ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
On 31 Jan 2013, at 05:40, Paul D. DeRocco pdero...@ix.netcom.com wrote: Now how would you do it if the available coin values were: 40,30,10,4,3,1 That's a more interesting problem, but probably a less interesting coding test, because I think it would involve a more brute force approach, less elegance. Right. Not only finding the least number of coins, but also checking that the available coins can be used to create the desired total. The presence of a 1-unit coin should make that so, so long as you check the desired total is an integer. Not all solutions checked for that. Tut tut! :-) Dave ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
RE: Coding challenge
From: Robert Sneidar OIC now. 3 3 is the best answer but the algorithm produces 4 + 1 + 1. Well I think the issue here is that currency is never (or almost never) designed this way. No one would make a 3 dollar bill coincidentally with a 4 dollar bill. There would be no practical reason to. And yet I remember for a time the USA produced a one dollar bill and a two dollar bill. So never say never! :-) It seems that when creating currency values, one of the overriding principles OUGHT to be that each smaller value ought to divide evenly into all the larger values. I'm sure this is what was intended with American currency when it was first created in it's present form. Otherwise making change becomes rather tedious. Actually, there was a brief time (1875-1888) when we had both a quarter and a 20-cent coin. So the algorithm would make 40 cents out of 25+10+5, instead of 20+20. -- Ciao, Paul D. DeRocco Paulmailto:pdero...@ix.netcom.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
We also had both a nickel and a half dime together for several years. I cannot figure out how to handle that. Craig Newman -Original Message- From: Paul D. DeRocco pdero...@ix.netcom.com To: 'How to use LiveCode' use-livecode@lists.runrev.com Sent: Thu, Jan 31, 2013 3:02 pm Subject: RE: Coding challenge From: Robert Sneidar OIC now. 3 3 is the best answer but the algorithm produces 4 + 1 + 1. Well I think the issue here is that currency is never (or almost never) designed this way. No one would make a 3 dollar bill coincidentally with a 4 dollar bill. There would be no practical reason to. And yet I remember for a time the USA produced a one dollar bill and a two dollar bill. So never say never! :-) It seems that when creating currency values, one of the overriding principles OUGHT to be that each smaller value ought to divide evenly into all the larger values. I'm sure this is what was intended with American currency when it was first created in it's present form. Otherwise making change becomes rather tedious. Actually, there was a brief time (1875-1888) when we had both a quarter and a 20-cent coin. So the algorithm would make 40 cents out of 25+10+5, instead of 20+20. -- Ciao, Paul D. DeRocco Paulmailto:pdero...@ix.netcom.com ___ use-livecode mailing list use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
dunbarx@... writes: We also had both a nickel and a half dime together for several years. I cannot figure out how to handle that. Don't sweat it. You put them both in the same coin slot. The only time you need to worry about it is when the slot runs dry. For the same reason, you don't need to check the date on a nickel before handing it out in change. -- Mark Wieder mwie...@ahsoftware.net ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
Mark. For the same reason, you don't need to check the date on a nickel before handing it out in change. Ha. Please hand me a nice, unworn 1926S nickel in my change. Or maybe a 1913 liberty? Craig -Original Message- From: Mark Wieder mwie...@ahsoftware.net To: use-livecode use-livecode@lists.runrev.com Sent: Thu, Jan 31, 2013 4:29 pm Subject: Re: Coding challenge dunbarx@... writes: We also had both a nickel and a half dime together for several years. I cannot figure out how to handle that. Don't sweat it. You put them both in the same coin slot. The only time you need to worry about it is when the slot runs dry. For the same reason, you don't need to check the date on a nickel before handing it out in change. -- Mark Wieder mwie...@ahsoftware.net ___ use-livecode mailing list use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
It would depend on what's in your wallet ;-) On 31/01/2013, at 2:16 PM, Mark Wieder mwie...@ahsoftware.net wrote: ...and the xtalk implementation would be... -- Monte Goulding M E R Goulding - software development services mergExt - There's an external for that! ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
OK - I'm usually crap at these things but I'll have a go... function getChange pTotal put 50,20,10,5,2,1 into tCoins local tCounts put 0 into tValue repeat for each item tCoin in tCoins put trunc(pTotal/tCoin) into tValue put tValue space after tCounts subtract tCoin*tValue from pTotal end repeat return tCounts end getChange Terry... On 31/01/2013, at 02:16 PM, Mark Wieder wrote: Today's algorithm challenge: Determine the minimum number of coins for change. Given any number between 1 and 99, determine how to give change with the minimum number of coins. You can assume that the coins are 1c, 2c, 5c, 10c, 20c and 50c. Various solutions here in Scala, java, C#, Groovy... http://java.dzone.com/articles/thursday-code-puzzler-change ...and the xtalk implementation would be... -- -Mark Wieder mwie...@ahsoftware.net ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode Dr Terry Judd Senior Lecturer in Medical Education Medical Eduction Unit Faculty of Medicine, Dentistry Health Sciences The University of Melbourne ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
On 1/30/13 9:16 PM, Mark Wieder wrote: Today's algorithm challenge: Determine the minimum number of coins for change. Given any number between 1 and 99, determine how to give change with the minimum number of coins. You can assume that the coins are 1c, 2c, 5c, 10c, 20c and 50c. Various solutions here in Scala, java, C#, Groovy... http://java.dzone.com/articles/thursday-code-puzzler-change ...and the xtalk implementation would be... Didn't test all possible values, but so far this works: on makeChange pAmt repeat for each item i in 50,20,10,5,2,1 put i = pAmt div i cr after tList put pAmt mod i into pAmt end repeat filter tList without *=0 put tList into fld change end makeChange -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
Terry- Wednesday, January 30, 2013, 7:56:49 PM, you wrote: OK - I'm usually crap at these things but I'll have a go... function getChange pTotal put 50,20,10,5,2,1 into tCoins local tCounts put 0 into tValue repeat for each item tCoin in tCoins put trunc(pTotal/tCoin) into tValue put tValue space after tCounts subtract tCoin*tValue from pTotal end repeat return tCounts end getChange That'll do it. Running your implementation I get a number for each coin type. As in 74 = 1 1 0 0 2 0 -- -Mark Wieder mwie...@ahsoftware.net ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
Jacque- Wednesday, January 30, 2013, 7:59:42 PM, you wrote: on makeChange pAmt repeat for each item i in 50,20,10,5,2,1 put i = pAmt div i cr after tList put pAmt mod i into pAmt end repeat filter tList without *=0 put tList into fld change end makeChange Mod - nicely done. I hadn't thought of the solution of sorting by coin type. So I get 74 = 50=1 20=1 2=2 -- -Mark Wieder mwie...@ahsoftware.net ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
Here's the one I came up with: function makeChange pValue local tChange set the itemdelimiter to comma repeat for each item tCoin in 50,20,10,5,2,1 repeat while pValue = tCoin put tCoin comma after tChange subtract tCoin from pValue end repeat end repeat return char 1 to -2 of tChange end makeChange And for 74 I get 50,20,2,2 -- -Mark Wieder mwie...@ahsoftware.net ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
And here's my simple logical non-mathematician version! function coinChange pChange repeat for each item x in 50, 20, 10, 5, 2, 1 repeat while pChange = x subtract x from pChange add 1 to y end repeat if y 0 then put y x x c cr after tResult put 0 into y end repeat return tResult end coinChange Paul On 2013-01-30, at 7:16 PM, Mark Wieder wrote: Today's algorithm challenge: Determine the minimum number of coins for change. Given any number between 1 and 99, determine how to give change with the minimum number of coins. You can assume that the coins are 1c, 2c, 5c, 10c, 20c and 50c. Various solutions here in Scala, java, C#, Groovy... http://java.dzone.com/articles/thursday-code-puzzler-change ...and the xtalk implementation would be... -- -Mark Wieder mwie...@ahsoftware.net ___ use-livecode mailing list use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
Paul- Wednesday, January 30, 2013, 8:21:36 PM, you wrote: And here's my simple logical non-mathematician version! function coinChange pChange repeat for each item x in 50, 20, 10, 5, 2, 1 repeat while pChange = x subtract x from pChange add 1 to y end repeat if y 0 then put y x x c cr after tResult put 0 into y end repeat return tResult end coinChange You did the same nested repeat thing I did. And everyone but me seemed to think of listing the number of coin types. I got lazy and just repeated the coin if necessary. -- -Mark Wieder mwie...@ahsoftware.net ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
Mark: on mouseup ask Enter Value put it into temp put 50,20,10,5,2,1 into coins put 1 into tCount repeat until temp = 0 if item tCount of coins = temp then put item tCount of coins , after tChange subtract item tCount of coins from temp else add 1 to tCount end if end repeat answer tChange end mouseup Craig ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
I think, as usual, Jacque's is the most original. Craig on makeChange pAmt repeat for each item i in 50,20,10,5,2,1 put i = pAmt div i cr after tList put pAmt mod i into pAmt end repeat filter tList without *=0 put tList into fld change end makeChange -Original Message- From: J. Landman Gay jac...@hyperactivesw.com To: How to use LiveCode use-livecode@lists.runrev.com Sent: Wed, Jan 30, 2013 11:00 pm Subject: Re: Coding challenge On 1/30/13 9:16 PM, Mark Wieder wrote: Today's algorithm challenge: Determine the minimum number of coins for change. Given any number between 1 and 99, determine how to give change with the minimum number of coins. You can assume that the coins are 1c, 2c, 5c, 10c, 20c and 50c. Various solutions here in Scala, java, C#, Groovy... http://java.dzone.com/articles/thursday-code-puzzler-change ...and the xtalk implementation would be... Didn't test all possible values, but so far this works: on makeChange pAmt repeat for each item i in 50,20,10,5,2,1 put i = pAmt div i cr after tList put pAmt mod i into pAmt end repeat filter tList without *=0 put tList into fld change end makeChange -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com ___ use-livecode mailing list use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
On 1/30/13 10:29 PM, Mark Wieder wrote: And everyone but me seemed to think of listing the number of coin types. I got lazy and just repeated the coin if necessary. Regardless, all the solutions are way more readable than the web page examples. -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
Craig- Wednesday, January 30, 2013, 8:31:54 PM, you wrote: on mouseup ask Enter Value put it into temp put 50,20,10,5,2,1 into coins put 1 into tCount repeat until temp = 0 if item tCount of coins = temp then put item tCount of coins , after tChange subtract item tCount of coins from temp else add 1 to tCount end if end repeat answer tChange end mouseup OK. You went with my approach as well - listing the coins as values rather than by number. I'll have to subtract a point for not cleaning up the trailing comma, though. -- -Mark Wieder mwie...@ahsoftware.net ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
On 31/01/2013, at 2:22 PM, Monte Goulding mo...@sweattechnologies.com wrote: It would depend on what's in your wallet ;-) On 31/01/2013, at 2:16 PM, Mark Wieder mwie...@ahsoftware.net wrote: ...and the xtalk implementation would be... on mouseUp put random(99) into tChange put tChangecrmakeChange(tChange) end mouseUp function makeChange pChange repeat for each item tCoin in 50,20,10,5,2,1 put pChange div tCoin into tCoins if tCoins 0 then put tCoinxtCoinscr after tReturn end if put pChange mod tCoin into pChange end repeat return tReturn end makeChange -- Monte Goulding M E R Goulding - software development services mergExt - There's an external for that! ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
On 1/30/13 10:38 PM, dunb...@aol.com wrote: I think, as usual, Jacque's is the most original. Thanks, but it's really just a variation on calculating digital time (hours, mins, secs) from seconds. I didn't think up that one. -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
Mark. That comma is there for future expansion. Craig -Original Message- From: Mark Wieder mwie...@ahsoftware.net To: How to use LiveCode use-livecode@lists.runrev.com Sent: Wed, Jan 30, 2013 11:46 pm Subject: Re: Coding challenge Craig- Wednesday, January 30, 2013, 8:31:54 PM, you wrote: on mouseup ask Enter Value put it into temp put 50,20,10,5,2,1 into coins put 1 into tCount repeat until temp = 0 if item tCount of coins = temp then put item tCount of coins , after tChange subtract item tCount of coins from temp else add 1 to tCount end if end repeat answer tChange end mouseup OK. You went with my approach as well - listing the coins as values rather than by number. I'll have to subtract a point for not cleaning up the trailing comma, though. -- -Mark Wieder mwie...@ahsoftware.net ___ use-livecode mailing list use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
RE: Coding challenge
Now how would you do it if the available coin values were: 40,30,10,4,3,1 That's a more interesting problem, but probably a less interesting coding test, because I think it would involve a more brute force approach, less elegance. -- Ciao, Paul D. DeRocco Paulmailto:pdero...@ix.netcom.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding challenge
Craig- Wednesday, January 30, 2013, 9:08:00 PM, you wrote: That comma is there for future expansion. LOL. -- -Mark Wieder mwie...@ahsoftware.net ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
RE: Coding challenge
From: Mark Wieder Now how would you do it if the available coin values were: 40,30,10,4,3,1 That's a more interesting problem, but probably a less interesting coding test, because I think it would involve a more brute force approach, less elegance. I'm missing something. Why would that be different? How would you represent 6? -- Ciao, Paul D. DeRocco Paulmailto:pdero...@ix.netcom.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding Challenge
I'll drop my code in LC and actually RUN it now. If you want to collaborate closer on it, I'd be happy to help. My AIM/iChat is FluffAndSuch. (Other LCers are welcome to use that too.) ~ Chris Innanen ~ Nonsnaity On Sat, Mar 12, 2011 at 3:39 AM, Malte Brill revolut...@derbrill.de wrote: Chris, thanks for looking into this again. After looking closer at Steffens version there indeed are some problems left. Using yours (and adapting it a bit) always returned true (but I think this is due to one or two typos I am looking at tonight) Alex: I think I was a bit overenthusiastic when I said I´d works. It works in 95% of all cases. Not all yet. :-D So, I will also test yours again later today. I need this to work on Monday morning, so long weekend will be long. g Thanks again, Malte ___ use-livecode mailing list use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding Challenge
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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding Challenge
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@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding Challenge
Hi Alex, well what I need to do is to check if the relationship I am wanting to set is valid or not, before I write it to the database. I might not be clear enough. But my goal is not really to check for existing relations, but the validity of the data I am about to enter into the Database. So if there is no relation at all, any relation is valid. Direct relations are clear and indirect relations need to be checked for. Maybe I just dot understand how I would use your script in that case. Sorry for the confusion. Malte ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding Challenge
Try this. I haven't tested, but the logic looks sound enough... private function resolveRelation pPers1,pPers2,pRelation put sRelations[pPers1][pPers2] into relationship -- if the two are equal but we're testing for or then return false if relationship is = and pRelation is not = then return false -- else if the relationship is a direct match, return true else relationship = pRelation then return true end if -- otherwise, interate to see if the relationship is true -- note that at this point, we know the two aren't directly equal -- this is important because the first interation HAS to be or and not = or = -- further interations can be = and =, but the first cannot get traverseList(pPers1,pPers2,pRelation) -- if the relationship is valid, then put it into the DB to save time later if it is true then set sRelations[pPers1][pPers2] to pRelation end if return it end resolveRelation private function traverseList pPers1,pPers2,pRelation -- are the two people of the correct relationship and/or equal? if sRelations[pPers2][pPers2] = pRelation or sRelations[pPers2][pPers2] = pRelation then return true end if local tOther put the keys of sRelations[pPers1] into tOther repeat for each line personB in tOther -- only follow branches leading to the same relationship we are testing ( or ) -- OR =, so long as the first iteration was or -- So if: AB and BC and C=D and DE then AE must be true if sRelations[pPers2][personB] = pRelation or sRelations[pPers2][personB] = = then return traverseList(personB,pPers2,pRelation) end if end repeat return false end traverseList ~ Chris Innanen ~ Nonsanity On Fri, Mar 11, 2011 at 8:26 AM, Malte Brill revolut...@derbrill.de wrote: Ok, I will not claim I understand how this works, but it appears to do. :-) Still needs more testing, but for now I think it works. Cheers, Malte I have been asking a colleague for help (Danke danke danke Steffen) and here is what he came up with: local sRelations, sOpList on mouseUp local tValid delete variable sRelations delete variable sOpList set the itemdel to TAB -- fld Data is TAb delimited. Person1 TAB Operator TAB Person2 repeat for each line theLine in fld data if item 2 of theLine = = then put = into sRelations[item 1 of theLine][item 3 of theLine] put = into sRelations[item 3 of theLine][item 1 of theLine] end if if item 2 of theLine = then put into sRelations[item 1 of theLine][item 3 of theLine] put into sRelations[item 3 of theLine][item 1 of theLine] end if if item 2 of theLine = then put into sRelations[item 1 of theLine][item 3 of theLine] put into sRelations[item 3 of theLine][item 1 of theLine] end if end repeat answer checkForValidRelation(the text of fld pers1,the text of fld pers2,the label of btn relation) -- returns true or false for the validity of the relation you are about to set. end mouseUp private function checkForValidRelation pPers1,pPers2,pRelation local tResolved put resolveRelation(pPers1,pPers2,pRelation) into tResolved if not tResolved then return true return (checkOperator(pRelation) = pRelation) end checkForValidRelation private function resolveRelation pPers1,pPers2,pRelation if sRelations[pPers1][pPers2] is not empty then put sRelations[pPers1][pPers2] cr after sOpList return true end if -- iterate through list return traverseList(pPers1,pPers2,pRelation) end resolveRelation private function traverseList pPers1,pPers2,pRelation local tOther put the keys of sRelations[pPers1] into tOther repeat for each line personB in tOther if personB = pPers2 then put sRelations[pPers1][personB] cr after sOpList return true else if traverseList(pPers1,personB,pRelation) then return true end if end if end repeat return false end traverseList private function checkOperator pRelation local tSame, tLast put true into tSame put pRelation into tLast repeat for each line theLine in sOpList if theLine is not empty then if theLine pRelation then put false into tSame end if put theLine into tLast end if end repeat if not tSame then return tLast end if return pRelation end checkOperator ___ use-livecode mailing list use-livecode@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@lists.runrev.com Please
Re: Coding Challenge
On Fri, Mar 11, 2011 at 1:54 PM, Nonsanity f...@nonsanity.com wrote: Try this. I haven't tested, but the logic looks sound enough... Actually, don't try that, try this. That one had flaws this one should fix. (But again, not tested at ALL.) private function resolveRelation pPers1,pPers2,pRelation put sRelations[pPers1][pPers2] into relationship -- if the relationship is a direct match, return true if relationship = pRelation then return true -- else if there is a direct relationship, but not the one we're testing for, then fail else if relationship is not empty and relationship is not pRelation then return false end if -- make a reversed copy of our target relationship put pRelation into Rel if pRelation is then put into Rel else if pRelation is then put into Rel -- otherwise, there is no direct relationship, so look for an indirect one -- to find one, we first find other items related to both inputs that have the same relationship exactly -- then iterate through the tree looking for further = or = relationships local tOther put the keys of sRelations[pPers1] into tOther repeat for each line personB in tOther if sRelations[pPers1][personB] = pRelation then get traverseList(pPers1,personB,pRelation,Rel) if it is true then set sRelations[pPers1][pPers2] to pRelation set sRelations[pPers2][pPers1] to Rel return true end if end if end repeat -- test for the other direction, reverse everything put the keys of sRelations[pPers2] into tOther repeat for each line personB in tOther if sRelations[pPers2] = Rel then get traverseList(pPers2,personB,Rel,Rel) if it is true then set sRelations[pPers1][pPers2] to pRelation set sRelations[pPers2][pPers1] to Rel return true end if end if end repeat return false end resolveRelation -- pPersV varies as we move through the tree -- pPersX is our target person private function traverseList pPersV,pPersX,pRelation,pRevRel -- are the two people of the correct relationship and/or equal? if sRelations[pPersV][pPersX] = pRelation or sRelations[pPersV][pPersX] = = then return true end if local tOther put the keys of sRelations[pPersV] into tOther repeat for each line personB in tOther -- only follow branches leading to the same relationship we are testing (= or =) -- So if: AB and BC and C=D and DE then AE must be true if sRelations[pPersV][personB] = pRelation or sRelations[pPersV][personB] = = then if traverseList(personB,pPersX,pRelation) then -- save this data directly for future speed set sRelations[pPersV][pPersX] to pRelation set sRelations[pPersX][pPersV] to pRevRel return true end if end if end repeat return false end traverseList ~ Chris Innanen ~ Nonsanity ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding Challenge
On Fri, Mar 11, 2011 at 2:32 PM, Nonsanity f...@nonsanity.com wrote: On Fri, Mar 11, 2011 at 1:54 PM, Nonsanity f...@nonsanity.com wrote: Try this. I haven't tested, but the logic looks sound enough... Actually, don't try that, try this. That one had flaws this one should fix. (But again, not tested at ALL.) Typo. Replace Rel,Rel with Rel,pRelation in the previous code. ~ Chris Innanen ~ Nonsanity ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding Challenge
You could use getRelationship() as I sent earlier, but it would be a bit clumsy. Easier to test for validity directly, something like (off the top of my head ...) function canItBeValid p1, p2, pRelationship put sample(p1) into p1 put sample(p2) into p2 switch pRelationship case = if p1 is among the lines of gOlder[p2] then return false if p2 is among the lines of gOlder[p1] then return false return true case if p1 = p2 then return false if p1 is among the lines of gOlder[p2] then return false return true case if p1 = p2 then return false if p2 is among the lines of gOlder[p1] then return false return true default ask bad relationship pRelationship return false end switch end canItBeValid but I see from a later email you have something already working, so go with that :-) -- Alex. On 11/03/2011 11:48, Malte Brill wrote: Hi Alex, well what I need to do is to check if the relationship I am wanting to set is valid or not, before I write it to the database. I might not be clear enough. But my goal is not really to check for existing relations, but the validity of the data I am about to enter into the Database. So if there is no relation at all, any relation is valid. Direct relations are clear and indirect relations need to be checked for. Maybe I just dot understand how I would use your script in that case. Sorry for the confusion. Malte ___ use-livecode mailing list use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding Challenge
Hi Malte. Hope I'm not too late to the party :-) Here's some sample code that appears to work on my small sample data. It's not easy to come up with good test data here - nothing obvious could generate realistic test data by program. Summary is 1. deal with all equality cases first. For every set of equal-age names, we use the same name (first one alphabetically) for the 'younger' relationship table. 2. normalize the realtionships (always younger, replace by same-age equivalent 3. for each name, keep two lists - those older and still to be handled, and those older but already dealt with 4. repeatedly, take a name from the first list and try to move it to the second. If this name itself has nothing left on its 'still-to-do' list then we have completely moved this name - remove it from the still-to-do list. This should be reasonably efficient, though there are possible optimizations by keeping back-pointers - so let me know if this is too slow when you start using thousands of names, -- Alex. global gSameAge -- array of those who are the same age global gRelate -- array of direct (i.e. defined) relationships global gOlder -- array containing (one per line) all those who are known older than the key global gOlderStillToDo on c put URL file:~/data.txt into tData put empty into gSameAge put empty into gOlder put empty into gOlderStillToDo -- deal with all the equal age info -- for each group of same-age people, we will use the first alphabetically -- step 1. normalize each individual equality to be alphabetocal -- step 2. sort the set of equality facts to be alphabetical -- step 3. for each subsequent name, store the earliest equal one repeat for each line L in tData if word 2 of L = = then if word 1 of L word 3 of L then put word 1 of L word 3 of L CR after tEqual else put word 3 of L word 1 of L CR after tEqual end if end if end repeat -- sort these to handle cases like a=b and b=d sort lines of tEqual repeat for each line L in tEqual if gSameAge[word 1 of L] is not empty then put gSameAge[word 1 of L] into gSameAge[word 2 of L] else put word 1 of L into gSameAge[word 2 of L] end if end repeat -- 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 end if end repeat -- first the direct relationships repeat for each line L in tUnequal put word 2 of L CR after gOlderStillToDo[word 1 of L] end repeat repeat 1 timeS -- forever, but avoid infinite loops put 0 into tNeedToDoAgain put the keys of gOlderStillToDo into tKeys -- for each one that still has something to do repeat for each line K in tKeys put empty into tNewlyFound put empty into tStillToDo repeat for each line L in gOlderStillToDo[K] if L is not among the keys of gOlderStillToDo then -- add this older one, *and* all names known to be older than it put L CR after gOlder[K] put gOlder[L] CR after tNewlyFound else -- this one hasn't yet been done, so we may need another iteration put L CR after tStillToDo add 1 to tNeedToDoAgain end if end repeat if tStillToDo is empty then delete variable gOlderStillToDo[K] else put tStillToDo into gOlderStillToDo[K] end if repeat for each line L in tNewlyFound if L = K then -- there is a loop in age info - i.e. bad input !! ask loop L K exit to top end if if L is not among the lines gOlder[K] and L is not among the lines of gOlderStillToDo[K] then put L CR after gOlderStillToDo[K] add 1 to tNeedToDoAgain end if end repeat end repeat if tNeedToDoAgain = 0 then exit repeat end repeat repeat for each key K in gOlder put K --- CR after field F put gOlder[K] after field F end repeat end c function sample pA if gSameAge[pA] is not empty then return gSameAge[pA] else return pA end if end sample On 08/03/2011 18:49, 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
Re: Coding Challenge
I'm not sure i understand the problem. given: Paul 3 Peter 6 Joanne 6 fritz 9 Madelaine 15 sort by word 2 of each put lineoffset(paul, theList) - lineoffset (peter) into theCompare if theCompare 0 then --child one is younger else --child 2 is younger end if that should solve all cases, unless they're the same age, which you need to check with a direct comparision (if word 2 of child1 = word 2 of child2 then sameAge)... of course you could as well always use comparisions, and i'm sure you'd think of that yourself. so i really don't understand the question it seems. On 8 Mar 2011, at 14:15, Malte Brill wrote: Hi folks, this is over my head. I have a problem I can not tackle alone, so please let me scream for help... HEELLLP Imagine a group of kids: Paul,Peter,Fritz,Madeleine,Joanne (and any additional number of kids) I want to programmatically test on age relations of those kids: e.g. Peter is older than Paul, Joanne is the same age as Paul. Now I want to be able to test if the statement Joanne is older than Peter (or same age, or younger) are valid or not. I will need to be able to do this for all kids in the group. Any ideas on how to tackle that??? Cheers, Malte ___ use-livecode mailing list use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding Challenge
Malte, are you looking for a general solution to problems such as this: Tom is younger than Rose, but older than Will and Jack, in that order. Rose is younger than Susie, but older than Jack. Jack is younger than Jim. Susie is older than Rose, but younger than Jim. Jim is older than Tom. Who is the oldest? ~ Chris Innanen ~ Nonsanity On Tue, Mar 8, 2011 at 8:15 AM, Malte Brill revolut...@derbrill.de wrote: Hi folks, this is over my head. I have a problem I can not tackle alone, so please let me scream for help... HEELLLP Imagine a group of kids: Paul,Peter,Fritz,Madeleine,Joanne (and any additional number of kids) I want to programmatically test on age relations of those kids: e.g. Peter is older than Paul, Joanne is the same age as Paul. Now I want to be able to test if the statement Joanne is older than Peter (or same age, or younger) are valid or not. I will need to be able to do this for all kids in the group. Any ideas on how to tackle that??? Cheers, Malte ___ use-livecode mailing list use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding Challenge
On Tue, Mar 8, 2011 at 10:07 AM, Nonsanity f...@nonsanity.com wrote: Malte, are you looking for a general solution to problems such as this: Tom is younger than Rose, but older than Will and Jack, in that order. Rose is younger than Susie, but older than Jack. Jack is younger than Jim. Susie is older than Rose, but younger than Jim. Jim is older than Tom. Who is the oldest? ~ Chris Innanen ~ Nonsanity Using that as an example, the steps to get not just the oldest but a complete ordered list is to: 1) Codify all the less-than greater-than pairs and group them in a list all going the same way. I'll pick less-than here. (Names have been reduced to the first letter, except for Jim who is M.) T R W T J T J R W R R S J R J M R S S M T M 2) IF you have enough relationships to determine a complete ordering, then the names missing from each side of the list represent the youngest and oldest. In this case, M is not on the left (younger) side, and J is not on the right (older) side, so Jim is the youngest and Jack is the oldest. 3) Eliminate all pairings that involve the known individuals and see if you have enough information to proceed. (youngest) J ... M (oldest) T R W T [J T] [J R] W R R S [J R] [J M] R S [S M] [T M] 4) Repeat. S is not on the left (younger) side and W is not on the right (older) side, so add them to the ordered list. (youngest) J W ... S M (oldest) T R 5) With only two names remaining, and one conditional, we have enough information to complete the list. (youngest) J W T R S M (oldest) If the data given is not enough to get a complete list, it may be possible to pluck out some slightly more complex relationships (A is older than B IF C is older than D) but it sounds like you need more solid answers. Anyway, that's A general solution to this sort of problem. I don't know if there's a better one or not... I didn't already know this proceedure, I just worked it out when you asked. I only now went back to the web site where I got the sample problem and clicked the answer button. It's Jim. Yeay. Hmmm... Looking back, I think that if you have incomplete data, you can still get a mostly ordered list out of this. If more than one name is missing from the left (younger) side, then you know that those names are the youngest, you just don't know which is younger or older among them. I'd repackage them as a single unit (new letter) and substitute it though the whole list for all the affected names, then try again. In the end, you should have a list with groups of unknown order scattered throughout, but still have an overall list. If further data is presented for the names in those groups, they can be put through this same routine in isolation from the rest of the list. Hope this is what you were looking for! (But it was fun to work out anyway...) ~ Chris Innanen ~ Nonsanity ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding Challenge
Oh! I forgot to add J W to the list when I re-did it in the email. It comes from the in that order phrase below. Without it, there are TWO names missing from the youngest side of the list, so W and J would be grouped together (into X) like so: T R X T X T X R X R R S X R X M R S S M T M And the output of the first iteration would be: (youngest) [J,W] ... M The rest of the solution would proceed as normal. You would end up knowing that Jack and Will are younger than everyone else, but not know which of the two was the youngest. Oh, and any equality statements in the original data (Karen is the same age as Helen) should be substituted for a single variable, grouping them the same way you would a pair of unknowns, like J and W when I left out the one conditional statement. ~ Chris Innanen ~ Nonsanity On Tue, Mar 8, 2011 at 10:41 AM, Nonsanity f...@nonsanity.com wrote: On Tue, Mar 8, 2011 at 10:07 AM, Nonsanity f...@nonsanity.com wrote: Malte, are you looking for a general solution to problems such as this: Tom is younger than Rose, but older than Will and Jack, in that order. Rose is younger than Susie, but older than Jack. Jack is younger than Jim. Susie is older than Rose, but younger than Jim. Jim is older than Tom. Who is the oldest? ~ Chris Innanen ~ Nonsanity Using that as an example, the steps to get not just the oldest but a complete ordered list is to: 1) Codify all the less-than greater-than pairs and group them in a list all going the same way. I'll pick less-than here. (Names have been reduced to the first letter, except for Jim who is M.) T R W T J T J R W R R S J R J M R S S M T M 2) IF you have enough relationships to determine a complete ordering, then the names missing from each side of the list represent the youngest and oldest. In this case, M is not on the left (younger) side, and J is not on the right (older) side, so Jim is the youngest and Jack is the oldest. 3) Eliminate all pairings that involve the known individuals and see if you have enough information to proceed. (youngest) J ... M (oldest) T R W T [J T] [J R] W R R S [J R] [J M] R S [S M] [T M] 4) Repeat. S is not on the left (younger) side and W is not on the right (older) side, so add them to the ordered list. (youngest) J W ... S M (oldest) T R 5) With only two names remaining, and one conditional, we have enough information to complete the list. (youngest) J W T R S M (oldest) If the data given is not enough to get a complete list, it may be possible to pluck out some slightly more complex relationships (A is older than B IF C is older than D) but it sounds like you need more solid answers. Anyway, that's A general solution to this sort of problem. I don't know if there's a better one or not... I didn't already know this proceedure, I just worked it out when you asked. I only now went back to the web site where I got the sample problem and clicked the answer button. It's Jim. Yeay. Hmmm... Looking back, I think that if you have incomplete data, you can still get a mostly ordered list out of this. If more than one name is missing from the left (younger) side, then you know that those names are the youngest, you just don't know which is younger or older among them. I'd repackage them as a single unit (new letter) and substitute it though the whole list for all the affected names, then try again. In the end, you should have a list with groups of unknown order scattered throughout, but still have an overall list. If further data is presented for the names in those groups, they can be put through this same routine in isolation from the rest of the list. Hope this is what you were looking for! (But it was fun to work out anyway...) ~ Chris Innanen ~ Nonsanity ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding Challenge
On Tue, Mar 8, 2011 at 10:59 AM, Nonsanity f...@nonsanity.com wrote: Without it, there are TWO names missing from the youngest side of the list... Correction: ...from the OLDEST side of the list, and therefore are the youngest... Gotta keep things clear in stuff like this. I almost let that slide, but... :) ~ Chris Innanen ~ Nonsanity ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding Challenge
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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding Challenge
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@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding Challenge
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@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@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding Challenge
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@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@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@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding Challenge
Malte, How about something like this: 1) Normalize all of your relations to older than (reverse of younger than) So if you started with: Malte is older than Bjornke Mark is older than Malte Mark is younger than Fred George is younger than Fred You now have these ordered pairs: Malte,Bjornke Mark, Malte Fred,Mark Fred, George Ignore equals relations for now. 2) Combine any places where a name occurs in both the 1st and last items, repeat as necessary: = Malte,Bjornke Fred, Mark, Malte Fred, George = Fred, Mark, Malte, Bjornke Fred, George 4) For any equals relations, simply treat them as aliases in the final analysis. If a name doesn't appear in your list, try all of the aliases because the result will be the same. 5) To answer a question, use each resulting line as a test. Examples: If Person A Person B, then they will appear before them in at least 1 line If Person A Person B, then they will appear after them in at least 1 line If Person A = Person B, then they must not appear on the same line This probably isn't perfect, but maybe a good direction? 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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding Challenge
That's a lot of children. Hmmm... Are you looking to use relative ages instead of actual ages because the entry times (old photographs for example) involve the children at different ages? The entry of all that is going to be the biggest headache, I imagine, as every relationship will require selecting two people. But once the data is input, the method I outlined should give you the results you want. ~ Chris Innanen ~ Nonsanity On Tue, Mar 8, 2011 at 1:49 PM, Malte Brill revolut...@derbrill.de 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@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Coding Challenge
And if you assign a value (a weight) to the relation? 0 or 1 in function if are older or younger, assign the relation value to the person and compare the persons with the relation value or weigth. Salut, Josep -- View this message in context: http://runtime-revolution.278305.n4.nabble.com/Coding-Challenge-tp3341313p3342144.html Sent from the Revolution - User mailing list archive at Nabble.com. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode