Hacker News new | ask | show | jobs
by kadoban 1285 days ago
You can absolutely puzzle out _a_ solution to that problem, it's not just a quiz. It's not even hard, given the context that you know that it's possible to do.

Steps, mostly driven by just basically knowing the goal and that there's not many operations that could possibly help:

"a" "b"

"a+b" "b"

"a+b" "-a"

"b" "-a"

"b" "a"

Then once you have that, you can enumerate the downsides to that, look for more efficient and less error-prone ways to proceed.

1 comments

I'm sorry. That one uses a hidden temp storage for the intermediate calculations.

We were looking for the solution based on XOR which works with only two registers.

We wish you luck with your job search elsewhere.

That's not what someone giving even this poor interview question would answer with. It's also not true.

These interview questions are fairly shit, but they're not _that_ shit, and the people giving them are doing their best.