It’s been 2 days since last post, I’m still alive. Just finished CS50 Week 1 problem sets. I don’t intend to follow the course schedule by weeks, so I’ll be doing next week works as soon as I finish the current one.
Week 1 class is introducing C, its data types, command line interface and so on. It’s not hard to follow the class, but it is very long, average 2 hours per class. There are also some short videos about 15 minutes long each to supplement the topics, and a walk through how to do the problem set.
The short videos are good, but they are too short, not enough additional materials. As the walk-through, they are more like hints of how to do your problem set.
There are 6 problem set, 4 less comfortable and 2 more comfortable. What does that mean? The less comfortable ones are easy, everything is pretty straight forward, pretty much requires no heavy brainstorming. The more comfortable ones are slightly harder, that’s where the walk through helps.
I’ve done all of it this week. I’d say one of the more comfortable (harder) set, is just an add on to one of the less comfortable ones.
I’m not going to post my work here, since it is graded.
Week 1 Problem sets:
1) Hello World Program
Of course, every language program must start with some sort of print program, such as Hello World! This program is not graded fyi.
2) Water Consumption Program
This program calculates how much bottles of water (16oz) that is required to take a certain amount of time in the shower. Basically a conversion program.
3) Mario Stairs Program
This is somewhat fun? Using an algorithm to type in amount of stairs and convert it into text picture? I’ll post a picture.
There is a more comfortable version (harder, not really), basically makes it symmetrical.
This program calculates the least amount of coins to hit the amount that user typed in. So .75 cents would be 3 coins (3 quarters), .41 cents would be 4 coins (1 quarter, 1 dime, 1 nickel and 1 penny). Not too hard, but I struggled it a little. Unlike Ruby, what you see is what you typed. The problem with C is even if you typed in 0.1, the actual number is not 0.1, it will be 0.1000000000000000000000000000012315213, some random numbers ending. I don’t really know why it does that, it has to do with bits and bytes, how it is being stored. So my last cent is always wrong, due to some random ending number. How is 0.1 / 0.1 is not 1? To counter this problem, I converted the input into Int data type, which makes it whole number, no more .00000000012315. For example 0.01 would multiple by 100, and becomes 1. I also round whatever that is after 2 decimal places. This way all I deal with is just Int data type.
This is one of the more comfortable (harder, and it is harder) programs. This validates the user’s input of their credit card number. It uses an algorithm called Luhns algorithm. It looks really intimidating at first, but it’s actually very simple to implement.
This problem set only requires us to check Amex, Visa, and Mastercard. Not Discover or any other type of credits though.
Here’s my grade for Pset1.