'Bug in cs50x 2022 cash.c

My code works out perfectly, it compiles perfectly on my computer, but it doesn't work when I check50 it, it gives the correct result, and it seems well optimized. When I use the check50 command, it says:

:) cash.c exists
:( cash.c compiles
    code failed to compile
:| get_cents returns integer number of cents
    can't check until a frown turns upside down
:| get_cents rejects negative input
    can't check until a frown turns upside down
:| get_cents rejects a non-numeric input of "foo" 
    can't check until a frown turns upside down
:| calculate_quarters returns 2 when input is 50
    can't check until a frown turns upside down
:| calculate_quarters returns 1 when input is 42
    can't check until a frown turns upside down
:| calculate_dimes returns 1 when input is 10
    can't check until a frown turns upside down
:| calculate_dimes returns 1 when input is 15
    can't check until a frown turns upside down
:| calculate_dimes returns 7 when input is 73
    can't check until a frown turns upside down
:| calculate_nickels returns 1 when input is 5
    can't check until a frown turns upside down
:| calculate_nickels returns 5 when input is 28
    can't check until a frown turns upside down
:| calculate_pennies returns 4 when input is 4
    can't check until a frown turns upside down
:| input of 41 cents yields output of 4 coins
    can't check until a frown turns upside down
:| input of 160 cents yields output of 7 coins
    can't check until a frown turns upside down

And here's the code:

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

int greedy_calculation(int greedyInput);

int main(void)
{
    int changeOwed = 0;
    do
    {
        changeOwed = get_int("Changed owed: ");
    }
    while(changeOwed < 1);

    changeOwed = greedy_calculation(changeOwed);

    printf("%i\n", changeOwed);
}

int greedy_calculation(int greedyInput)
{
    int finalResult = 0;

    do
    {
        while((greedyInput - 25) >= 0)
        {
            greedyInput -= 25;
            finalResult++;
        }

        while((greedyInput - 10) >= 0)
        {
            greedyInput -= 10;
            finalResult++;
        }

        while((greedyInput - 5) >= 0)
        {
            greedyInput -= 5;
            finalResult++;
        }

        while((greedyInput - 1) >= 0)
        {
            greedyInput -= 1;
            finalResult++;
        }
    }
    while(greedyInput != 0);

    return finalResult;
}

I am well aware that I still need to add comments, but I'm more stuck with as to why it doesn't work, thanks so much for your help :D



Solution 1:[1]

From the spec (emphasis added):

CS50x 2022’s version of Cash is quite different than CS50x 2021’s version. It will be in your best interest to do this problem from scratch, if you do not have credit for the work you did in 2021. Last year’s version will fail to compile when checked by check50 due to the fact that in this new version, you must implement functions which the testing suite will test independently, beyond just checking for the final answer (as last year’s versiondid).

check50 expects that you start with the supplied (2022) distro code and follow the spec instructions.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DinoCoderSaurus