Talk:100 doors: Difference between revisions

→‎An observation: make Incorrect Answers a section
m (Forgot to sign, duh!)
(→‎An observation: make Incorrect Answers a section)
Line 1:
== Incorrect answers ==
Some of the "solutions" given are incorrect. This problem is also a great example of the "Fence Post" condition often missed by programmers. Look over the solutions and ask yourself if the 100th door is shown to be open or closed.
: Yes -- because the doors in the problem are described with counting numbers and not zero-indexed, there are multiple incorrect solutions with the classic [https://en.wikipedia.org/wiki/Off-by-one_error#Fencepost_error fencepost error], listing 1 (not 0) but omitting 100. There wrong answers include Raku, SuperCollider, and Ursala. [[User:Jeremydouglass|Jeremydouglass]] ([[User talk:Jeremydouglass|talk]]) 00:35, 18 April 2020 (UTC)
----
== An observation ==
An observation: You're actually making 101 passes. 100 mutative, and one for reading the final state. I'm wondering if the wording of the task should be changed, as no way of reporting the final state within the first 100 passes immediately comes to mind. --[[User:Short Circuit|Short Circuit]] 00:14, 7 October 2007 (MDT)
Line 9 ⟶ 13:
::: Integer factors of 5 -> [1, 5], Integer factors of 4 -> [1, 2, 4] (The integer square root gives the list an odd length - other factors are always paired with their matching quotients) [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 07:59, 8 September 2016 (UTC)
----
 
Some of the "solutions" given are incorrect. This problem is also a great example of the "Fence Post" condition often missed by programmers. Look over the solutions and ask yourself if the 100th door is shown to be open or closed.
----
== Optimized Examples ==
Somone just added a Python example which exploits the observation (noted in the preceding discussion here) that perfect squares are the only "open" doors after following this algorithm. That's fair enough, I guess. However, it suggests that similarly optimized implementations should be shown for all languages in which they are relevant (to offer a fair comparison). [[User:JimD|JimD]] 16:02, 15 October 2007 (MDT)