person holding Super Mushroom

I have just finished completing part one of the pset1 of the first week of the cs50 course!  It took me a while to complete 3 sets… I didn’t know whether I was doing it right because I felt like my method was so longwinded and there wasn’t anyone to tell me else wise. I started the course a while ago but only watched pset0 videos and did the scratch task. I woke up at 7am this morning and I started at 9am and ended it at 3am! In total, it took me around 10 hours to watch all the videos and research and complete the task – as the course suggested.

Apart from constantly being distracted by the internet and wanting to make food I really enjoyed it. When you complete a task the achievement feels super duper good 🙂

Mario’s Pyramid

The first task was to recreate a triangle using hashes like the pyramid blocks in Mario.

Please enter the height: 4
...#
..##
.###
####

So the dots are supposed to be spaces but WordPress won’t let me put those in. The end result would be 1 space less than the height then 1 #. Then 1 less space and 1 more hash etc etc.

There’s an easier version and a more ‘comfortable’ version. I started off with the harder version thinking I was smarter than I actually was and found it difficult so had to revert back to the easier version. I’m not sure whether I did it right but I managed to get the stuff printed out after some failed efforts. I had to watch all their course videos and rewatch the lecture to complete it. Then I decided to move onto the harder version and complete that one too. I sent to get it marked by the bot and I only got 85% for one as I didn’t realise you had to ‘style’ the code too which was annoying.

My answer just consisted of simple for and while loops which I learnt on Codeacademy last year for Javascript. It’s all kind of similar. I had to make it only accept a value between 0 and 23 that was an integer.

More Comfortable Task

The more comfortable task asked you to make a pyramid that looked more like this.

Please enter the height: 4
...##..##
..###..###
.####..####
#####..#####

So it had to start from 2 hashes and then have 2 spaces after the hash and then the same amount of hash on the other side. I had to print them out line by line to get it like that.

After many failed attempts of the code not working. I managed to complete it.

Cash Task

The next task was to use a greedy algorithm to calculate how many coins in quarters, dimes, cents etc would you get out of the change given back at a cashier. I found this one quite difficult because I wanted to use the modulo maths method as I kind of understand the process but I didn’t know how to implement it and the same went for using a for loop to loop through an array with the different coin amounts in it. But I couldn’t do any of that so I did some while loops and hard-coded the rest. It was a bit long and tedious but it works!

After submitting the cash task I tried to move onto the credit task which was for “more comfortable” coders. This one was HARD as it was encrypting a credit card, multiplying every other digiting, adding them together and all sorts. I couldn’t do it. It was too overwhelming 🙁 I’m going to skip it do all the “less comfortable” tasks and the “more comfortable” ones if I can and go back every few intervals to see if I can complete them. I kind of want to finish all of them as I feel it was progress my learning a lot more if I kept trying at something more difficult.

C++ is very similar to Javascript. So far I can’t tell the difference. Mainly because I’ve forgotten most of it lol.

Now onto part II… it’s taken me almost 2 weeks to finish the first week FML.


Blog banner by Ryan Brinkerhoff


If you found this post useful please support House Ninety Two: Buy Me a Coffee at ko-fi.com