Re: Coding challenge

2013-02-01 Thread Ben Rubinstein
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 re

Re: Coding challenge

2013-01-31 Thread dunbarx
n 31, 2013 4:29 pm Subject: Re: Coding challenge 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 s

Re: Coding challenge

2013-01-31 Thread Mark Wieder
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 th

Re: Coding challenge

2013-01-31 Thread dunbarx
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 To: 'How to use LiveCode' Sent: Thu, Jan 31, 2013 3:02 pm Subject: RE: Coding challenge > From: R

RE: Coding challenge

2013-01-31 Thread Paul D. DeRocco
> 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 practi

Re: Coding challenge

2013-01-31 Thread Dave Cragg
On 31 Jan 2013, at 05:40, Paul D. DeRocco 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 > eleg

Re: Coding challenge

2013-01-31 Thread Mark Wieder
Paul D. DeRocco 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 v

Re: Coding challenge

2013-01-31 Thread J. Landman Gay
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

Re: Coding challenge

2013-01-31 Thread 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 f

Re: Coding challenge

2013-01-31 Thread Robert Sneidar
l. > > > As six pennies. As long as you have a "1", you should be OK. > > > > > Craig Newman > > > > > -Original Message- > From: Paul D. DeRocco > To: 'How to use LiveCode' > Sent: Thu, Jan 31, 2013 12:57 am >

Re: Coding challenge

2013-01-31 Thread dunbarx
value be considered as a candidate. And maybe even lower nextmost ones? Craig. -Original Message- From: Paul D. DeRocco To: 'How to use LiveCode' Sent: Thu, Jan 31, 2013 12:55 pm Subject: RE: Coding challenge > Mark Wieder > > In any of the submitted

Re: Coding challenge

2013-01-31 Thread Robert Sneidar
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 calculati

Re: Coding challenge

2013-01-31 Thread Robert Sneidar
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 r

RE: Coding challenge

2013-01-31 Thread Paul D. DeRocco
> 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+

Re: Coding challenge

2013-01-31 Thread Colin Holgate
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 > > > > > Does

Re: Coding challenge

2013-01-31 Thread dunbarx
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.c

Re: Coding challenge

2013-01-31 Thread dunbarx
as 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 To: use-livecode Sent: Thu, Jan 31, 2013 9:54 am Subject: Re: Coding challenge The question was > Determine the minimum number

Re: Coding challenge

2013-01-31 Thread Mark Wieder
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

Re: Coding challenge

2013-01-31 Thread Colin Holgate
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 subs

Re: Coding challenge

2013-01-31 Thread Alex Tweedly
l.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 To: 'How to use LiveCode' Sent: Thu, Jan 31, 2013 12:57 am Subject: RE: Coding challenge From: Mark Wieder Now how would y

Re: Coding challenge

2013-01-31 Thread dunbarx
Paul. As six pennies. As long as you have a "1", you should be OK. Craig Newman -Original Message- From: Paul D. DeRocco To: 'How to use LiveCode' Sent: Thu, Jan 31, 2013 12:57 am Subject: RE: Coding challenge > From: Mark Wieder > > >

RE: Coding challenge

2013-01-30 Thread Paul D. DeRocco
> 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. >

Re: Coding challenge

2013-01-30 Thread Mark Wieder
Paul- Wednesday, January 30, 2013, 9:40:54 PM, you 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

Re: Coding challenge

2013-01-30 Thread Mark Wieder
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, unsu

RE: Coding challenge

2013-01-30 Thread Paul D. DeRocco
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 Paul

Re: Coding challenge

2013-01-30 Thread dunbarx
Mark. That comma is there for future expansion. Craig -Original Message- From: Mark Wieder To: How to use LiveCode 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 V

Re: Coding challenge

2013-01-30 Thread J. Landman Gay
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 Hy

Re: Coding challenge

2013-01-30 Thread Monte Goulding
On 31/01/2013, at 2:22 PM, Monte Goulding wrote: > It would depend on what's in your wallet ;-) > > On 31/01/2013, at 2:16 PM, Mark Wieder wrote: > >> ...and the xtalk implementation would be... on mouseUp put random(99) into tChange put tChange&cr&makeChange(tChange) end mouseUp fun

Re: Coding challenge

2013-01-30 Thread Mark Wieder
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 tC

Re: Coding challenge

2013-01-30 Thread J. Landman Gay
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.

Re: Coding challenge

2013-01-30 Thread dunbarx
; put tList into fld "change" end makeChange -Original Message- From: J. Landman Gay To: How to use LiveCode 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 mi

Re: Coding challenge

2013-01-30 Thread dunbarx
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 t

Re: Coding challenge

2013-01-30 Thread Mark Wieder
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 >

Re: Coding challenge

2013-01-30 Thread Paul Hibbert
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

Re: Coding challenge

2013-01-30 Thread Mark Wieder
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

Re: Coding challenge

2013-01-30 Thread Mark Wieder
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 ma

Re: Coding challenge

2013-01-30 Thread Mark Wieder
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/

Re: Coding challenge

2013-01-30 Thread J. Landman Gay
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 soluti

Re: Coding challenge

2013-01-30 Thread Terry Judd
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 tC

Re: Coding challenge

2013-01-30 Thread Monte Goulding
It would depend on what's in your wallet ;-) On 31/01/2013, at 2:16 PM, Mark Wieder wrote: > ...and the xtalk implementation would be... -- Monte Goulding M E R Goulding - software development services mergExt - There's an external for that! ___

Re: Coding Challenge

2011-03-12 Thread Nonsanity
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 wrote: > Chris, > > thanks for loo

Re: Coding Challenge

2011-03-12 Thread Jim Ault
Oe dynamic you need ot include is the clue sequence. if 'chris' is ranked 5 in the final configuration, but is ranked 1st until much later, then you need to install the higher ranked names later. If you feed the tree from the top down, the rules won't be as complex, but how would you know the t

Re: Coding Challenge

2011-03-12 Thread Malte Brill
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 whe

Re: Coding Challenge

2011-03-11 Thread Alex Tweedly
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 "="

Re: Coding Challenge

2011-03-11 Thread Nonsanity
On Fri, Mar 11, 2011 at 2:32 PM, Nonsanity wrote: > On Fri, Mar 11, 2011 at 1:54 PM, Nonsanity 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.

Re: Coding Challenge

2011-03-11 Thread Nonsanity
On Fri, Mar 11, 2011 at 1:54 PM, Nonsanity 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 sRel

Re: Coding Challenge

2011-03-11 Thread Nonsanity
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 "="

Re: Coding Challenge

2011-03-11 Thread Nonsanity
I don't think this works... The Iterating function doesn't really iterate. It just does a bit of tire spinning without going anywhere. And gives a wrong result. Let say the array looked like this: [B][A] = > [B][C] = < [B][D] = < [C][E] = < [D][E] = < Which is enough information to determine thi

Re: Coding Challenge

2011-03-11 Thread Malte Brill
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 lo

Re: Coding Challenge

2011-03-11 Thread Malte Brill
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

Re: Coding Challenge

2011-03-11 Thread Alex Tweedly
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

Re: Coding Challenge

2011-03-11 Thread Malte Brill
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

Re: Coding Challenge

2011-03-10 Thread Alex Tweedly
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 ever

Re: Coding Challenge

2011-03-08 Thread JosepM
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

Re: Coding Challenge

2011-03-08 Thread Nonsanity
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 select

Re: Coding Challenge

2011-03-08 Thread Brian Yennie
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,Bjorn

Re: Coding Challenge

2011-03-08 Thread Peter Haworth
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. Th

Re: Coding Challenge

2011-03-08 Thread Bob Sneidar
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 relation

Re: Coding Challenge

2011-03-08 Thread Peter Haworth
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 sma

Re: Coding Challenge

2011-03-08 Thread Malte Brill
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

Re: Coding Challenge

2011-03-08 Thread Nonsanity
On Tue, Mar 8, 2011 at 10:59 AM, Nonsanity 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..

Re: Coding Challenge

2011-03-08 Thread Nonsanity
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

Re: Coding Challenge

2011-03-08 Thread Nonsanity
On Tue, Mar 8, 2011 at 10:07 AM, Nonsanity 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 tha

Re: Coding Challenge

2011-03-08 Thread Nonsanity
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 t

Re: Coding Challenge

2011-03-08 Thread Mark Schonewille
Malte, Create lines with on each line the name and age of the subject (and possibly an id number), sort by age, check the line numbers. What exactly do you want to do with the result? -- Best regards, Mark Schonewille Economy-x-Talk Consulting and Software Engineering Homepage: http://economy

Re: Coding Challenge

2011-03-08 Thread Björnke von Gierke
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, un