Five programming problems every Software Engineer should be able to solve in less than 1 hour
Mark Schonewille
m.schonewille at economy-x-talk.com
Sat May 9 20:31:59 EDT 2015
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
KvK: 50277553
Installer Maker for LiveCode:
http://qery.us/468
Buy my new book "Programming LiveCode for the Real Beginner"
http://qery.us/3fi
LiveCode on Facebook:
https://www.facebook.com/groups/runrev/
On 5/10/2015 02:28, Mark Schonewille wrote:
> 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
> "642,6,4,3;642,6,4,1;642,6,661,4,3;5,50,56;420,42,423;262,26;26,262"
> into myData
> set the itemDel to ";"
> repeat for each item myList in myData
> put myList into myOldList
> set the itemDel to comma
> sort items of myList numeric descending by len(each)
> sort items of myList numeric descending by
> padded(each,len(item 1 of myList))
> replace comma with empty in myList
> put myOldList && myList & cr after myNewData
> set the itemDel to ";"
> end repeat
> return myNewData
> end problem4
>
> function padded theItem,theLength
> set the itemDel to 0
> put 0 into item theLength of myNewItem
> put theItem into char 1 to len(theItem) of myNewItem
> if len(myNewItem) > len(theItem) then add .1 to myNewItem
> return myNewItem
> end padded
>
>
More information about the use-livecode
mailing list