Intro to Toy Problems

Intro to Toy Problems

Intro to Toy Problems

What is a toy problem?

• An exercise in logic and coding skills

• Usually deals with algorithms and data structures

• Short - usually ~1 hour to complete

• Multiple solutions

    • Ranging from naive to canonical

• Solution may have constraints imposed upon it

    • Time/space complexity

Intro to Toy Problems

Why do toy problems?

• Makes you a better general problem solver

• Familiarizes you with aspects of the target language

• Helps you approach and deconstruct complex problems

• Lets you consider different, possibly more efficient ways of      accomplishing a given task

• Prepares you for tackling real-world software engineering        issues

• Prepares you for technical interviews

Intro to Toy Problems

Strategies for Toy Problems

• Carefully read the description of the problem

    • Exactly what are you expected to accomplish?

• Don't start coding immediately

• Visualize the problem using pen/paper or whiteboard

    • This is especially helpful for complex problems

• Don't panic!

    • Don't start aiming for a perfect solution

    • A naive solution is a great starting point

Intro to Toy Problems

Toy Problems at Moringa School

• Starting tomorrow, you will have a Toy Problem in the morning four days a week every week for the first half of the course.

• You will find each day's toy problem on Github. There will be a central repository that contains all the problems. Make a fork of that repository and then add the central repo as a remote named 'upstream'. When you want the day's new problem, execute: '$ git pull upstream master'

• The day after you do a toy problem (or the following Tuesday), you will have a solution lecture during which one of you will be chosen to present your solution. The class will discuss your solution and look at a canonical solution as well.

Intro to Toy Problems

Let's try one out!

Prompt: "Using Java, write a function that takes a String and returns the reverse of that String. Do not use the StringBuffer or StringBuilder classes."

 

Note: as in many Toy Problems, you will not be able to use any external libraries to achieve your solution, only the language's native features

Made with Slides.com