31 votes

Why do we practice printing patterns while coding?

Why do we practice printing patterns while coding? Because bugs love to hide in loops. Talk students into using loops to print these patterns and they will create bugs. Tracking down and squishing ...
user avatar
9 votes

Why do we practice printing patterns while coding?

Are these kinds of pattern questions just for fun and to get better at using loops [...] ? Absolutely yes. Practical applications of such patterns nearly don't exist. It's good training for control ...
user avatar
7 votes
Accepted

Using questions from a code-competition website in homework and exams

Whether this is a good plan or not depends on some things, most especially the nature of your students. However, it seems a bit too unstructured. If you have a general mix of student ability it ...
user avatar
  • 35.1k
7 votes

Exercise or example to reinforce idea of functions?

I saw the light at the end of the fiber optic cable as soon as you said that these are students of electronics. There is nothing more modular and encapsulated than that! Software is simply electronics ...
user avatar
6 votes
Accepted

Exercise or example to reinforce idea of functions?

Instead of an example, use a metaphor. Get yourself a frisbee - ultimate disk and two packs of sticky notes. You are the caller of a function. Another person is the function itself. Write a value on ...
user avatar
  • 35.1k
6 votes

Reference request for resource with difficult programming exercises

If he wants to have a blast biting into some very fun and challenging problems, Project Euler is fantastic, and entirely language neutral. He may find that certain problems are out of his grasp until ...
user avatar
  • 31.6k
6 votes

Reference request for resource with difficult programming exercises

Although the question is asking for a book, looking a "Project Euler" mentioned in another answer, I would like to suggest Codewars might be what you are looking for. On codewars you choose ...
user avatar
  • 161
6 votes

Why do we practice printing patterns while coding?

I was skeptical about this as well. Those pictures feel like a cheesy attempt to make programming cool, from an era when that meant ASCII graphics; or the sort of cutsie junk we need to keep the ...
user avatar
5 votes
Accepted

Should I Provide Answers To Exercises?

I post solutions after the due date of an assignment. And usually, I'll go over them in class as well. Two birds... Students get to see at least one working solution, although I try to come up with ...
user avatar
  • 3,029
5 votes

Lambda expressions exercises and practice

One of the interesting things added to java in v8 is functional interfaces. Previously java only matched things up and verified correctness by type (type names). With functional interfaces, java now ...
user avatar
  • 35.1k
5 votes
Accepted

Is it worth to learn to make a MD5-hash cracker?

I have used a similar idea - writing an SHA-1 hash cracker - as a mini-project for students learning Java. These students had previously learned to program in other languages, so they had experience ...
user avatar
  • 519
5 votes

Reference request for resource with difficult programming exercises

The International Olympiad in Informatics is an international competition for gifted young amateur programmers. The tasks from past editions are available online, including detailed problem ...
user avatar
  • 200
4 votes

A meaningful exercise that requires using a destructor

Create an object that creates a new file and writes in to it over several method invocations (not just one). Assure that the object has been deleted before continuing (Make the object go out of scope ...
user avatar
  • 35.1k
4 votes

Should I Provide Answers To Exercises?

To give or not to give, that is the question There are actually several possibilities that reflect how you want the provided solution to be used. For context, I am an instructor at Colorado State ...
user avatar
  • 1,113
4 votes

Should I Provide Answers To Exercises?

Don't provide code dumps. Provide guides that outline the process of solving the problem. Create a function that squares a number passed to it Don't just give out a fully-coded solution. The ...
user avatar
3 votes

Should I Provide Answers To Exercises?

Reading an answer is not the same thing as solving a problem. I think different areas of the brain are engaged. Solving the problem yourself is a stronger reinforcement of the ideas certainly. ...
user avatar
  • 35.1k
3 votes

A meaningful exercise that requires using a destructor

There are 2 good examples of patterns where the destuctor is a key. This way you can teach a couple of useful patterns on the way. RAII - Resource Acquisition Is Initiation Rule of 3/5/0 It's ...
user avatar
3 votes
Accepted

Genetic Algorithm enrichment lesson

Classification problems are reasonable candidates. For instance, I wrote a GA that looked at the mushroom dataset taken from the UCI Machine Learning Repository with the goal of classifying an ...
user avatar
  • 414
3 votes

Best Practices for introductory teaching

I think you have left out two essential elements here. Your first two points leave the students passive consumers. The last is about testing. But there is no guarantee of any learning in between. In ...
user avatar
  • 35.1k
3 votes

Basic OOP practice exercises for inheritance and polymorphism

You could have a hierarchy based on an abstract class or interface Car, with implementations/subclasses for ElectricCar, ...
user avatar
3 votes

Exercise or example to reinforce idea of functions?

Can I craft an exercise ... that would give a dramatically wrong output, e.g. cause the screen to "blow" up if the function print-ed instead of return-ed... [my emphasis] Early in my Python ...
user avatar
  • 824
3 votes
Accepted

Looking for good Master Theorem examples

A famous example is Strassen's matrix multiplication algorithm, whose running time satisfies the recurrence $T(n) = 7T(n/2) + O(n^2)$. A similar example is Karatsuba's algorithm for fast integer ...
user avatar
3 votes
Accepted

Reference request for resource with difficult programming exercises

Disclaimer 1: I haven't seen the book, and I have no idea what exercises it offers. Disclaimer 2: I haven't seen your brother's code. The goal of an easy exercise is to learn how to write the perfect ...
user avatar
  • 442
3 votes
Accepted

What are some good conditional branching excercise scenarios?

There are literally zillions of scenarios. Even before the loops are introduced. For example, Min, max, and clipping a value into an interval. Figure out whether a year is a leap one. Determine if a ...
user avatar
  • 442
2 votes

Basic OOP practice exercises for inheritance and polymorphism

I have used an example of a machine which has a serial number and a state. It can be turned on and off, it can be told to give out its serial number. A ...
user avatar
2 votes
Accepted

Basic OOP practice exercises for inheritance and polymorphism

One example that isn't necessarily exciting but would allow for a lot of class design is a Shape interface. From there let's say you have ...
user avatar
  • 9,032
2 votes

Excel macro recorder exercises

One extremely handy macro is creating names ranges. Start recording Select the range you want to name Press the "create named range" in the "formulas" tab give name stop recording. Voila. This has ...
user avatar
  • 6,227
2 votes

Excel macro recorder exercises

I'll start by adding the exercises I'm currently using, but please don't let this stop you from posting more! Create a macro that inserts a header row. (Story: "Every day I download a csv file. ...
user avatar
  • 1,388
2 votes

Lambda expressions exercises and practice

I think the most critical thing about lambda functions is that they enable the convenient use of map and filter functions on ...
user avatar
  • 121
2 votes
Accepted

Lambda expressions exercises and practice

One idea might be to borrow SQL-related exercises -- find problems asking the reader to come up with some sort of SQL query to find information, and rephrase the problem and ask students to come up ...
user avatar
  • 4,005

Only top scored, non community-wiki answers of a minimum length are eligible