21 votes
Accepted

Pset7 - :( quote handles valid ticker symbol

I found a solution here. I didn't format the price of stock by usd(). When I changed my code from {{ price }} to {{ price | usd }} in quoted.html, it worked.
Anh Nhat Tran's user avatar
13 votes
Accepted

CS50 good hash function for PSET5 Speller

I'll take a run at explaining it. This is a very popular hash function for this pset and other uses. It uses a seed value because changing the starting hash value, the seed value, has an effect on ...
Cliff B's user avatar
  • 68.8k
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
6 votes
Accepted

How to get a value using flask, from a selected option in a drop down list?

Give your select a name, and your options a value each. <select class="form-control" id="rating" name="rating"> <option value="5">5</option> <option value="4">4</...
Blauelf's user avatar
  • 20.9k
4 votes
Accepted

Fifteen move not working in last row only

A very common problem. Look at the following: else if (i < d && board[i + 1][j] == 0) This code attempts to swap with a tile that is off the edge of the board. If i = d-1, then what is ...
Cliff B's user avatar
  • 68.8k
4 votes
Accepted

Pset1 error: expected identifier or '('

The body of the main function must go between keys, the compiler interprets that as the keys are missing, declaring a function before main (this will be seen later) the solution is simple: int main(...
MARS's user avatar
  • 5,169
4 votes
Accepted

This should be right (Caesar)

The output does not match the spec. This plaintext : should be this plaintext:. The same with ciphertext:. There is no space between the word and the :. While this may seem "overly strict", it is good ...
DinoCoderSaurus's user avatar
4 votes
Accepted

PSET 3 Plurality - Program works but also returns invalid vote?

Pretty straightforward problem. Your vote function ALWAYS returns false, even after registering the vote. If false is returned to main, it'll print the invalid vote message. If vote() succeeds in ...
Cliff B's user avatar
  • 68.8k
4 votes
Accepted

PSet4 Recover, only finds 22 corrupted photos, doesn't pass Check50

This is a pretty common newbie mistake. Look at this code: //Loop until end of 512 block while (fread(buffer, sizeof(BYTE), 512, memorycard) == 512) { //Read 512 bytes into buffer fread(buffer, ...
Cliff B's user avatar
  • 68.8k
4 votes
Accepted

variable used in loop condition not modifies in loop body

Well, I had to think carefully about what the code is doing. That mostly comes from not using a best practice. Here's the best-practice guideline on whether to use a FOR loop or a WHILE loop. When ...
Cliff B's user avatar
  • 68.8k
3 votes

Pset2 - Receiving different outputs each time I run my code- Vigenere.c

When encrypt[n] is declared, it doesn't allow for the end of string marker at the end. Also, the end of string marker is never added to the string, so when it is printed at the end of the program, ...
Cliff B's user avatar
  • 68.8k
3 votes
Accepted

Game of Fifteen - Move function issue

You have two serious problems here. First, your move() function defines int blank = board[d][d]; The array element board[d][d] doesn't exist because both indexes run from 0 to d-1. Anything with d ...
Cliff B's user avatar
  • 68.8k
3 votes
Accepted

What is the Advantage of Verified Certificate in CS50

An honor code certificate basically means that you verify yourself that you took the course. It is than up to the person reading your certificate to decide whether you did indeed complete the course ...
jaguar's user avatar
  • 70
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
Accepted

**SPOILER - COMPLETED PSET** improve CS50 pset4 recover with functions

Assuming that i understand correctly and the function causing the problem is newfile, the problem is this: Your argument img is a FILE pointer. At the beginning of your code you set it to NULL, which ...
Irene's user avatar
  • 1,687
3 votes
Accepted

recover.c Invalid or Unsupported Image Format

I found the answer with a very stupid mistake, and that is I open the file without assigning it to out_file Feels bad as am frustrated all night :(
Yasser Altamimi's user avatar
3 votes
Accepted

how do I write a = a - .10; like a--?

In general, you can shorthand like this: replace with this a = a + 5; a += 5; a = a - .10; a -= .10; a = a * 7; a *= 7; a = a / 2; a /= 2;
curiouskiwi's user avatar
  • 18.7k
3 votes
Accepted

Why greedy.c shows unexpected result due to float variable?

I'd suggest you review the Week 1 lecture, particularly the part about float imprecision. (you can see the notes for week 1. Also, the problem walkthrough (and hints) mention that should convert the ...
curiouskiwi's user avatar
  • 18.7k
3 votes
Accepted

pset3 duration itoa - with "&"

First, understand what strings in C are. Strings in C are pointers to a character, or char* (if you use type string, that's a custom alias for the same thing). The convention then says that the ...
Blauelf's user avatar
  • 20.9k
3 votes
Accepted

When will my CS50x certificate arrive?

All certificates have been issued for everyone who has qualified by the end of September. Do you not see a link on your edX dashboard? Do you see the green "you've qualified" banner on your cs50.me/...
curiouskiwi's user avatar
  • 18.7k
3 votes

Web CS50 Project 1: 'flask.cli.NoAppException' flask app with sqlalchemy

Try to delete the following code in line 17. Session(app) At least it works for me in Mac.
Tommy Wong's user avatar
3 votes
Accepted

make: Nothing to be done for `caesar'

This never has anything to do with the contents of the .c file and always to do with the location or name of the file. It's a common error for new programmers. When you run the command make caesar, ...
Cliff B's user avatar
  • 68.8k
3 votes
Accepted

Checking to see if the contents of a string is an integer

I do not remember now if such a check is necessary, anyway if you want to check if a character is integer we have the function isdigit (), you can search in google about it. I would separate the ...
MARS's user avatar
  • 5,169
3 votes
Accepted

jpg's are not proper, mix of multiple images. Can anyone tell me whats wrong?"RECOVER"

EEK! A GOTO statement!!!! We'll come back to that. The second IF statement is bad. You can't simply replace every == with != to find the opposite condition of a complex logical test. If any of ...
Cliff B's user avatar
  • 68.8k
3 votes
Accepted

Valgrind error on speller

I'm going to make an educated guess here. Since it's complaining about trying to allocate 2 bytes after a 46 byte allocation, this makes me think that its failing when testing the maximum word length ...
Cliff B's user avatar
  • 68.8k
3 votes
Accepted

Enrolled in 2018, upgraded for certificate in 2019, can I still get the CS50x certificate in 2020?

Yes, your progress from 2019 will carry forward to the 2020 course, but you'll need to complete the course using the 2020 materials. We'll publish transition instructions in January (much like the ...
curiouskiwi's user avatar
  • 18.7k
3 votes
Accepted

pset4 filter reflect. runtime error: index 601 out of bounds for type 'RGBTRIPLE [width]'

Reading your code I can see that you're worried about the number of width pixels been even or not. Should you be worried? If you look at your code you can see that you're answering yourself. When ...
Tritum's user avatar
  • 1,571
3 votes
Accepted

Pset3: Tideman sort_pairs doesn't work?

preferences[pairs[i].winner][pairs[i].loser] > preferences[pairs[i+1].winner][pairs[i+1].loser] This condition swaps the elements in ascending order while check50 checks for the pairs array for ...
CSsucks's user avatar
  • 66
3 votes
Accepted

PSet5 case-insensitive using strcasecmp

Your word comparison appears to be case insensitive. What about your hash function? Is it case sensitive? ;-) If this answers your question, please click on the check mark to accept. Let's keep ...
Cliff B's user avatar
  • 68.8k
3 votes
Accepted

Pset3 - runoff - print_winner and find_min error

You return prematurely. Simply finding a vote count smaller than the max is not enough. You need to keep going until you've looked at all the candidates, and then return the smallest vote count. // ...
Fuelled_By_Coffee's user avatar

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