All,
This has been very interesting.
Based on what I’ve seen in this discussion and info from reading the list for
several years, LiveCode has difficulty with very large numbers. So, that is why
you can simply do this for Problem 3. Correct?
function ShowTheFirst100Fibonacci
local
In any case, I thought they were interesting so I gave it a shot. I
finished in something like 40 minutes, but I think some of my solutions
are
more expedient than I would like.
Indeed - the problems themselves are quite interesting - here are my
solutions:
PROBLEM 1
function
True. But to be fair, this is not a problem specific to LiveCode. It's
a generic problem in any programming language - eventually you will
run into the limits of the math library and the limits of the
processor. The limits aren't always immediately obvious, and some
trickery is then necessary to
On Sat, May 9, 2015 at 7:01 PM, Geoff Canyon gcan...@gmail.com wrote:
Yeah, I'm now trying to salvage my padding solution, which is better than
the padding solutions he gave on the site, but still wrong.
Okay, I think this works. It pads with the first character, which covers
most cases, and
I rewrote the function to take arbitrary arguments for the list of numbers
and the target value, and then took advantage of the fact that char 0 of
+- is empty:
function problem5 S,T
local tResults
local countLessOne
local tScheme
local tSum
split S using comma
put (item 2 of
On 05/10/2015 04:51 AM, Randy Hengst wrote:
Based on what I’ve seen in this discussion and info from reading the list for
several years, LiveCode has difficulty with very large numbers.
True. But to be fair, this is not a problem specific to LiveCode. It's a
generic problem in any
On Sun, May 10, 2015 at 5:38 AM, Mark Waddingham m...@livecode.com wrote:
function problem4_pad pItem, pLength
repeat until the length of pItem is pLength
put char 1 of pItem after pItem
end repeat
return pItem
end problem4_pad
function problem4 pList
local tLength
On Sun, May 10, 2015 at 5:38 AM, Mark Waddingham m...@livecode.com wrote:
PROBLEM 5
At first sight this one seems 'scary' but in actual fact the
number of combinations is actually quite small (3^8) and you
can get them by counting from 0 to 3^8 in ternery and padding
function problem4 pList
local tLength
put 0 into tLength
repeat for each item tItem in pList
put max(the number of chars in tItem, tLength) into tLength
end repeat
sort items of pList ascending numeric by the number of chars in
each
sort items of pList descending text by
On Sun, May 10, 2015 at 10:41 AM, Mark Waddingham m...@livecode.com wrote:
put item (char j of tScheme + 1) of ,+,- after tSum
On Sun, May 10, 2015 at 10:42 AM, Geoff Canyon gcan...@gmail.com wrote:
put S[j] char (char j of tScheme) of +- after tSum
Great minds think
Based on what I’ve seen in this discussion and info from reading the
list for several years, LiveCode has difficulty with very large
numbers. So, that is why you can simply do this for Problem 3.
Correct?
function ShowTheFirst100Fibonacci
local tTheFirst100Fibonacci
put 0,1, into
I thought briefly about doing this but it didn't gel in my mind as
quickly
as the substitution method I used. I quite like how this turned out!
I realized after posting my versions that my version of problem5 could
be even more succinct code-wise:
function problem5
local tResults
On 2015-05-10 17:42, Geoff Canyon wrote:
I rewrote the function to take arbitrary arguments for the list of
numbers
and the target value, and then took advantage of the fact that char 0
of
+- is empty:
That's neat - I wonder what the limits in terms of tractable computation
the approach has
On Sun, May 10, 2015 at 12:26 PM, Mark Wieder mwie...@ahsoftware.net
wrote:
On 05/10/2015 04:51 AM, Randy Hengst wrote:
Based on what I’ve seen in this discussion and info from reading the list
for several years, LiveCode has difficulty with very large numbers.
True. But to be fair, this
Problem 5
Write a program that outputs all possibilities to put + or - or nothing
between the numbers 1, 2, ..., 9 (in this order) such that the result is
always 100. For example: 1 + 2 + 34 – 5 + 67 – 8 + 9 = 100.
function sumPermute S,T
repeat
put offset(,,line 1 of S) into F
Problem 4
Write a function that given a list of non negative integers, arranges them
such that they form the largest possible number. For example, given [50, 2,
1, 9], the largest formed number is 95021.
Again, not enough test cases, and in this case his initial solution failed
when tested more
It looks like this also doesn't solve it. Perhaps getting all
combinations and taking the maximum is the only right solution?
--
Best regards,
Mark Schonewille
Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
Most of those (and especially #5) are ones that I think would look much
nicer in LC than in most other languages.
On Sat, May 9, 2015 at 8:31 PM, Mark Schonewille
m.schonewi...@economy-x-talk.com wrote:
It looks like this also doesn't solve it. Perhaps getting all combinations
and taking the
Problem 2
Write a function that combines two lists by alternatingly taking elements.
For example: given the two lists [a, b, c] and [1, 2, 3], the function
should return [a, 1, b, 2, c, 3].
function interleave X,Y
split X using comma
split Y using comma
repeat with i = 1 to max(item 2
Fibonacci calculator that won’t overflow.
Here’s one, I think there were others. The script is in the GO button.
Copy into your message box:
go url http://sysoper0.com/calcFibs.livecode”
.Jerry
On May 9, 2015, at 5:12 PM, Jerry Jensen j...@jhj.com wrote:
We went through this a while ago, I
Ah k. Yep. don't do it that way.
On Sat, May 9, 2015 at 5:08 PM, Mike Bonner bonnm...@gmail.com wrote:
Number 4 is cool actually, but I wonder if there are reasons NOT to do it
the way I'm doing it.
Basically, I sort the lines of the list, descending, as text rather than
numeric, then
On Sat, May 9, 2015 at 5:33 PM, Mike Bonner bonnm...@gmail.com wrote:
What is the recursion limit?
As far as I know it's a memory thing, so there's no set depth. I could be
wrong.
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please
On 05/09/2015 05:12 PM, Jerry Jensen wrote:
We went through this a while ago, I think a challenge forwarded by Mark Wieder.
The problem is that integers overflow and start giving wrong answers part way
to 100. I forget the exact place it happens.
I wrote a few that did it the hard way
Problem 1
Write three functions that compute the sum of the numbers in a given list
using a for-loop, a while-loop, and recursion.
Note that he doesn't provide any test cases, so for each problem I provided
my own in a field, and then called the functions for each line in the test
field, putting
Problem 3
Write a function that computes the list of the first 100 Fibonacci numbers.
By definition, the first two numbers in the Fibonacci sequence are 0 and 1,
and each subsequent number is the sum of the previous two. As an example,
here are the first 10 Fibonnaci numbers: 0, 1, 1, 2, 3, 5, 8,
Hi,
I think this should be something like this (below). Mind line wraps,
especially in the solution for problem 5.
My solution for problem 5 is much easier but also less elegant than the
Java solution on the website. If anyone has better (faster or easier)
solutions, especially for problem
To do number 4, it seems that:
first find digit one. Easy enough. Then with every item that starts with
that digit, see if there is a singleton. If there is NOT a singleton, move
to digit 2 of all numbers that start with that number. If there is a
singleton, you must check second digits that
4's another one that I think would look a lot nicer in LC than in most
other languages.
On Sat, May 9, 2015 at 9:44 PM, Mike Kerner mikeker...@roadrunner.com
wrote:
Most of those (and especially #5) are ones that I think would look much
nicer in LC than in most other languages.
On Sat, May
What is the recursion limit? I decided to do a speed test on larger lists,
and strangely, if I have a list that is 704 lines (I used lines rather than
items) things work fine. As soon as I hit 705, I get the following:
executing at 4:30:55 PM
Type Function: error in function handler
Object
You're right, Geoff. Apparently, not as easy as I thought, but that
makes it more interesting.
--
Best regards,
Mark Schonewille
Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553
Installer Maker
On Sat, May 9, 2015 at 6:51 PM, Geoff Canyon gcan...@gmail.com wrote:
function sumPermute S,T
repeat
put offset(,,line 1 of S) into F
put F into fld 1
wait 0 ticks
if F = 0 then exit repeat
put empty into newS
repeat with i = 1 to 3
put
On Sat, May 9, 2015 at 6:34 PM, Mark Schonewille
m.schonewi...@economy-x-talk.com wrote:
function problem4
put 50,2,1,9 into myList
sort items of myList numeric descending by char 1 of each
replace comma with empty in myList
return myList
end problem4
Doesn't work on
Number 4 is cool actually, but I wonder if there are reasons NOT to do it
the way I'm doing it.
Basically, I sort the lines of the list, descending, as text rather than
numeric, then replace cr with empty.
function genLargest pList
sort lines of pList descending
replace cr with empty in
We went through this a while ago, I think a challenge forwarded by Mark Wieder.
The problem is that integers overflow and start giving wrong answers part way
to 100. I forget the exact place it happens.
I wrote a few that did it the hard way (character by character arithmetic) -
I’ll see if I
On Sat, May 9, 2015 at 7:12 PM, Jerry Jensen j...@jhj.com wrote:
We went through this a while ago, I think a challenge forwarded by Mark
Wieder. The problem is that integers overflow and start giving wrong
answers part way to 100. I forget the exact place it happens.
I wrote a few that did
On Sat, May 9, 2015 at 6:59 PM, Mark Schonewille
m.schonewi...@economy-x-talk.com wrote:
Apparently, not as easy as I thought, but that makes it more interesting.
Yeah, I'm now trying to salvage my padding solution, which is better than
the padding solutions he gave on the site, but still
Geoff,
There's my new attempt. I haven't tested it thoroughly, but I'm leaving
it at this for tonight.
I'm padding the numbers now, but if the number is padded, I give it an
advantage while sorting.
// OK, not /that/ easy.
function problem4
put
37 matches
Mail list logo