Minimal numbers of three lists at same position: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
I deleted it because was duplicate of existing one. - CalmoSoft |
|||
{{Draft task}} |
|||
;Task: |
|||
<br>Let gine three lists: |
|||
<br>list1 = [9,18,27,2,65,43,78,11,2] |
|||
<br>list2 = [2,27,36,1,14,89,25,9,15] |
|||
<br>list3 = [1,45,78,5,11,95,14,25,9] |
|||
<br>Let create minList which contain minimal number of three lists at same position. |
|||
=={{header|Ring}}== |
|||
<lang ring> |
|||
see "working..." + nl |
|||
list1 = [9,18,27,2,65,43,78,11,2] |
|||
list2 = [2,27,36,1,14,89,25,9,15] |
|||
list3 = [1,45,78,5,11,95,14,25,9] |
|||
list = [] |
|||
minList = [] |
|||
len = len(list1) |
|||
for n = 1 to len |
|||
add(minList,list1[n]) |
|||
add(minList,list2[n]) |
|||
add(minList,list3[n]) |
|||
minList = sort(minList) |
|||
min = minList[1] |
|||
add(list,min) |
|||
minList = [] |
|||
next |
|||
showArray(list) |
|||
see nl + "done..." + nl |
|||
func showArray(array) |
|||
txt = "" |
|||
see "[" |
|||
for n = 1 to len(array) |
|||
txt = txt + array[n] + "," |
|||
next |
|||
txt = left(txt,len(txt)-1) |
|||
txt = txt + "]" |
|||
see txt |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
working... |
|||
[1,18,27,1,11,43,14,9,2] |
|||
done... |
|||
</pre> |
Latest revision as of 06:43, 23 November 2021
I deleted it because was duplicate of existing one. - CalmoSoft