Hot answers tagged

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.6k
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
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.2k
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.2k
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
4 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
  • 655
3 votes

problem set 1 and check50 question

You have to also print a newline after the number of coins. Change this: printf("%d", totalCoins); to this: printf("%d\n", totalCoins);
ChrisG's user avatar
  • 7,376
3 votes
Accepted

Resize check50 results pset4

Wouldn't it work better if you wrote out the headers after you calculate the new new_bf.bfSize and new_bi.biSizeImage ? If this answers your question, please click on the ckeck to accept. Let's keep ...
Cliff B's user avatar
  • 68.2k
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.2k
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.6k
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.6k
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,159
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

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.2k
2 votes
Accepted

pset5 - possessives and substrings

Actually, your problem is a lot more severe than it appears. You are getting a massive number of false positives. I say that they're false because you're not actually checking the words correctly. So ...
Cliff B's user avatar
  • 68.2k
2 votes
Accepted

check50 error in vigenere with baz and Hax0r2 argv

check50 has no bugs. Your sandbox results show only one error 'szz' rather than 'rby' inside this string Expecting the following on standard out — xoqmd, rby gflkp!\n ... but received the ...
curiouskiwi's user avatar
  • 18.6k
2 votes
Accepted

Help! pset1 - mario.c - "illegal file in check" when using check50

You have a typo. check50 2014.fall.pset1.mario. mario.c You see that extra stray period between mario and mario.c? That's what is causing the problem. Lose it. ;-) If this answers your question, ...
Cliff B's user avatar
  • 68.2k
2 votes
Accepted

pset4 - Recover - doesn't pass check50 but works

It's interesting that you get 50 files, but something is amiss. Look at your test for signatures: if (buffer[0] == 0xff && buffer[1] == 0xd8 && buffer[2] == 0xff && buffer[3] &...
Cliff B's user avatar
  • 68.2k
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.2k
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.2k

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