As a newbie CS student

It’s no secret to those seeking to learn CS or programming basics that Harvard has one of the best (and toughest IMO) courses for that. CS50x is an online variation of the on campus course that you can take anytime, based on Harvardx program. It also provides a certification to any that complete the course material, or you can go further and get a Verified Certification through EDx. Not like that matters, because the knowledge and portfolio you build is way more important.

Photo by Fernando Hernandez on Unsplash

I’m a big home studying fan, and pleased with the new opportunities that pop every day in…


From problem set 3

Photo by annie bolin on Unsplash

Runoff is a ranked choice voting system. It has the benefit to provide a winner that better reflect the voters’ preference. To make that work, each voter rank the candidates in a preference list. If any candidate has a majority of the first vote preference, that candidate is declared the winner. If no candidate has more than 50% of the votes, an instant runoff takes place. The candidate that received the least amount of votes is eliminated from the election, anyone that had previously selected that candidate as their first preference now has their second preference considered. …


From problem set 3

Photo by Arnaud Jaegers on Unsplash

Plurality is a fairly simple introduction exercise to the next on the problem set, either you choose the less comfortable route with Runoff or the more comfortable with Tideman.

In Plurality we need to organize a simple election. The main function and headers are given by the course as a distribution code. We can’t change the distribution code or else we fail the staff tests. Our task is to implement the function that updates the voting count for each candidate and the function that print out the winner, or winners, as this simple model of election allows for frequent ties…


From problem set 2

Photo by Raphael Schaller on Unsplash

This time we’re preparing to code a substitution cipher. Instead of getting a number for key, we’ll be getting a string. A 26 character long string to be more exact, where each character will replace it’s equivalent index on the alphabet.

“A key, for example, might be the string NQXPOMAFTRHLZGECYJIUWSKDVB. This 26-character key means that A (the first letter of the alphabet) should be converted into N (the first character of the key), B (the second letter of the alphabet) should be converted into Q (the second character of the key), and so forth.”

$ ./substitution YTNSHKVEFXRBAUQZCLWDMIPGJO
plaintext: HELLO
ciphertext: EHBBQ

From problem set 2

Photo by Kai Dahms on Unsplash

Although it may be obfuscated by the salad, the real Caesar did have his fair share of inventions. One of them, supposedly, is a simple cryptography system that consists in adding a number, or “key” to a letter, transforming it on another letter. A jump of positions based on said key. Here’s a working code example of “Hello” with key = 1.

$ ./caesar 1
plaintext: Hello
ciphertext: Ifmmp

Unencrypted text is generally called plaintext. Encrypted text is generally called ciphertext. And the secret used is called a key.

So, how it works for the code we’re supposed to write?


From problem set 2

Photo by Jessica Ruscello on Unsplash

Readability applies The Coleman-Liau index formula to a text. The Coleman-Liau index of a text is designed to output what (U.S.) grade level is needed to understand the text. The formula keeps track of letters, words and sentences to return that index.

index = 0.0588 * L - 0.296 * S - 15.8

Here, L is the average number of letters per 100 words in the text, and S is the average number of sentences per 100 words in the text.

Here’s an example output:

$ ./readability
Text: Harry Potter was a highly unusual boy in many ways. For one thing…


From problem set 1

Photo by Ryan Born on Unsplash

Credit is the point where things start to get complicated. We need to work with a lot of big numbers and not only do mathematics with then but learn how to travel trough the number to access specific digits in its composition. We learn a little about the cryptography behind each card number and how to use it to check if the card is valid and from which provider it comes.

As always we begin preparing our directory. Assuming you already have the pset1 directory, let’s type on our terminal:

~/ $ cd pset1
~/pset1/ $ mkdir credit
~/pset1/ $ cd credit
~/pset1/credit/…

From problem set 1. Both less and more versions.

Photo by Cláudio Luiz Castro on Unsplash

On Mario problem set we need to create a terminal version of the famous pyramids from Super Mario World. The catch is that the pyramid must be responsive to the user inputs. He is deciding it’s height.


From problem set 1

Photo by Chris Briggs on Unsplash

Cash is the easier project we work on the entire course (provided you’re using the CS50 library). It basically asks us to count how many coins we need to use to return a change. Here the cashier wants to use the least amount of coins possible, not mattering how many coins of each are in the cashier’s drawer.

To begin, we open CS50 IDE through the Menu in the course page or by typing ide.cs50.io on your browser. Then procced to create our cash project folder.

cd ~/pset1
mkdir cash
cd cash
touch cash.c

You’ll notice that now we have…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store