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
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
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
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
> 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
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
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
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
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
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
>
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
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
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
> 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+
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
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
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
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
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
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
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
>
> >
> 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.
>
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
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
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
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
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
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
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
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.
;
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
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
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
>
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
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
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
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/
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
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
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!
___
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
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
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
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 "="
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.
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
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 "="
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
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
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
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
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
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
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
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
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
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
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
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
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
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..
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
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
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
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
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
66 matches
Mail list logo