At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
# 6.189 Homework 1 Exercise OPT.2 – Secret Messages # A simple shift cypher # Done in Python 3.2.2 On pastebin: http://pastebin.com/PU0p47xM
Very simple and very cool! Nice work. I was waiting to see what type of work load the MechMOOC was going to offer, and it seems it will be weekly assignments. I think I will also attempt to complete the entirety of the MIT assignments...
Well, that is my second Python program... ever. I just know a good chunk of C++ and VB, as well as a little of a couple others. So rather than doing most of the hello world stuff, I am going for the harder targets. It should make interesting, and I can share what I do so that others who are taking it as a starting point can see a few other things.
e, I like how you did this. I'm curious about this piece: if temp >= shift: message_out=message_out+chr(temp-shift) else: message_out=message_out+chr(temp-shift+126) why the + 126? I get that you're saying, if the digit we're iterating on is less than the shift value, message_out should have the current value less the shift value (because this is your decoding process) plus 126. I understand that if temp is less than shift, you'd have a negative number, which maybe ascii doesn't support. What's special about 126? And how does it ensure you decode correctly?
It relates to the ASCII table. Though I did see some characters pop up that I did not expect, so the ASCII handling might be different. I know 3.2.2 uses UTF8, so my encoding is probably being tweaked by that.
6.189 Homework 2, OPT.1 - Pig Latin Sentences http://pastebin.com/gfisvZqZ The "advanced" Pig Latin processor. Implemented without regex, which is a bit long because of that. As you learn, you will find that Regular Expressions, or regex, are a great way to do these things.
I must have missed these. Is this extra MOOC-E coursework or are you following something else?
These are in the 6.189 homework. Not specific to the MOOC. Thought it would be a good time to do some, give MOOC followers something else to look at/talk about/try etc. You can see the questions I am answering in the PDF files for the class. They are optional even in 6.189, so not exactly what everyone would do.
They are the most fun though.
Thanks @e.mccormick, I'll have a look
Something you can do in Python easily is learn the overall goal of Python. Just type in "import this" to the interpreter and presto: >>> import this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those! >>>
So where is the remainder or modulus operator in your solution to 6.189 OPT.2? I think this exercise is just to get you to use that operator once. I also think that the instructions are unnecessarily confusing -- who needs to know what ASCII is? I think all that is needed is that the function ord returns sequential integers for 'a' to 'z', so then you can rely on ord('z')-ord('a')==25 (I almost said 26 :-)
Nice work on the Secret Message Cypher! It's simple to use, and does a good job of first handling possible runtime exceptions, then checking the value of the mode variable before proceeding. It is robust in that whether the user enters a non-integer (causing an exception that is caught) or an integer not equal to 1 or 2, execution continues with the same same "Not a valid selection" message, so that the user is insulated from the distinction between a runtime exception and a value check.
I felt it was better to make something that is less likely to crash then to exactly follow the instructions. It relies upon knowing ascii rather than the mod function. Also, I did not shift things in a way where capitals remain capitals, etc. Now what is real fun is working out an extended Playfair Cypher that would include all upper and lower case, as well as punctuation, and encrypt with that. Because it would be a square array, you would have the option of anything that does 52 characters or more. 8 would be 64, so 12 punctuation characters or 2 punctuation characters and the numerals. Or 9 gets you 81, which has plenty of room for things and 10 really does it. Another interesting one is to break things up into a matrix, then use rules of matrix multiplication to encrypt. Any invertible matrix can be used for this sort of solution because what you multiply by a matrix to encode can be decoded by multiplying by the inverse.