News for hackers. Stuff that matters.
Re:Amazon’s Interview Questions And Why I Don’t Work At Amazon by untitledwiz on Sunday October 20, 2013 @08:55PM (#6582417)
Add them all up, subtract that from the actual sum of 1-250 and voila. Optimization bonus: you don't need to do the second sum, there's a closed form (I don't remember what it is, but I do remember Gauss came up with it as a kid).
Re:Amazon’s Interview Questions And Why I Don’t Work At Amazon by taeric on Sunday October 20, 2013 @08:58PM (#6582439)
Doesn't this only work if you have spaces between the numbers?
Re:Amazon’s Interview Questions And Why I Don’t Work At Amazon by andrewcooke on Sunday October 20, 2013 @09:08PM (#6582500)
no spaces.

but you can get the formula by imagining the numbers as piles of pennies and then completing them to make a square and then splitting down the diagonal

  *
  **
  ***

  *..
  **.
  ***

  \..   \
  *\. + \
  **\   \
where a \ is half a penny. so * = \\

so it's 1/2 * n * n (ie half the square) plus an extra 1/2 for each one on the diagonal.

so it's n * n/2 + n/2 = (n+1) * n/2

Re:Amazon’s Interview Questions And Why I Don’t Work At Amazon by seniorsassycat on Sunday October 20, 2013 @09:01PM (#6582461)
andrewcooke supposed the numbers were not separated by spaces so

1727321173475

could be 1, 72, 73, 211, ... or 17, 27, 32, 117, ... or 172, ...

Re:Amazon’s Interview Questions And Why I Don’t Work At Amazon by cocoflunchy on Sunday October 20, 2013 @09:01PM (#6582464)
n(n+1)/2