Get the latest tech news

My favorite programming problem to teach: Digit length (2019)


A function to return the number of digits in an input (natural) number provides many learning opportunities for a new programmer

Though many of the lessons may be obvious to those with software engineering experience, the conclusions therein can take a long time to reach for students new to the discipline, which is why I make a point to discuss them early in the course. This mindset prepares students to learn about contracts and formal methods, topics taught in 15-122 and 15-150 (the following courses in the Carnegie Mellon introductory computer science series). If my job is done correctly, students will leave the small group session understanding that clarifying details about the specification before writing code is the difference between unexpected errors and well-defined behavior.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Digit

Digit

Photo of length

length

Related news:

News photo

Indian insurance startup Go Digit raises $141M from anchor investors ahead of IPO

News photo

Moviecart – Full length color movie and audio cartridges for stock Atari 2600

News photo

Length and thickness of bamboo internodes: a beautiful curve