CS 50 Rules!
The first problem set (Pset1) is done.
I've completed the first week of what an 18 year old at Harvard does along with three other classes. The only thing that's different is that I am 43 years old with three kids, a house payment and two cars. And it took me two weeks to get it done.
The first problem set comes with four challenges:
I'm sure there are better ways solve these problems than I did, but this is just the first step in the learning process.
I spent way too much time on this one. I kept trying to figure out how to loop through the change requirements and use a different variable each time. I was thinking that I had to use loops to get the problem done, but then I decided to keep it simple and solve for each number of coins individually while also checking for the remainder with the modulus operator. I also used the floor() function from the math library to round down to the nearest integer. I used this since I knew I would be using the modulus operator to find the remainder (%) from the remaining coins from the previous coin. This doesn't sound like it makes sense, but if you read the code (I hope) it'll become a little more clear.... I'm sure there are better ways to do it and I look forward to seeing some elegant solutions! Cheers!