Re:My Favorite Programming Problem to Teach: Digit Length
by FabHK on Monday November 11, 2019 @05:47AM
(#21503701)
That link has a very insightful discussion (and incidentally provides a nice fast correct solution, and use case, for the initial problem!).
Re:My Favorite Programming Problem to Teach: Digit Length
by gpderetta on Monday November 11, 2019 @09:23AM
(#21505027)
Probably the students do not know about big O notation at this point, but requiring a solution that uses at most O(1) additional space would be enough. Then again, automatic bignums in python make it hard to evaluate the space complexity.
That said, I do agree that as stated the problem is a toy. The problem statement could at least motivate the lack of string operations - i.e. pretend you’re the language designer and you’re tasked with implementing str(int) in C. Just saying “don’t do that” isn’t helpful. Gaining an understanding that nothing is magical is useful though.