3 ms·
Partially (that's the perl lvalue solution), but the problem shouldn't be solved by cheating, but by implementing a symbolic logical solver, like computional al
by rurban 8y ago
Partially (that's the perl lvalue solution), but the problem shouldn't be solved by cheating, but by implementing a symbolic logical solver, like computional algebra sytems (Maxima, Sage, ...). To free $x on the left side square both sides.
{ use logic;
sqrt($_) = 12;
print solve($_);
}
=>
$_ = square(12) = 144;
This is usually done by providing prolog-like rules for each and every operation, where many ops could provide more than 1 solution. Then feed them into a solver for more speed. Like with picat or cbmc.
Lisp is perfect for that. With perl it gets hairy, but still should be possible.