GithubHelp home page GithubHelp logo

federico-abss / cs50-intro-course Goto Github PK

View Code? Open in Web Editor NEW
303.0 11.0 363.0 21.86 MB

Harvard's cs50: Introduction To CS 2020 - solutions to every pset plus final project!

C 62.92% Makefile 1.10% Python 24.73% CSS 0.79% HTML 10.45%

cs50-intro-course's People

Contributors

beatrizmakowski avatar federico-abss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cs50-intro-course's Issues

How did your limit function pass check50?

Did you have to declare your <limit()> function in any of the others files before it passed check50? I created a function and it compiles with "make" but not with check50.

Help with implementing sort.

// function used for sort
int comparator(const void *a, const void *b)
{
pair *orderA = (pair *)a;
pair *orderB = (pair *)b;
// uses pointers to access the preferences and check how much a candidate wins over another
return (preferences[orderB->winner][orderB->loser] - preferences[orderA->winner][orderA->loser]);
}
// Sort pairs in decreasing order by strength of victory
void sort_pairs(void)
{
qsort(pairs, pair_count, sizeof(pair), comparator);
}

Hi, I am also doing this project and I've been stuck specifically on this sort function for a few days. I know your implementation works but I'm quite new to coding and I don't really understand it. I was wondering if you could show me a different way to sort the pairs without making a new function and using pointers to get the difference in margins of victory between pairs. I know how to sort it but I don't know how to get the margins so I can sort them.

*Also sorry for posting this as an Issue, I was trying to find out how to leave a comment underneath your code but I couldn't figure it out. I'm new to GitHub too :/

validateLock() function issue in tideman.c of pset3

Hello DeWill here

I was solving pset3 of CS50 and got stuck at tideman problem of pset3,
I browsed on internet for some help and came to your solution(which helped me a lot to understand problem)....

While going through your code, I thought validateLock() function of your code might be incorrect( also I might be wrong ๐Ÿ˜„ ),
you are going through locked array linearly(like 1 row at a time), instead you should search alternatively....
I mean, consider pair (1,2) (2,3) (3,1)
the way you search is is,
first comparing 1 to 1,2,3
then 2 to 1,2,3
then 3 to 1,2,3
instead you should search as
first 1 to 2, then 2 to 3, and lastly 3 to 1

here is the solution that i came up with,

void validateLock(int x, int winner, int loser)
{
    for (int i = 0; i < candidate_count; i++)
    {
        if (lock == false)
        {
            return;
        }
        if (locked[x][i] == true)
        {
            if (x == winner && i == loser)
            {
                lock = false;
                return;
            }
            validateLock(i, winner, loser);
        }
    }
}

void lock_pairs(void)
{
    for (int i = 0; i < pair_count; i++)
    {
        locked[pairs[i].winner][pairs[i].loser] = true;

        validateLock(pairs[i].loser, pairs[i].winner, pairs[i].loser);
        // if the validateLock function found a cycle we reverse the lock
        if (!lock)
        {
            locked[pairs[i].winner][pairs[i].loser] = false;
        }
        lock = true;
    }
}

here i keep referance of staring pair as winner & loser
and start searching from one step ahead....

As I previously said, I might be wrong ๐Ÿ˜… ,
btw thanks for posting solution publicly, I helped me a lot....

with regards DeWill

in filter less pset4, about the grayscale function, doesn't the global variable retains values?

void grayscale(int height, int width, RGBTRIPLE image[height][width])
{
    float rgbGray; //Here don't we need to set this variable to zero again after we assign the values to
   //every pixel inside the inner loop?

    for (int i = 0; i < width; i++)
    {
        for (int j = 0; j < height; j++)
        {
            // averages the color intensity and then applies the same value to all the colors to get gray
            rgbGray = round((image[j][i].rgbtBlue + image[j][i].rgbtGreen + image[j][i].rgbtRed) / 3.000);

            image[j][i].rgbtBlue = rgbGray;
            image[j][i].rgbtGreen = rgbGray;
            image[j][i].rgbtRed = rgbGray;
        }
    }
}

I just wanted to ask this question somewhere in the comment but since there is no option for that in github, so I raised an issue. Sorry for that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.