zlacker

[return to "My favorite programming problem to teach: Digit length (2019)"]
1. nicbou+I93[view] [source] 2024-06-06 05:39:07
>>equili+(OP)
Wouldn't len(str(num)) be adequate here? This is a quite literal translation of what the code should be doing: measuring the length of the text representation of a number. The mathematical approach seems a little convoluted, although it serves the purpose of teaching a lesson.
◧◩
2. bittum+1a3[view] [source] 2024-06-06 05:41:54
>>nicbou+I93
At the bottom of the article they mention that this was discouraged because they hadn't covered strings in the course yet
◧◩◪
3. MrJohz+ma3[view] [source] 2024-06-06 05:46:22
>>bittum+1a3
And more importantly, because it sidesteps the interesting pedagogy around edge cases and testing that the instructor is interested in.
◧◩◪◨
4. vsnf+Na3[view] [source] 2024-06-06 05:51:58
>>MrJohz+ma3
The correct solution here is to give credit for the problem to acknowledge genuine clever problem solving, and then offer extra credit for doing it the pedagogical way.
[go to top]