<p>Let's see if I can answer the questions head on here. </p>

<p><em>Should I provide answers to the exercises?</em></p>

<p>Yes. programming is not like mathematics, although they are closely related. They are multiple ways to achieve the same results. Some students appreciate when they are provided with the expected answer.</p>

<p><em>If so should I include them as a part of the document with the exercises or as a separate document?</em></p>

<p>Separate document would be better. There are a lot of students who dont want to be treated with holding hands. They can easily ignore the separate document while those who need it can look at it. </p>

CC BY-SA 3.0
2018-03-24T06:40:18.073Z
2018-03-24T06:40:18.073Z
Jay
<p>I post solutions after the due date of an assignment. And usually, I'll go over them in class as well. </p>

<p>Two birds...</p>

<ol>
<li><p>Students get to see at least one working solution, although I try to come up with several. </p></li>
<li><p>Posting the solution serves as a good block to students asking to turn in assignments late. They'll understand pretty well that they can't turn it in late after I've already posted solutions.</p></li>
</ol>

<p>I've been trying this year to make videos of me working through the problems. Sometimes they'll be screencasts of me working through the problem in front of the class. Sometimes they'll be a little more scripted and recorded when there aren't students listening. Usually it's the shorter problems where I'll just record myself during class and the longer ones that I script out a bit. </p>

<p>Another activity I like is to do code reviews. I'll screen shot several student submitted solutions and we'll go over them anonymously. I'll include a couple that are really good solutions. But, better than that, I'll also include a few that are really close but not quite a working solution. </p>

<p>On some assignments, especially those that are a little more difficult, I'll provide a pseudocode algorithm with the assignment as a bit of a cheat sheet. Nothing that can be just typed in, but sometimes students need a little bit of a nudge in the right direction. </p>

CC BY-SA 3.0
2018-03-17T14:47:17.380Z
2018-03-18T15:59:37.240Z
2018-03-18T15:59:37.240Z
Ryan Nutt
<p>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. </p>

<p>Frustration is a mind killer. Students shouldn't be frustrated when they are trying to learn and as novices they have few tools for problem solving. </p>

<p>So, to resolve the dilemma, yes, make answers available, but not in the same document and not at the same time. One way is to provide answers only when asked, and after some assurance that the student has spent some mental effort on the exercise. If an exercise is given on Monday, don't provide answers until Wednesday, for example, or some variation on that. </p>

<p>If the size of your student group isn't too large you could give out answers only one-to-one on personal request. You could examine the student solution ideas to dispel any misconceptions. If you get a lot of requests you may need to change your teaching a bit, so that the exercise becomes more natural. </p>

<p>Another option, and this one for when your student numbers are too large to engage individually, is to provide answers (after an interval) for only half of the exercises and assure that the ones that are not answered by you cover the same concepts as those you do answer. </p>

<p>A third option is to provide an additional exercise on the same topic with any answer for a given exercise. Give the student a way to exercise the grokking part of the brain, not just the reading part. </p>

CC BY-SA 3.0
2018-03-17T00:45:11.337Z
I don't know what the grokking part of the brain is, but maybe that's what I'm doing too?, see my answer below.
Java Jive
CC BY-SA 3.0
2018-03-16T20:26:44.780Z
2018-03-16T20:26:44.780Z
Buffy
<h2>To give or not to give, that is the question</h2>

<p>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 University and I am discussing assignments that students
might encounter in the first two to three years (not CS1).</p>

<h2>Don't ever give the students solutions</h2>

<p>The motivation for this approach
   is that one can reuse the assignment in the future without worrying about
   a "new" student getting a solution from the past. Although this seems
   logical, a colleague of mine scours the web for postings of his assignments.
   He developed a nice automated tool to do this for him.
   He says that he finds a significant portion (~40%) have been posted, often to
   sites like <a href="http://www.chegg.com" rel="nofollow noreferrer">http://www.chegg.com</a>  Thus, if an assignment has ever been
   posted on the web, it will be there forever. Even if it is not on the web,
   a solution from a "friend" (who did the same assignment previously) may be
   available. My take is that cheaters will cheat.</p>

<p>I encourage students to look for help on the web. If they find help, I ask that they cite the link in their code. This way they can go back to what they found helpful without repeating the search that got them to this information. By citing a reference, you are declaring that your work is <strong>based</strong> on code you found elsewhere and are giving credit to the author. But, I also say that in using the code, you are taking responsibility for its correctness. You cannot say "<em>It is not my fault the code I copied from the web doesn't work!</em>".</p>

<h2>Supply a reference implementation to the student</h2>

<p>This can be done at different times, for different purposes.</p>

<ul>
<li><p><strong>Supply a reference implementation in "object" code</strong> (an executable). 
This may be done
  when the assignment is posted. The motivation of this approach is to   give       the student an "oracle" that they can test against. Here you are
  emphasizing "testing" in that the student must figure out various
  test cases and then compare the results of their code to that of
  the "oracle". This can also be viewed as a means of resolving
  ambiguities in the assignment. If two things in the specification
  may be in conflict, the student must make the same choice as the "oracle".</p>

<p>This is fine for "compiled" languages, but does not work for
  scripting languages. If one is really paranoid about Java de-compilers,
  run the reference code through an obfuscater. The student may be able to
  "de-compile" it back to source, but the source won't look anything like
  code a human would write.</p></li>
<li><p><strong>Supply a reference implementation in "object" code after the due date.</strong>
  Then allow students to gain back points by fixing their implementation.
  This emphasizes the requirement of a professional to get the job done
  correctly. If you hire someone to paint your house, and they only
  complete 75% of the job, they cannot expect to be paid with a "C"
  grade. You want the entire house painted, and will only pay at that time.
  When I was in engineering school (a long time ago, with small class
  sizes), our assignments were marked C&amp;R (correct and return). The
  assignment was not complete until you had the correct answer and
  demonstrated how you got it.</p></li>
<li><p><strong>Supply a reference implementation in "source" code after the due date.</strong>
  Here you are providing the student with a "master work" that the
  student may study and learn how you (the master) decomposed the
  specification and translated it to code. This forces the student to
  read code and create a mental model of how this implementation works.
  In industry, this is a normal part of most projects. You have to
  understand how the code (which you did not write) works before you can fix/extend it. You can become a much better programmer by studying other's code and understanding how they wrote the code.</p>

<p>For small assignments, I often present my solution by projecting it onto
  the screen from my laptop and reviewing it in class. The students may
  use their cell phones and snap pictures as I discuss my solution. I only
  do this when the review will fit in a single lecture or less. I do not
  spend class time reviewing every assignment.</p>

<p>For larger assignments, you may choose to provide the reference
  implementation via a link the students can download and do with
  as they please. If a "new" student submits this solution when
  you reuse the assignment, you may catch this by using
  <a href="https://theory.stanford.edu/~aiken/moss/" rel="nofollow noreferrer">MOSS</a> to catch plagiarism.
  This is what I do for my larger assignments.</p>

<p>There is one slight alternative to giving out the source directly.
  My colleague (mentioned above) wrote a program called "shadow" which
  turns a text document <a href="https://www.cs.colostate.edu/~fsieker/misc/HelloWorld.java" rel="nofollow noreferrer">your source code</a> into an HTML page. When
  you view the HTML page, you "see" the source and can read it to
  your hearts content. However, if you try and copy/paste it, you
  get a ton of obfuscating HTML code with the text <a href="https://www.cs.colostate.edu/~fsieker/misc/HelloWorld.html" rel="nofollow noreferrer">"hidden"</a> in it.
  Then only way to recover the original text is to type it in (or reverse
  engineer the obfuscation code). His theory is "<em>If you can reverse
  engineer this obfuscation, you don't need to be taking this class</em>".
  The two links in this paragraph show a HelloWorld.java in both forms.</p></li>
</ul>

<p>My personal opinion is that the more code students <strong>read</strong>, the more proficient they will become. Thus, I tend to provide (or at least discuss) my solution to assignments with the students.</p>

CC BY-SA 3.0
2018-03-23T03:44:11.883Z
This is a gorgeous answer, and well-deliniated. I know I've said this before, but I really hope we get to hear more from you.
Ben I.
CC BY-SA 3.0
2018-03-23T04:12:28.600Z
I always love to read things from the _voice of experience_. I second Ben I. in hoping to see more of your work here.
Gypsy Spellweaver
CC BY-SA 3.0
2018-03-22T22:18:19.790Z
2018-03-23T19:50:01.590Z
2018-03-23T19:50:01.590Z
Fritz Sieker
<p>Don't provide code dumps. Provide guides that outline <a href="http://happycoding.io/tutorials/how-to/program" rel="nofollow noreferrer">the process</a> of solving the problem.</p>

<blockquote>
  <p>Create a function that squares a number passed to it</p>
</blockquote>

<p>Don't just give out a fully-coded solution. The answer to this question is not as simple as regurgitating the syntax. It's a process of breaking the question down into smaller steps and taking those steps on one at a time.</p>

<p>It might start like this:</p>

<blockquote>
  <p>When you encounter a question like this, you might start by breaking
  it down into its individual parts.</p>
  
  <ul>
  <li>We know we need to create a function.</li>
  <li>We know the function needs to take a numeric argument.</li>
  <li>We know the function should return the square of the number passed into it.</li>
  </ul>
</blockquote>

<p>And if the students are writing and running the code, it might continue like this:</p>

<blockquote>
  <p>Now that we have these steps written down, we can start implementing
  them one at a time. Let's start by creating a function:</p>

<pre><code>public void square(){
  System.out.println("here");
}
</code></pre>
  
  <p>We might run this function to double-check that it's working how we
  expected. Next let's add an argument:</p>

<pre><code>public void square(int number){
  System.out.println("number: " + number);
}
</code></pre>
  
  <p>Finally, let's add a return type to the function and return the square
  of the number:</p>

<pre><code>public int square(int number){
  return number * number;
}
</code></pre>
</blockquote>

<p>Or if students are writing their code down on paper, it might look like this:</p>

<blockquote>
  <p>Start by writing the function definition. We know it needs a numeric
  return type and that it should take a numeric argument:</p>

<pre><code>public int square(int number){
</code></pre>
  
  <p>Next, we need to create the square of the number:</p>

<pre><code>  int numberSquared = number * number;
</code></pre>
  
  <p>Finally, we need to return this value:</p>

<pre><code>return numberSquared;
</code></pre>
  
  <p>Putting it all together, it looks like this:</p>

<pre><code>public int square(int number){
  int numberSquared = number * number;
  return numberSquared;
}
</code></pre>
</blockquote>

<p>Just giving out a full code solution doesn't really help with the actual process of writing code, which is what you're actually teaching.</p>

CC BY-SA 3.0
2018-03-19T12:38:01.770Z
I'm not discussing code dumps.  I'm discussing giving the students one possible answer to the exercise I've given them.  While I appreciate all the effort you put in to preparing your answer you've sort of misread my question.
Onorio Catenacci
CC BY-SA 3.0
2018-03-19T16:12:15.587Z
@OnorioCatenacci And I believe you've misread my answer. By "code dump" I simply mean handing them a code solution without any explanation. The point I'm making in this answer is that the code is the least important part. The most important part is outlining **the process** of coming up with an answer in the first place.
Kevin Workman
CC BY-SA 3.0
2018-03-16T21:02:56.180Z
2018-03-16T21:02:56.180Z
Kevin Workman
<p>I think this answer is a little different, please remand me if not - I provide an <em>algorithm</em> with my coding assignments, and I almost always have code I can point to in their notes or previous assignments that is exactly what they need to fill in the algorithm.  First I give a general description of the problem: </p>

<blockquote>
  <p>Create a Windows forms application named <strong>Squares</strong> with a text box,
  a button,  and a label.  When the user enters a number in the text box
  and presses the button, get the number, square it, and write the
  square to the label.  Write a  function to take the number and return
  the square.  Be sure you handle invalid input.</p>
</blockquote>

<p>If that's all they need to read, they can go from there.  If they need to read further, then what follows <em>in the same document</em> is the step by step algorithm, but not code.  If they get stuck in the algorithm, on, for example, a line that says:</p>

<blockquote>
  <p>Declare an integer variable to hold the value from the text box.</p>
</blockquote>

<p>Then I point them to their notes for a myriad of examples for how to declare an integer variable, or even to a previous, simpler exercise where they had to do it.  In other words, I make them find the answer themselves.  This gives them a greater feeling of accomplishment and also makes them less dependent upon me.</p>

<p>I find that by giving them this "scaffolding", I rarely have to provide an actual code solution, but will upon request.</p>

CC BY-SA 3.0
2018-03-17T00:44:17.620Z
2018-03-17T00:44:17.620Z
Java Jive
<p>I'm preparing some exercises to introduce software developers who have no experience with Scheme to the language. Part of the exercises are simple things like:</p>

<p><code>Create a function that squares a number passed to it</code></p>

<p>I've been sort of debating whether or not I should include answers to the exercises or if I should provide them as a separate document.  I think it would help the students to be able to examine one approach to doing this--a reference implementation as it were.  But I do have some concerns about the students not even trying to do the exercise themselves before looking at the answers. </p>

<p>Should I provide answers to the exercises? If so should I include them as a part of the document with the exercises or as a separate document?</p>

<p>I realize this is a vague question so if I need to narrow it please just tell me. I can't think of a less generic way to ask the question right now.</p>

CC BY-SA 3.0
2018-03-16T18:43:24.053Z
No worries, this is a great question. And I'm very interested to see the answers, because I've struggled with the same thing.
Ben I.
<curriculum-design><exercises>
Should I Provide Answers To Exercises?
# Should I Provide Answers To Exercises?

(Asked by: username_0 on 2018-03-16)

I'm preparing some exercises to introduce software developers who have no experience with Scheme to the language. Part of the exercises are simple things like:

`Create a function that squares a number passed to it`

I've been sort of debating whether or not I should include answers to the exercises or if I should provide them as a separate document. I think it would help the students to be able to examine one approach to doing this--a reference implementation as it were. But I do have some concerns about the students not even trying to do the exercise themselves before looking at the answers.

Should I provide answers to the exercises? If so should I include them as a part of the document with the exercises or as a separate document?

I realize this is a vague question so if I need to narrow it please just tell me. I can't think of a less generic way to ask the question right now.

**Tags:** curriculum-design, exercises

> **Comments:**
> **username_1**: No worries, this is a great question. And I'm very interested to see the answers, because I've struggled with the same thing.  

---

## 6 answers

### Answer by username_3 on 2018-03-17. Score: 5 | Accepted answer

I post solutions after the due date of an assignment. And usually, I'll go over them in class as well.

Two birds...

1. Students get to see at least one working solution, although I try to come up with several.
2. Posting the solution serves as a good block to students asking to turn in assignments late. They'll understand pretty well that they can't turn it in late after I've already posted solutions.

I've been trying this year to make videos of me working through the problems. Sometimes they'll be screencasts of me working through the problem in front of the class. Sometimes they'll be a little more scripted and recorded when there aren't students listening. Usually it's the shorter problems where I'll just record myself during class and the longer ones that I script out a bit.

Another activity I like is to do code reviews. I'll screen shot several student submitted solutions and we'll go over them anonymously. I'll include a couple that are really good solutions. But, better than that, I'll also include a few that are really close but not quite a working solution.

On some assignments, especially those that are a little more difficult, I'll provide a pseudocode algorithm with the assignment as a bit of a cheat sheet. Nothing that can be just typed in, but sometimes students need a little bit of a nudge in the right direction.


---

### Answer by username_6 on 2018-03-22. Score: 4

## 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 University and I am discussing assignments that students
might encounter in the first two to three years (not CS1).

## Don't ever give the students solutions

The motivation for this approach
is that one can reuse the assignment in the future without worrying about
a "new" student getting a solution from the past. Although this seems
logical, a colleague of mine scours the web for postings of his assignments.
He developed a nice automated tool to do this for him.
He says that he finds a significant portion (~40%) have been posted, often to
sites like <http://www.chegg.com> Thus, if an assignment has ever been
posted on the web, it will be there forever. Even if it is not on the web,
a solution from a "friend" (who did the same assignment previously) may be
available. My take is that cheaters will cheat.

I encourage students to look for help on the web. If they find help, I ask that they cite the link in their code. This way they can go back to what they found helpful without repeating the search that got them to this information. By citing a reference, you are declaring that your work is **based** on code you found elsewhere and are giving credit to the author. But, I also say that in using the code, you are taking responsibility for its correctness. You cannot say "*It is not my fault the code I copied from the web doesn't work!*".

## Supply a reference implementation to the student

This can be done at different times, for different purposes.

* **Supply a reference implementation in "object" code** (an executable).
  This may be done
  when the assignment is posted. The motivation of this approach is to give the student an "oracle" that they can test against. Here you are
  emphasizing "testing" in that the student must figure out various
  test cases and then compare the results of their code to that of
  the "oracle". This can also be viewed as a means of resolving
  ambiguities in the assignment. If two things in the specification
  may be in conflict, the student must make the same choice as the "oracle".

  This is fine for "compiled" languages, but does not work for
  scripting languages. If one is really paranoid about Java de-compilers,
  run the reference code through an obfuscater. The student may be able to
  "de-compile" it back to source, but the source won't look anything like
  code a human would write.
* **Supply a reference implementation in "object" code after the due date.**
  Then allow students to gain back points by fixing their implementation.
  This emphasizes the requirement of a professional to get the job done
  correctly. If you hire someone to paint your house, and they only
  complete 75% of the job, they cannot expect to be paid with a "C"
  grade. You want the entire house painted, and will only pay at that time.
  When I was in engineering school (a long time ago, with small class
  sizes), our assignments were marked C&R (correct and return). The
  assignment was not complete until you had the correct answer and
  demonstrated how you got it.
* **Supply a reference implementation in "source" code after the due date.**
  Here you are providing the student with a "master work" that the
  student may study and learn how you (the master) decomposed the
  specification and translated it to code. This forces the student to
  read code and create a mental model of how this implementation works.
  In industry, this is a normal part of most projects. You have to
  understand how the code (which you did not write) works before you can fix/extend it. You can become a much better programmer by studying other's code and understanding how they wrote the code.

  For small assignments, I often present my solution by projecting it onto
  the screen from my laptop and reviewing it in class. The students may
  use their cell phones and snap pictures as I discuss my solution. I only
  do this when the review will fit in a single lecture or less. I do not
  spend class time reviewing every assignment.

  For larger assignments, you may choose to provide the reference
  implementation via a link the students can download and do with
  as they please. If a "new" student submits this solution when
  you reuse the assignment, you may catch this by using
  [MOSS](https://theory.stanford.edu/~aiken/moss/) to catch plagiarism.
  This is what I do for my larger assignments.

  There is one slight alternative to giving out the source directly.
  My colleague (mentioned above) wrote a program called "shadow" which
  turns a text document [your source code](https://www.cs.colostate.edu/~fsieker/misc/HelloWorld.java) into an HTML page. When
  you view the HTML page, you "see" the source and can read it to
  your hearts content. However, if you try and copy/paste it, you
  get a ton of obfuscating HTML code with the text ["hidden"](https://www.cs.colostate.edu/~fsieker/misc/HelloWorld.html) in it.
  Then only way to recover the original text is to type it in (or reverse
  engineer the obfuscation code). His theory is "*If you can reverse
  engineer this obfuscation, you don't need to be taking this class*".
  The two links in this paragraph show a HelloWorld.java in both forms.

My personal opinion is that the more code students **read**, the more proficient they will become. Thus, I tend to provide (or at least discuss) my solution to assignments with the students.

> **Comments:**
> **username_1**: This is a gorgeous answer, and well-deliniated. I know I've said this before, but I really hope we get to hear more from you.  
> **username_7**: I always love to read things from the _voice of experience_. I second username_1 in hoping to see more of your work here.  

---

### Answer by username_8 on 2018-03-16. Score: 4

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 answer to this question is not as simple as regurgitating the syntax. It's a process of breaking the question down into smaller steps and taking those steps on one at a time.
It might start like this:

When you encounter a question like this, you might start by breaking
  it down into its individual parts.

We know we need to create a function.
We know the function needs to take a numeric argument.
We know the function should return the square of the number passed into it.


And if the students are writing and running the code, it might continue like this:

Now that we have these steps written down, we can start implementing
  them one at a time. Let's start by creating a function:
public void square(){
  System.out.println("here");
}

We might run this function to double-check that it's working how we
  expected. Next let's add an argument:
public void square(int number){
  System.out.println("number: " + number);
}

Finally, let's add a return type to the function and return the square
  of the number:
public int square(int number){
  return number * number;
}


Or if students are writing their code down on paper, it might look like this:

Start by writing the function definition. We know it needs a numeric
  return type and that it should take a numeric argument:
public int square(int number){

Next, we need to create the square of the number:
  int numberSquared = number * number;

Finally, we need to return this value:
return numberSquared;

Putting it all together, it looks like this:
public int square(int number){
  int numberSquared = number * number;
  return numberSquared;
}


Just giving out a full code solution doesn't really help with the actual process of writing code, which is what you're actually teaching.

> **Comments:**
> **username_0**: I'm not discussing code dumps.  I'm discussing giving the students one possible answer to the exercise I've given them.  While I appreciate all the effort you put in to preparing your answer you've sort of misread my question.  
> **username_8**: @OnorioCatenacci And I believe you've misread my answer. By "code dump" I simply mean handing them a code solution without any explanation. The point I'm making in this answer is that the code is the least important part. The most important part is outlining **the process** of coming up with an answer in the first place.  

---

### Answer by username_4 on 2018-03-16. Score: 3

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.

Frustration is a mind killer. Students shouldn't be frustrated when they are trying to learn and as novices they have few tools for problem solving.

So, to resolve the dilemma, yes, make answers available, but not in the same document and not at the same time. One way is to provide answers only when asked, and after some assurance that the student has spent some mental effort on the exercise. If an exercise is given on Monday, don't provide answers until Wednesday, for example, or some variation on that.

If the size of your student group isn't too large you could give out answers only one-to-one on personal request. You could examine the student solution ideas to dispel any misconceptions. If you get a lot of requests you may need to change your teaching a bit, so that the exercise becomes more natural.

Another option, and this one for when your student numbers are too large to engage individually, is to provide answers (after an interval) for only half of the exercises and assure that the ones that are not answered by you cover the same concepts as those you do answer.

A third option is to provide an additional exercise on the same topic with any answer for a given exercise. Give the student a way to exercise the grokking part of the brain, not just the reading part.

> **Comments:**
> **username_5**: I don't know what the grokking part of the brain is, but maybe that's what I'm doing too?, see my answer below.  

---

### Answer by username_5 on 2018-03-17. Score: 2

I think this answer is a little different, please remand me if not - I provide an *algorithm* with my coding assignments, and I almost always have code I can point to in their notes or previous assignments that is exactly what they need to fill in the algorithm. First I give a general description of the problem:

> Create a Windows forms application named **Squares** with a text box,
> a button, and a label. When the user enters a number in the text box
> and presses the button, get the number, square it, and write the
> square to the label. Write a function to take the number and return
> the square. Be sure you handle invalid input.

If that's all they need to read, they can go from there. If they need to read further, then what follows *in the same document* is the step by step algorithm, but not code. If they get stuck in the algorithm, on, for example, a line that says:

> Declare an integer variable to hold the value from the text box.

Then I point them to their notes for a myriad of examples for how to declare an integer variable, or even to a previous, simpler exercise where they had to do it. In other words, I make them find the answer themselves. This gives them a greater feeling of accomplishment and also makes them less dependent upon me.

I find that by giving them this "scaffolding", I rarely have to provide an actual code solution, but will upon request.


---

### Answer by username_2 on 2018-03-24. Score: 1

Let's see if I can answer the questions head on here.

*Should I provide answers to the exercises?*

Yes. programming is not like mathematics, although they are closely related. They are multiple ways to achieve the same results. Some students appreciate when they are provided with the expected answer.

*If so should I include them as a part of the document with the exercises or as a separate document?*

Separate document would be better. There are a lot of students who dont want to be treated with holding hands. They can easily ignore the separate document while those who need it can look at it.


---

