News for hackers. Stuff that matters.
Re:Ask HN: What are your favorite code problems to give whil... by pdiddy on Saturday June 13, 2015 @08:36AM (#9710816)
Another way is to just use subtraction:

  x = x + y
  y = x - y
  x = x - y
I originally learned about this while preparing for some interviews.

The funny thing, I find, is that in Python you can simply do this:

  x, y = 5, 10
  x, y = y, x
I was asked this question in an interview and I responded that you can do this. His response: "Python is weird."

There are no comments on this comment yet.