Loading [MathJax]/extensions/TeX/AMSmath.js

Tuesday, January 26, 2016

CSC Day 57 Update - Time time tiiiime

CSC - Day 57

6.00.1x Problem Set 1:
SICP ex 3.03 3.04 3.07:

Progress is never fast enough but a new side job makes the time I do have all the more valuable. I had a quick succession of good things happen, and if anything the path ahead's clearer now. It's a bit obvious I'm not hitting that 9-week deadline - nor was it ever physically possible - if it takes 10, so be it, once I'm done I assess how much time things take, what I did right, wrong, and wait for my ego to resurrect itself (doesn't take long).

SICP/CS61A - Structure & Interpretation of Computer Programs is at Lecture 23/44 & p341 (ch 3.4) - past the halfway point; and CS106A Programming Methodology is Lec 19/28, PSET 6 of 7, Assignment 6 of 7 - so.. getting there. I'm making sure I don't fall behind on 6.00.1x - so that I can get the certificate; Circuits & Electronics is the next priority and Calc I at the end.

Unfortunately I'm not quite philosophical right now - though I'm writing thoughts down for future posts, but today's part of that report-every-3-days commitment. And I figure I should wait more than 1 day of training to complain and wax-philosophic about low-tier work in America. It's more motivation to be serious w/ the study and get into intellectual work.



Some notes from Problem Set 1 of 6.00.1x - Introduction to Computer Science & Programming with Python:

I'm learning some differences between Python and Java. My approach to studying CS & Programming is to not shy away from dealing with multiple languages at once. After all: the real part should be learning to build algorithms, solve problems, and get comfortable with multiple layers of abstraction. The syntax of different programming languages should be the easy part.

That said a few beginner notes on Python and Java. In Java you have something very close to C. Code blocks inside braces, lines ending with semicolons, explicit type setting of variables. Python looks like it's more streamlined, but I suspect a bit of a learning curve after the first stage. No explicit type setting, which makes coding faster but can bring headaches if you don't pay attention, no semicolons - instead a strict indentation regime, and a simple colon beginning a code block instead of the braces. Edit: semicolons optional

6.00.1x PSet 1.2: Counting bobs

Figuring out how to count the number of times the name "bob" comes up in a string took a lot longer than my pride allows me to say. After seeing the difference between Java and Python syntax, there were 2 issues I had to figure out: firstly how to use the range() function. You can't just write:

for i in range(s): ...  because range() wants a number but s here is a string of letters. No bueno. So use len() to find the integer value of the length of s, and pass that as an argument to range() like so:

for i in range(len(s)): --- 

The second issue was remembering that moving through an array, you start at the first value and end just before the last. So writing: if "bob" in s[i:i+2]: is going to bring you bad times, and is why my code kept saying zero.

6.00.1x Pset 1.3: Counting and Grouping


There were two hurdles with this problem. First was figuring out how to pass integer variables into a string in Python, and I think I found a more-complicated-than-necessary way of doing it, and the other was making sure the variable I wanted to return was defined after the for-loop was completed. I also forgot some colons in there. Odd to me that Python won't update variables within another variable (say integer values within a string) but.. hmm perhaps because it's defined as a string then it stays that way? Idk.


Note: copypasting from Evernote lets you keep formatting? sweet

No comments:

Post a Comment