Questions tagged [cs50]

Code questions pertaining to Harvard's self-study introductory. It is STRONGLY RECOMMENDED to additionally tag with C or Python. Also consider using the spin-off https://cs50.stackexchange.com/

Note there is a spin-off site at https://cs50.stackexchange.com/. Consider joining the community and directing your questions there.


The CS50 (a.k.a. CSCI S-50) courses are computer science courses from Harvard University as part of its edX program.

There is a C library available at CS50 Library which provides support functions for the course.

There is also a Python library at CS50 Library which provides support functions for the course.

The tag should be used primarily for questions also tagged or (though the course does use some other languages too, and if there is a need, the extra languages would be valid too).

This tag should be used for questions which use the "cs50.h" header, python-cs50 or -lcs50 library. Another symptom that it is appropriate is the use of the type string (which is defined with typedef char *string; in the cs50.h header) or functions such as get_char(), get_double(), get_float(), get_string(), get_int(), get_long_long() and SQL().

The term 'pset' with a number (e.g. PSET5 — for Problem Set 5), with varying capitalizations is also often an indication that could be appropriate.

  • As an alternative to edx, there is a standalone website (called CS50x) where all the course materials and problem sets can be found.
  • There is CS50 Stack Exchange site dedicated to the course.
  • You can run CS50 programs in Visual Studio Code for CS50 (Codespaces)
  • The previous CS50 IDE has been deprecated. Use the Codespaces link above instead. For reference, here is the link to the previous CS50 IDE
  • CS50 has a "CS50 Sandbox" to run in a test environment. The CS50 Sandbox will be decommissioned on July 1, 2023. Sandbox URL: http://sandbox.cs50.io/ A suggested alternative after that date is Replit
3444 questions
0
votes
2 answers

CS50 Filter 'Edge' returns white image

I've been working on the Harvard's CS50 'Filter' problem, and have been stuck a little bit on the edges part. I've been trying to solve it using this algorithm: Go through the whole image, pixel by pixel. The image is a matrix of type RGBTRIPLE…
Mateaș Mario
  • 113
  • 1
  • 7
0
votes
1 answer

How to give arguments to a html template?

I use four arguments in quoted.html, but when I try to pass them to from my application.py, there is an error: TypeError: render_template() takes 1 positional argument but 4 were given @app.route("/quote", methods=["GET",…
WillBui
  • 5
  • 1
0
votes
1 answer

if statement being ignored, something wrong with uint8_t

the values are given by images, so typedef struct IMAGE{ uint8_t rgbtBlue; uint8_t rgbtGreen; uint8_t rgbtRed; }IMAGE; IMAGE image[height][width]; in the function, I create another 2 dimensional array. typedef struct…
akuan10
  • 111
  • 6
0
votes
2 answers

What am i missing in my C code in order to achieve the right number in Luhn’s Algorithm?

I'm new to programming, C and I'm trying to solve CS50's pset1 problem, Luhn's Algorithm to check if a credit card is valid. The example I'm using to test is this card Visa: 4003600000000014. As referred in the problem, first underline every other…
var-log
  • 31
  • 5
0
votes
1 answer

(PSET4 Filter "grayscale") What exactly is check50 saying is wrong about my code?

I'm tasked with writing a program that applies a gray scale filter to a given image. This is done by looping over each pixel and averaging the rgb values. When I check my code, I receive an error which seems to say "ERROR: expected X, received X".…
0
votes
2 answers

CS50 2021: Readability in Python wrong calculation

Probably its something totally stupid but I'm stuck and could need help from the community. In CS50 2021 Week 6 we have to do the readability calculation we already did in C. The task: "Write [...] a program that first asks the user to type in some…
0
votes
1 answer

CS50 credit.py attempting to add the sum of an string by converting to integer

Would someone please point me in the right direction regarding my sum1 variable? I'm trying to store the values of the doubled nums from the variable doubled. To me it looks like im performing the same operations I used to get the double variable,…
Powerbyte
  • 5
  • 2
0
votes
0 answers

Getting a segmentation fault on cs50's filter

I'm currently stuck on cs50's pset4 filter (less comfortable). The program compiles perfectly. I have tried out the first three parts of the code (grayscale, sepia & reflection) and their output has been as desired; however, whenever I try out blur,…
0
votes
1 answer

Pass a value from view.py to a url link in html

I am working on CS50 Web Development on the lesson of Django. I want to pass a string from view.py to HTML as the URL link here is the view.py def randompage(request, name): random_page = random.choice(util.list_entries()) return render(request,…
0
votes
1 answer

Caesar Cipher, stuck on "validating the key"

I am working on Caesar problem set in CS50 Harvard course and I am going step by step through the problem and am stuck on "validating the key". Now that you know how to read the key, let’s analyze it. Modify caesar.c such that instead of printing…
0
votes
0 answers

Edge Detection(Sobel Operator) C Help needed

I have written two different programs but none of them works can somebody please help int16_t gx[3] = {0, 0, 0}; int16_t gy[3] = {0, 0, 0}; int8_t matrix_gx[3][3] = {{-1,0,1},{-2,0,2},{-1,0,1}}; int8_t matrix_gy[3][3] =…
0
votes
1 answer

Program is finding num of sentences words and letters and calculating reading level. Bug appears when it should output "grade 8" but it output grade 9

when you input - Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, "and what is…
Mertin27
  • 1
  • 1
0
votes
1 answer

CS50 Wk4 Recover Segmentation Fault

I'm currently a student working on the wk5 pset recover for cs50. I've written out my code but have encountered a segmentation fault. How do I go about debugging this? I've checked out all the other responses on the forum but still cannot understand…
Terry Chung
  • 27
  • 1
  • 5
0
votes
0 answers

Programming C - Debugging Numbers-Strings Conversion Problems

I'm working on an exercise problem for a programming class and I'm a bit out of my depth debugging it. My main problem is that I have had to convert strings into integers and vice-versa and I don't understand well how that works. I'll attach a copy…
0
votes
2 answers

how to delete row of table in SQLITE3 using Django Shell?

in practicing using sqlite3 with django, I've created a single row via the Django Shell: # Import our flight model In [1]: from flights.models import Flight # Create a new flight In [2]: f = Flight(origin="New York", destination="London",…
Katie Melosto
  • 1,047
  • 2
  • 14
  • 35
1 2 3
99
100