Last list item

Revision as of 04:54, 23 October 2021 by CalmoSoft (talk | contribs)

List = [6, 81, 243, 14, 25, 49, 123, 69, 11]
Find two smallest items, summarize them, add to the end of list and delete them.
Last item show on this page.

Last list item is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Task

Ring

<lang ring> see "working..." + nl see "Last item is:" + nl

List = [6,81,243,14,25,49,123,69,11] Temp = []

while true

     Temp = sort(List)
     first = Temp[1]
     second = Temp[2]
     ind1 = find(List,first)
     ind2 = find(List,second)
     del(List,ind2)
     del(List,ind1)
     sum = first + second 
     add(List,sum)
     if len(List) = 1
        exit
     ok

end

see "" + List[1] + nl see "done..." + nl </lang>

Output:
working...
Last item is:
504
done...