News for hackers. Stuff that matters.
Re:My Favorite Programming Problem to Teach: Digit Length by hechang1997 on Sunday November 10, 2019 @11:07PM (#21502064)
I don't know about this. This feels like cheating rather than thinking outside of the box. Like when you ask a student to implement a vector in C++, instead of writing the code the student makes a wrapper around std::vector. Internally, `str` probably also use some equivalent of the naive solution implemented somewhere to convert a integer to its decimal string.
Re:My Favorite Programming Problem to Teach: Digit Length by kadoban on Monday November 11, 2019 @03:14AM (#21503003)
Using math.log10 seems at least as cheating to me. (though to be clear, I'd accept both if it were me)