Two sum: Difference between revisions
Content deleted Content added
m →version 2: added/changed comments and whitespace. |
m →version 2: used a better comment. |
||
Line 2,093: | Line 2,093: | ||
say /* [↓] look for sum of 2 numbers=target*/ |
say /* [↓] look for sum of 2 numbers=target*/ |
||
do a=0 for # /*scan up to the last number in array. */ |
do a=0 for # /*scan up to the last number in array. */ |
||
do b=a+1 to #-1; |
do b=a+1 to #-1; if @.a + @.b\=targ then iterate /*Sum not correct? Skip.*/ |
||
sol= sol + 1 /*bump count of the number of solutions*/ |
sol= sol + 1 /*bump count of the number of solutions*/ |
||
say @solution |
say @solution center( "["right(a, L)',' right(b, L)"]", L+L+5) , |
||
right(@.a, w*4) |
right(@.a, w*4) " + " right(@.b, w) ' = ' targ |
||
end /*b*/ /*show the 2 indices and the summation.*/ |
end /*b*/ /*show the 2 indices and the summation.*/ |
||
end /*a*/ |
end /*a*/ |