OK. I know. It looks boring. But it's a structure of the things I want to think about when I go through trying to take a problem and mapping it into a iterative program.
好,我知道这看起来有点无聊,但是这是我要去以迭代的方式,去解决一个问题采取的,措施的大致结构。
so that you can solve it in the best and most efficient manner.
这样便可以用最好,最有效的方式解决问题。
We all have our version of trying to wrestle with this: if God knows what you're going to do tomorrow, to what extent does it make sense to say that what you do tomorrow you do freely?
我们都有自己试图解决这个问题的方式:,如果上帝压根儿就知道我们明天要做什么,那么,说着明天会自由的从事自己想做的事情,究竟又有什么意义呢?
And so frequently what we try and do is, we take a new problem and map it onto an old problem so that we can use an old solution.
我们经常做的一件事就是,我们处理一个新问题时,把它归结为一个老问题,以便我们能采取老的解决方式。
But if you can accept the purity of the statement I just made, it is at the root of the thing you have a solution.
但如果你能够遵从原教旨主义的方式,那么这就是你解决此问题的根本
So always amazing to us how we go into the problem, our eye or mind can see one class of solutions, but the math will tell you sometimes there are new solutions and you've got to respect it and understand and interpret the unwanted solutions, and this is a simple example where you can follow what the meaning of the second solution is.
解决问题的方式总能让人惊喜不已,我们的眼睛或思想可以看见一类解,但数学有时会告诉你还有新的解,你不能忽视它,而是解释这些不期而至的解,这只是一个简单的例子,由此你可以理解第二个解的意义
If I want to try and decide how to tackle a problem in an iterative matter, here the steps I'm going to go through. First thing I'm going to do, is I'm going to choose a variable that's going to count.
但是这就是我对它的观点,如果我试着去以迭代的方式,解决一个问题的话,下面是我应该采取的步骤,第一件要做的事情。
So if I were to solve this problem, here's the way I would do it. I would say, first thing I want to do, is I want to input a value for the base as a float.
如果我想要解决这个问题,这就是我要解决它的方式了,第一件我要做的事情就是要,输入一个浮点数作为三角形的底。
And I would suggest palindrome as a great example of that. That's easy to think about recursively. It's much harder to think about iteratively. And you want to get into the habit of deciding which is the right one for you to use. And with that, we'll see you next time.
其它的问题可能用递归的方式,可以更好的解决,而直接思考可能很困难,这时你就得养成做出,正确选择的好习惯了,下周再见。
Once I've got that, you notice I can now define a polar point, same way. Notice I've now solved one of my problems, which is, in each one of these cases here, I'm creating both x y and radius angle values inside of there.
你们注意到我现在可以,定义一个极坐标点了,以同样的方式,请注意到现在,我已经解决了我的问题之一了,也就是,在这些例子中的每一个,我在里面都创建了x,y值。
应用推荐