zlacker

[return to "My favorite programming problem to teach: Digit length (2019)"]
1. Strila+Qe3[view] [source] 2024-06-06 06:29:57
>>equili+(OP)
It's very strange to me that the teacher would push the students from the correct solution using a loop, towards an incorrect solution using a logarithm. A logarithm could work in a language like C where ints can't get too large, but Python has arbitrary precision integers so any solution using floating point numbers is doomed. For example, the code given in the post returns 16 instead of 15 for 999_999_999_999_999.
◧◩
2. romwel+st3[view] [source] 2024-06-06 08:53:25
>>Strila+Qe3
>It's very strange to me that the teacher would push the students from the correct solution using a loop, towards an incorrect solution using a logarithm

That's because the teacher here is an undergraduate student who has yet to learn from painful experience :)

[go to top]