Lessons

Introduction to Programming
3. Problem Solving

By writing code, you can instruct computers to solve problems – both simple and complex – much faster than a human can!

An example could be that you wanted to know how often a specific word appears in a book. If you wanted to do this yourself, you could read the book from start to finish and draw a line each time the given word appears. For humans, this would be a very slow process, and there is a high chance of error along the way. A computer, on the other hand, can do this in a split second – here, for example, are the number of times each of these 10 names appear in the Lord of the Rings trilogy:

NameAmount
Frodo1747
Gandalf1168
Sam1118
Aragorn677
Gollum456
Gimli364
Legolas321
Boromir241
Sauron119
Arwen17
The number of times the names appear in the books has been found using the Python programming language. It took just 0.56 seconds for the computer to calculate this.

Computers are therefore good at executing many instructions very quickly - but, given our book example, if instead you wanted to know who was the author of the book, then the computer would not be able to give the answer without first instructing it by writing additional code. In this way, computers are fantastically good at following instructions, but not so good at coming up with a solution themselves.

Of course, this was just a small example of how computers can be programmed to solve problems, but with larger amounts of code, it is possible to build huge IT systems that can help cover all sorts of needs – e.g. navigating a single person from A to B, or managing the payment of taxes for an entire nation’s population.