Equilibrium index: Difference between revisions
Added BASIC256
(→{{header|AppleScript}}: Added straightforward solution.) |
(Added BASIC256) |
||
Line 697:
indices: 1 2 3 4 5 6 7
</pre>
=={{header|BASIC256}}==
{{trans|Ring}}
<syntaxhighlight lang="vb">arraybase 1
dim list = {-7, 1, 5, 2, -4, 3, 0}
print "equilibrium indices are : "; equilibrium(list)
end
function equilibrium (l)
r = 0: s = 0
e$ = ""
for n = 1 to l[?]
s += l[n]
next
for i = 1 to l[?]
if r = s - r - l[i] then e$ += string(i-1) + " "
r += l[i]
next
e$ = left(e$, length(e$)-1)
return e$
end function</syntaxhighlight>
{{out}}
<pre>The equilibrium indices are : 3 6</pre>
=={{header|Batch File}}==
|