scalapuzzlers / scalapuzzlers.github.com

Github Pages behind scalapuzzlers.com
www.scalapuzzlers.com
161 stars 53 forks source link

Adding puzzler 29 ('Double Trouble') #62

Closed demobox closed 11 years ago

demobox commented 11 years ago

Note that, as discussed in the scala-lang thread, this behaviour was changed in 2.10 as part of the fix for SI-5104:

https://github.com/scala/scala/commit/460bbc1276fb4ba83b9bcbdc7f7ba475b352b7c6

So this would unfortunately have to move straight to the archive section, although (again, as pointed out in the thread) there is a nice follow-up puzzler:

val a = Array(1.0, Double.NaN, 2.0) 
util.Sorting.stableSort(a)
println(a.mkString(" "))

prints 1.0 2.0 NaN in 2.9.2 but 1.0 NaN 2.0 in 2.10.0 because Double now violates the assumptions of Ordering.

demobox commented 11 years ago

See https://github.com/scalapuzzlers/scalapuzzlers.github.com/pull/65 for an updated version that is puzzling given the new 2.10.0 behaviour.

demobox commented 11 years ago

@nermin Since we're seeing that a number of people are still using 2.9, how about re-submitting this and adding it to the Archive? We'd obviously choose a different name from https://github.com/scalapuzzlers/scalapuzzlers.github.com/pull/65

nermin commented 11 years ago

Okay, I guess it won't hurt :)