Recap – Design of Computer Programs

Let’s do a recap of what we learned in this unit. First, we talked about some Python features that were maybe new to you. We used complex list comprehensions. That’s something like x-squared for x in blah, blah, blah, if something. We showed generator expressions, and that’s similar but with parentheses. We talked about generator […]

Solving Cryptarithmetic Solution – Design of Computer Programs

Here’s a code that’s pretty simple. All we do is we iterate the variable F over all the possible values of filling in the formula. If we say that filled-in formula F is valid, then we should go ahead and return it. Otherwise, when we get through the end of the loop, we automatically return […]

Neighbors – Design of Computer Programs

[Norvig] Now, before we go on to constraint number 3, I want to go backwards a little bit and say there’s 2 concepts we haven’t talked about yet: the concepts of being next to and immediately to the right of. Immediately to the right of–well, because we’ve used house numbers to assign houses, we can […]

Compile Word – Design of Computer Programs

Here’s an example of how it all works. This I’ve actually typed into the Python interpreter. I’ve defined a function f as a lambda expression. It looks like this. Then I’ve asked what F is. All Python prints out is it says that it’s an object of type function, which doesn’t have a name other […]

Representing Hands – Design of Computer Programs

[Norvig] Here’s a quiz question. I want you to tell me which of these possible representations for a hand do you think make sense. Somewhat this is subjective. You may have different opinions. So tell me all the ones that you think are pretty good and not the ones that you think are problematic. So […]

Nitty Gritty For Loops – Design of Computer Programs

Now, after all that, I think you’re finally ready–you’re mature enough– to learn the whole truth about how for statements actually work. You’ve been using them all along, but you may not have known the inner details, the gory truth, about what’s inside the for statement. Now, when I saw for x in items, print […]

Modify Code – Design of Computer Programs

What I want you to do is take– this is the same version of the bridge problem solver that we saw before, and I want you to modify this so that it tests for the goal later after pulling a state off the frontier, not when we’re about to put it on the frontier.

Alt – Design of Computer Programs

Let’s get back to our compiler. Again, in matchset I pulled out one more clause. This is a clause for sequence, and this is what we return. If I want to write the compiler for that sequence clause, I would say let’s define seq(x, y). It’s a compiler so it’s going to return a function […]

Mc Problem – Design of Computer Programs

Now let’s write a function to solve the missionary and cannibals problem. It takes a start state. Here’s the normal problem: 3 missionary, 3 cannibals, and 1 boat on the start side. Nothing on the other side, and it takes a goal state. The goal state is not specified. It’s just the opposite of that–3, […]

Decorated Wrappers – Design of Computer Programs

So here’s an idea. Let’s get rid of this line, and instead, let’s declare that n_ary is a decorator. We’ll write a definition of what it means to be a decorator in terms of updating wrappers. Then we’ll be done, and we’ve done it once and for all. We can apply it to n_ary, and […]

Copyright © 2019 Geted Tabs Online. All rights reserved.