--
View this message in context:
http://runtime-revolution.278305.n4.nabble.com/New-Coding-Challenge-added-tp4696094p4696104.html
Sent from the Revolution - User mailing list archive at Nabble.com.
___
use-livecode mailing list
use-livecode
free 15GB space now:
>> Get Copy
>>
>>
>> Script editor Themer for LC http://2108.co.uk
>>
>> PointandSee is a FREE simple but full featured under cursor colour picker /
>> finder.
>> http://www.pointandsee.co.uk - made with LiveCode
>&
space now:
Get Copy
Script editor Themer for LC http://2108.co.uk
PointandSee is a FREE simple but full featured under cursor colour picker /
finder.
http://www.pointandsee.co.uk - made with LiveCode
--
View this message in context:
http://runtime-revolution.278305.n4.nabble.com/New-Coding
e keys of tAPrime into tt
sort lines of tt numeric
put "and they are" & CR & tt after fld "F"
end mouseUp
Alex
On 06/09/2015 20:42, AndyP wrote:
I've added a new question to the LiveCode coding challenge section of my
site.
Determine Pi from an image of a cir
I've added a new question to the LiveCode coding challenge section of my
site.
Determine Pi from an image of a circle
http://2108.co.uk/questions/ <http://2108.co.uk/questions/>
There has been 1 partial solution to the previous question
Primes between 20 and 700
Anyone feel up to imp
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
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
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
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
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
.
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
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
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
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
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
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
. 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
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
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
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
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
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
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
: 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
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
-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
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...
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!
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
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
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)
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 -
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
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
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
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
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
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 |
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
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
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
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
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
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,
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
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:
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
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
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
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
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
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,
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 =
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
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:
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
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
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
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
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
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
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
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
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.
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
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
/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
67 matches
Mail list logo