10 votes

Pset3: Plurality - Weird output!

You should rethink your logic for the print_winners function. Here's the pseudocode I'd use. Declare a maxvote int set to 0. Iterate over the list of candidates and check the number of votes. If ...
curiouskiwi's user avatar
  • 18.7k
7 votes
Accepted

pset6 - caesar - check50 error: "expected exit code 1, not 0"

main in Python no longer has a special meaning, but is a regular function, its name only chosen to conform to conventions based in C. Try exit(1) instead of return 1. Relevant python docs: https://...
Blauelf's user avatar
  • 20.9k
6 votes
Accepted

pset6 python bleep

Is the problem that you have hardcoded the input file to "banned.txt"? From the specification: Accepts as its sole command-line argument the name (or path) of a dictionary of banned words (i.e., ...
DinoCoderSaurus's user avatar
6 votes
Accepted

pset4 filter: blur seems to be working, but check50 reads errors

You overwrite pixels you still need later, for calculating the neighbouring pixels. What looks about right visually is still wrong. I made another array, wrote my blurred image to that, then later ...
Blauelf's user avatar
  • 20.9k
6 votes
Accepted

Check50 and style50 not working: pset1

So apparently markupsafe was upgraded and soft_unicode does not exist in it anymore. I downgraded markupsafe to 2.0.1 and it fixed the issue for me: pip install markupsafe==2.0.1
Wajeeha Abid's user avatar
6 votes

cs50p problemset 7 /working.py

This scenario has been described in the CS50 Python ED forum. When you get this error message: :( correct working.py passes all test_working checks expected exit code 0, not 1 It means check50 is ...
kcw78's user avatar
  • 797
5 votes
Accepted

pset1 greedy checking problem

True that check50 is strict about the output. Here is what the instructions say Incidentally, so that we can automate some tests of your code, we ask that your program’s last line of output be ...
DinoCoderSaurus's user avatar
5 votes
Accepted

speller works fine but can´t pass check 50

There is a clue in the check50 results. Suspect your testing is on the large dictionary ("it work exactly like the cs50 staff's"). Try the program with the small dictionary. Chances are it will ...
DinoCoderSaurus's user avatar
5 votes
Accepted

Why is my lab1 code failing to pass one test in check50?

It's failing the test because you are using a do-while loop which is incrementing n before it checks if year < y. Remember that the reason to use a do-while loop instead of a while loop is that you ...
Robert S. Pratt's user avatar
4 votes
Accepted

pset4 check50 2016.recover recover.c is working correctly?

Yes, you're getting 50 files, but the last file is wrong. While the image looks right, it has a problem. It's 512 bytes too large. This is a fairly common error. Look closely at what the code does ...
Cliff B's user avatar
  • 68.8k
4 votes
Accepted

pset3/find check50 frown helpers.c compiles. expected exit code 0, not 1

find.c and helpers.h cannot be altered. When check50 runs, it uses its own copies, so your alterations are lost. That will cause the compile to fail. You need to make all of your changes in ...
Cliff B's user avatar
  • 68.8k
4 votes

pset1 cash 2022

Looks like you are using the 2022 version of check against the 2021 version of pset1 cash. The 2022 version of the pset has a new function to implement called get_cents. (There may be other ...
DinoCoderSaurus's user avatar
3 votes
Accepted

Pset6 problem in indexes and load function

Here are specific things to look at: load Declare c as an int instead of size_t, since size_t is unsigned. indexes Your allocation for path2 is wrong char* path2 = (char*)malloc(sizeof(strlen(php) ...
DinoCoderSaurus's user avatar
3 votes

PSET1 - Water fails check50: "expected prompt for input, not exit code of 0"

One option would be to simply use the GetInt(); function in the cs50.h library since it already reprompts the user for input if they give bogus values. Or implement the feature yourself and use a ...
NullityNull's user avatar
3 votes
Accepted

CS50 PSET2 Check 50 Hello world trouble. Caesar cipher segmentation fault and encipher the plaintext

isupper() does not work on strings, it only works on chars, that's why you get the seg fault. "I did not find anything that helped to iterate over the chars of p. Can you give me a hint on how to do ...
Mahmoud Khaled's user avatar
3 votes

PSET5: Why is my code working without fully implemented Unload function

Totally awesome that you are asking the question even though it passed check50! Kudos. Notice this line Usage: speller [dictionary] text in the valgrind report. Speller didn't really run. You called ...
DinoCoderSaurus's user avatar
3 votes
Accepted

pset5 speller works, check50 fails, segfault with small dictionary

Think about what's happening. When using the full dictionary, there are words for every letter of the alphabet. Since your hashmax is 32, there's also a really good chance that every possible hash ...
Cliff B's user avatar
  • 68.8k
3 votes
Accepted

pset7 finance check50 invalid purchase

One way to test is to add a hard-coded value to lookup (in helpers.py) that has the condition you need. Near the top, put this: if symbol == "ABC": return {"name": "ABC test","price": 14....
curiouskiwi's user avatar
  • 18.7k
3 votes
Accepted

pset7 finance check50 doesn't detect a valid sale despite portfolio updating correctly

As suggested in a comment, add this to the top of your lookup function in helpers.py if symbol == "AAAA": return {"name": "Test A", "price": 28.00, "symbol": "AAAA"} and then, with a fresh ...
curiouskiwi's user avatar
  • 18.7k
3 votes
Accepted

Pset1: Problem: expected “##\n”, not “ ##\n”

Your own question hides the answer, carefully observe the difference: "##\n" " ##\n" There is a space that should not be there, the hashtag must be perfectly aligned to the left. Your program is ...
MARS's user avatar
  • 5,169
3 votes
Accepted

check50 not approving my code but it looks like it's working

The good news is: it looks like your ciphering algorithm is working. Yay. The bad news is you missed a important detail in the spec. Notice the difference between what cs50 is expecting: "ciphertext:...
DinoCoderSaurus's user avatar
3 votes

:( Little Professor generates 10 problems before exiting

i used randint instead of randrange to generate unique questions. dunno why it didnt work with randrange. if level == 1: num1 = random.randint(0, 9) num2 = random.randint(0, 9) ...
shiva kharbanda's user avatar
3 votes

Mario pyramid works, but check50 not buying it

This is a fairly common misinterpretation of the spec. The pyramid should print out so that there are no leading spaces on the last line, no matter how high the pyramid is. This code prints too many ...
Cliff B's user avatar
  • 68.8k
2 votes
Accepted

pset4 recover: last image not recovered correctly

The problem is that you check for EOF before reading new data. You need to do the read and then check for EOF. Remember, after the last word is read, the file pointer is positioned to detect the EOF ...
Cliff B's user avatar
  • 68.8k
2 votes
Accepted

Pset3 Fifteen Check50 not Working

Wow, this is something I've never seen before. Congratulations! ;-) Your code is both right and wrong at the same time! :-D Yes, your code displays correctly and looks perfectly correct. It also ...
Cliff B's user avatar
  • 68.8k
2 votes
Accepted

Doesn't pass the last test

check50 actually uses a different data set for testing, so it is working correctly. (Sneaky of them, isn't it? ;-) It's because of a series of issues over time and is a long story. ) As for not ...
Cliff B's user avatar
  • 68.8k
2 votes
Accepted

check50 showing unexpected end of input

The issue is time. There's nothing wrong with the server for pset5. (Don't know if there are pset6 issues, but that's a different situation.) While your program may work, it is slow. When I ran your ...
Cliff B's user avatar
  • 68.8k
2 votes
Accepted

PSET4 Recover.c not clearing Check50

The 'killed by server' result happens when the program is taking too long to execute. There's an execution time limit built into check50 (I think it's 30 seconds, maybe less), and your code appears to ...
Cliff B's user avatar
  • 68.8k
2 votes
Accepted

Pset 6 server.c, Check50 does not work

These three failed tests should give you a hint that it's testing the code you wrote for indexes. :( Requesting /test redirects to /test/ :( Requesting /test/ outputs /test/index.html :...
DinoCoderSaurus's user avatar
2 votes
Accepted

PSet3 Find passing my testing but failing check50

What bool does 0 represnet - true or false? Your search() routine returns a bool, meaning either true or false. However, you have fallen into the trap of using numbers instead of true or false. The ...
Cliff B's user avatar
  • 68.8k

Only top scored, non community-wiki answers of a minimum length are eligible