Welcome to CS212. Now, in this class, you're going to be learning by example. So
I will pose some problems to you and you'll get a chance to create your
solution. And then I'll show you and discuss my solution. It's important to
note that there's more then one way to approach a problem, and I don't mean that
my solution is the only way or the best way. My solutions are there to help you
learn a style and some techniques for programming. But if you saw problems a
different way, that's fine. Good for you. All learning that goes on happens inside
of your head, not inside of my head. So what's important is that you understand
the relation between your code and my code that you get the right answer by writing
out the solution yourself and then you can examine my code and maybe pick up some
pointers and some techniques that you can use later. For example, suppose I ask you
to compute the sum of a list of numbers. Here's the mathematical formula. And I ask
you to write function, which we'll call ss, for sum of squares, which takes a list
of numbers as input. If you've taken CS101, you might write a solution like
this, initialize the total=0. We'll go through the indices of the
numbers and for each one we'll increment the total by the square of the number, and
then when we're done we'll return the total. So that's a perfectly good
solution. No problems with that whatsoever. If you're able to come up with
that you've done your job. But then after you come up with your solution I'll show
you mine and mine might look like this, same function definition. But I might
prefer a functional style rather a sequencial style where I'm return the sum
of the squares of X for each X in number. Now maybe you've never seen something like
this before maybe you didn't know about the sum function. Maybe you didn't know
about this type of generator expression in line so this might all be new to you.
Important point is that this solution of yours is just as valid as mine. So what I
want you to do is just compare your solution to my solution and see if
there's anything interesting or new in mine that you might pick up. I don't want
you to say, hey, that's not fair, Peter, you introduced some new idea that I
haven't seen before. Don't let that make you upset. Instead, I want you to say,
well, my solution works, but this is interesting, too, and this is something
new. I want you to be happy that you learned something new, and proud that you
came up with a solution that is just as good. But happen to just use some
different techniques. So remember, learning is not me saying something and
pouring that into your head. Rather, learning is what goes on inside of your
head. And it's up to you to make use of what I show you. So that you can learn.
This class is an apprenticeship. You learned first by observing, then by trying
it yourself when the next example comes up and then finally now you really got it
down when you can take what you've learned and teach it to someone else, may be in
the forums or may be outside of class. Now one final point. The problems in this class
are hard, the best learning takes place when you're challenged and this class
will challenge you. Don't worry if you don't get everything on the first try, use
the forms to ask questions, view the videos more than once if you think that
the helps, give yourself time to let new ideas sink in, you may have to see them
multiple times before it makes sense so don't worry about having to review
multiple times or ask for help. It's hard but it's fun hard, so welcome to the
class, good luck. I hope you enjoy as much as I do.