zlacker

[return to "My Favorite Programming Problem to Teach: Digit Length"]
1. svnpen+Jm[view] [source] 2019-11-11 03:14:08
>>jstrie+(OP)
> As a result, solutions using strings are disallowed on problem sets and quizzes until they are taught. However, the few students who have prior Python programming experience may be tempted to find digit length without loops using a variant of the following (for our purposes) invalid solution.

Wow. this is one of the reasons I hated school. No programmatic reason what given for why a string solution couldnt be used, only an arbitrary reason. Here students may have knowledge from self teaching or whatever, but they are unallowed to use that knowledge because "reasons".

To any teacher that thinks its a good idea to punish students for thinking outside the box: shame on you. All youre going to end up doing is crushing enthusiasm and/or creating drones. Please dont.

◧◩
2. AlecSc+mL[view] [source] 2019-11-11 09:46:03
>>svnpen+Jm
This problem is a funny one for me and gives me real nostalgia, back to about ten years ago when I was learning to program.

I'd just picked up python and was having so much fun going through the project Euler problems.

I can't remember which question it was for but we had to know the length of an integer. At that point I hadn't learnt about type conversion so had to implement it the way the author wants his students to do it.

I remember fondly as well that I hadn't learnt about the modulo operator and had to implement that by myself as well.

I couldn't believe it when I got the answer and progressed to the forum where others shared their answers and they were doing it on one line with %!

Good times!

[go to top]