The mystery of the missing code #mooc #mmooc

Just copying over an exchange on OpenStudy about some missing code.  Thanks, @Screech!

MOOC-E

The Mystery of the Missing Code: At about minute 20 of lecture 6 in 6.00SC (which is part of the week 5 assignment of the Mechanical MOOC course), Professor Grimson throws in two examples of code for recursive definitions that are not included in the downloadable code file. Has anyone out there recreated this code, and if so, can you share out?

Screech

Went to look at lecture 6. The code display is almost illegible. I zoomed in and the first looks like:

def simpleExp(b, n):
    if n == 0:
        return 1
    else:
        return n * simpleExp( b, n-1)

and a few minutes later in the lecture after his demonstration with the stacking toy, he presents the Hanoi function

def Hanoi(n, f, t, s):
    if n == 1:
        print “Move from ” + f + ” to ” + t
    else:
        Hanoi( n-1, f, s, t )
        Hanoi( 1, f, t, s)
        Hanoi( n-1, s, t, f )

I haven’t coded or tested this but it seems to fit with what he presented and make sense logically.  Was this what you wanted?  Yeah it can be a real eyestrain trying to make out that fuzzy video sometimes.

Advertisements

About MOOC-E

The Mechanical MOOC, international man (or machine) of mystery. (Photo credit: Tinkerbots http://bit.ly/P029IR)
This entry was posted in Seq15Oct12, Seq26Nov12, Tech issues and tagged , . Bookmark the permalink.

3 Responses to The mystery of the missing code #mooc #mmooc

  1. abtster says:

    I think the proper code for simpleExp() is the following:

    def simpleExp(b, n):
    if n == 0:
    return 1
    else:
    return b * simpleExp( b, n-1)

  2. abtster says:

    and wit proper idents:
    def simpleExp(b, n):
    ‘ ‘ if n == 0:
    ‘ ‘ return 1
    ‘ ‘else:
    ‘ ‘return b * simpleExp( b, n-1)

  3. abtster says:

    next try:
    def simpleExp(b, n):
    ____if n == 0:
    ________return 1
    ____else:
    ________ return b * simpleExp( b, n-1)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s