Resistor mesh: Difference between revisions

Content added Content deleted
(Added Phix)
m (→‎{{header|REXX}}: changed some whitespace.)
Line 1,725: Line 1,725:
say ' point B is at (row,col): ' Brow"," Bcol
say ' point B is at (row,col): ' Brow"," Bcol
@.=0; cell.=1
@.=0; cell.=1
do until $<=minVal; v=0
do until $<=minVal; v= 0
@.Arow.Acol= 1 ; cell.Arow.Acol=0
@.Arow.Acol= 1 ; cell.Arow.Acol= 0
@.Brow.Bcol= '-1' ; cell.Brow.Bcol=0
@.Brow.Bcol= '-1' ; cell.Brow.Bcol= 0
$=0
$=0
do i=1 for high; im=i-1; ip=i+1
do i=1 for high; im= i-1; ip= i+1
do j=1 for wide; n=0; v=0
do j=1 for wide; n= 0; v= 0
if i\==1 then do; v=v + @.im.j; n=n+1; end
if i\==1 then do; v= v + @.im.j; n= n+1; end
if j\==1 then do; jm=j-1; v=v + @.i.jm; n=n+1; end
if j\==1 then do; jm= j-1; v= v + @.i.jm; n= n+1; end
if i<high then do; v=v + @.ip.j; n=n+1; end
if i<high then do; v= v + @.ip.j; n= n+1; end
if j<wide then do; jp=j+1; v=v + @.i.jp; n=n+1; end
if j<wide then do; jp= j+1; v= v + @.i.jp; n= n+1; end
v=@.i.j - v/n; #.i.j=v; if cell.i.j then $=$ + v*v
v= @.i.j - v / n; #.i.j= v; if cell.i.j then $= $ + v*v
end /*j*/
end /*j*/
end /*i*/
end /*i*/
Line 1,749: Line 1,749:
exit /*stick a fork in it, we're all done. */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
sides: parse arg row,col; z=0; if row\==1 & row\==high then z=z+2; else z=z+1
sides: parse arg row,col; z=0; if row\==1 & row\==high then z= z+2; else z= z+1
if col\==1 & col\==wide then z=z+2; else z=z+1
if col\==1 & col\==wide then z= z+2; else z= z+1
return z</lang>
return z</lang>
{{out|output|text=&nbsp; when using the default inputs:}}
{{out|output|text=&nbsp; when using the default inputs:}}