Craig Rodrigues!

Learning to Code: Week 10 - Understand the Whole Problem

7/14/16

  • Excellent food for thought when it comes to solving a problem (from Shawn).

What I gave you was basically a functional requirement. Get from Atlanta to Miami.

But to get to the right answer, you have to get to the non-functional things that are important.

Is it about speed?

Is it about safety?

Do I want to see awesome scenery?

That's one of the things that differentiates a programmer from an architect. Architects work to understand the whole problem space before running off an doing something. Or at least good ones do.

7/15/16

  • Nothing done today. 😑

7/16/16

003

7/17/16

#include <cs50.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

/*  
    Largest Prime Factor
    The prime factors of 13195 are 5, 7, 13 and 29.
    What is the largest prime factor of the number 600851475143 ?
*/

int largest_factor = 0;

void largestprime(long long n);

int main(void)
{
    long long number = 600851475143;
    largestprime(number);
    printf("The largest prime factor of %lli is %i\n", number, largest_factor);
}

void largestprime(long long n)
{
    int d = 2; //start checking primes at 2

    while (n > 1)
    {
        while (n % d == 0)
        {
            largest_factor = d;
            n /= d;
        }

        d++;

        if (d * d > n)
        {
            if (n > 1)
            {
                largest_factor = n;
                break;
            }
        }
    }
}

 

7/18/16

  • Nothing done today. Too busy packing for San Diego.
  • Downloaded Week 5 & 6 videos for plane ride.

7/19/16

  • I powered through a lot of videos on the plane ride. Maybe 2.5 - 3 hours worth.
    • Rewatched Lecture 1
    • Lecture 2
    • Scanf-0, Scanf-1, Scanf-2
    • GetInt
    • File pointers
    • Singly-Linked Lists
  • I took notes and here they are as a PDF: https://www.dropbox.com/s/dy3ump3fwedniyc/CS50%20Week%205.pdf?dl=0
  • I haven’t been able to get the Daily Programmer BASIC challenge done, but the file pointers video really helped so I may be able to actually get it done now.

7/20/16

  • MORE VIDEOS
    • Doubly-Linked Lists
    • CS50 Library

Notes as a PDF here: https://www.dropbox.com/s/zekoyhtho66czx7/CS50%20Week%205%20%232.pdf?dl=0

Learning to Code: Week 11 - Coding While Travelling

Learning to Code: Week 9 - Python?