Skip to main content
removed any ambiguity
Source Link
user100690
user100690

JavaScript (Node.js), 5757 54 bytes

a=>b=>a+`=${b}
${a+a}=${b+b}
${a-=b}=${b=-a}
${a*aa*=a}=`+b*b=`+a

Try it online!Try it online!

How?

There always exists a multiple of \$5\$\$0.5\$ which, when subtracted from each number, creates a pair of the form \$-a = a\$ pair. If \$a-x=c\$, then \$b-(a-x+b)=-c\$, so then if \$a-x+b=x\$, then \$x=\frac{(a+b)}2\$. This might not be an integer, so multiply by 2 beforehand.

-3 bytes thanks to Arnauld.

JavaScript (Node.js), 57 bytes

a=>b=>a+`=${b}
${a+a}=${b+b}
${a-=b}=${b=-a}
${a*a}=`+b*b

Try it online!

How?

There always exists a multiple of \$5\$ which, when subtracted from each number, creates a \$-a = a\$ pair. If \$a-x=c\$, then \$b-(a-x+b)=-c\$, so then if \$a-x+b=x\$, then \$x=\frac{(a+b)}2\$. This might not be an integer, so multiply by 2 beforehand.

JavaScript (Node.js), 57 54 bytes

a=>b=>a+`=${b}
${a+a}=${b+b}
${a-=b}=${-a}
${a*=a}=`+a

Try it online!

How?

There always exists a multiple of \$0.5\$ which, when subtracted from each number, creates a pair of the form \$-a = a\$. If \$a-x=c\$, then \$b-(a-x+b)=-c\$, so then if \$a-x+b=x\$, then \$x=\frac{(a+b)}2\$. This might not be an integer, so multiply by 2 beforehand.

-3 bytes thanks to Arnauld.

added 23 characters in body
Source Link

JavaScript (Node.js), 57 bytes

a=>b=>a+`=${b}
${a+a}=${b+b}
${a-=b}=${b=-a}
${a*a}=`+b*b

Try it online!

How?

There always exists a multiple of .5\$5\$ which, when subtracted from each number, creates a -a = a\$-a = a\$ pair. (ifIf a-x=c\$a-x=c\$, then b-(a-x+b)=-c\$b-(a-x+b)=-c\$, so then if a-x+b=x\$a-x+b=x\$, then x=(a+b)/2\$x=\frac{(a+b)}2\$. This might not be an integer, so multiply by 2 beforehand.

JavaScript (Node.js), 57 bytes

a=>b=>a+`=${b}
${a+a}=${b+b}
${a-=b}=${b=-a}
${a*a}=`+b*b

Try it online!

How?

There always exists a multiple of .5 which, when subtracted from each number, creates a -a = a pair. (if a-x=c, then b-(a-x+b)=-c, so then if a-x+b=x, then x=(a+b)/2. This might not be an integer, so multiply by 2 beforehand.

JavaScript (Node.js), 57 bytes

a=>b=>a+`=${b}
${a+a}=${b+b}
${a-=b}=${b=-a}
${a*a}=`+b*b

Try it online!

How?

There always exists a multiple of \$5\$ which, when subtracted from each number, creates a \$-a = a\$ pair. If \$a-x=c\$, then \$b-(a-x+b)=-c\$, so then if \$a-x+b=x\$, then \$x=\frac{(a+b)}2\$. This might not be an integer, so multiply by 2 beforehand.

Source Link
user100690
user100690

JavaScript (Node.js), 57 bytes

a=>b=>a+`=${b}
${a+a}=${b+b}
${a-=b}=${b=-a}
${a*a}=`+b*b

Try it online!

How?

There always exists a multiple of .5 which, when subtracted from each number, creates a -a = a pair. (if a-x=c, then b-(a-x+b)=-c, so then if a-x+b=x, then x=(a+b)/2. This might not be an integer, so multiply by 2 beforehand.