Five programming problems every Software Engineer should be able to solve in less than 1 hour

Geoff Canyon gcanyon at gmail.com
Sun May 10 11:18:10 EDT 2015


On Sun, May 10, 2015 at 5:38 AM, Mark Waddingham <mark at 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
>    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 problem4_pad(each, tLength)
>    replace comma with empty in pList
>    return pList
> end problem4
>

This fails on 43,434 -- it returns 43434, but should return 43443



More information about the use-livecode mailing list