Course: Harvard’s CS50

## Problem Set 1: C

pset1/hacker1 is an introductory assignment to get your feet wet in C.

## Skittles

Demonstration of how someone can use binary search to make a correct guess (find a target value) faster than linear search.

## Greedy

A quick look at a simple ‘greedy’ algorithm.

## Chart

Make a horizontal chart.

## Chart (hacker1)

Make a vertical chart.

## Credit (hacker1)

Check for ‘apparent’ validity of credit card numbers.

One small detail that had me scratching my head in hacker1′s ‘Bad Credit’ assignment was something I missed the first, second and third time I read through the text…

Okay, let’s multiply each of the underlined digits by 2 […]

Now let’s add those products’digits(i.e., not the products themselves) together

Meaning: if the multiplication result is > 9 add the result’s digits together.

(ie. 2×8=16 –> 1+6 = 7)

That little hint probably got you going, and you can take care of the rest of the code yourself.

## Extras

These examples go beyond what you may be required to know at this point and/or the pset specifications.

change2.c (view | download) Note: greedy.c for Euro coins.