Talk:Middle three digits: Difference between revisions

Content added Content deleted
Line 10: Line 10:


==C++ entry and generalization to other numbers of digits==
==C++ entry and generalization to other numbers of digits==
The check rejecting the cases where (len % 2 == 0) is only correct if the length is also odd. It's perfectly reasonable to request the middle 2 digits of a 4-digit number, etc. So the correct check is to reject the case where the length of the string does not have the same parity as the number of digits being requested (len % 2 != n % 2). [[User:Markjreed|Markjreed]] 05:13, 5 February 2013 (UTC)
The check rejecting the cases where (len % 2 == 0) is only correct if the number of digits requested is also odd; it's perfectly reasonable to request the middle 2 digits of a 4-digit number, etc. So the correct check is to reject the case where the length of the string does not have the same parity as the number of digits being requested (len % 2 != n % 2). [[User:Markjreed|Markjreed]] 05:13, 5 February 2013 (UTC)


==Musings on the type of the return value==
==Musings on the type of the return value==