Questions tagged [cs50x]
The cs50x tag has no usage guidance.
1,113
questions
0
votes
0
answers
19
views
PSET04 Filter EDGE FUNCTION HELP!
I'm doing the filter-more pset. And I got errors in the edge function. I don't know why the intensity of each channel color per pixel are different than the correct ones. Maybe, I'm doing wrong about ...
1
vote
1
answer
94
views
in the Substitution problem in Week 2 Array, I want to pass the output from a function to the main
string makecipher(string plaintext, string key1)
{
int lentext = strlen(plaintext);
// printf("%i",lentext);
char ciphertext[lentext];
for (int i = 0; i < lentext; i++)
{--some code---
...
0
votes
0
answers
12
views
PSET04-filter more Edge Function. I need help, PLEASE!
I'm very confused why my code is not working. And there are these strange errors in the results of Check50, I don't know why. I know it could be complicated to read my code due to the amount of code I ...
0
votes
0
answers
4
views
Why is this happenning while getting the RGB results? - PSET04 FILTER (BLUR FUNCTION)
I'm doing the PSET04 (Filter-Less). And I got some errors in the last function (Blur), I don't know why the RGB Colors are different than the correct ones. Please help me, i'd appreciated.
Current ...
0
votes
0
answers
28
views
Hi guy!! Could you please help me with CS50 week 3 runoff on tabulate function?
here is my code
void tabulate(void)
{
// TODO
for (int i = 0; i < voter_count; i++)
{
for (int j = 0; j < candidate_count; j++)
{
for (int k = 0; k < candidate_count; k++)
...
0
votes
1
answer
20
views
Pset5 Speller - trying to understand more about segmentation fault
I tested a piece of code to figure out what's causing the segmentation fault with the 'load' function. The code below opens the large dictionary. Then it scans and prints each string inside the ...
0
votes
1
answer
140
views
reverse .wav file not working correctly
I tried running this code to reverse the .wav audio file, but it does not work as required. Can someone explain what's wrong?
// create array of size (size) to store blocks
BYTE buffer[size];
// ...
0
votes
0
answers
119
views
Professor Code Rejected by CS50 Check50
When submitting the code to check50, I get the following error message:
":( Little Professor accepts valid level
Cause: Timed out while waiting for program to exit."
When I run the program ...
0
votes
1
answer
30
views
Problem set 4 recover producing only one image, that too is corrupted
here is my code:
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
const int BLOCK_SIZE = 512;
int main(int argc, char *argv[])
{
// ensure ...
0
votes
1
answer
242
views
Week 1 Lab 1 Population size
Im currently working on Lab 1 regarding the population size of llamas, and everything went smoothly however even though I am in the population_size folder and inside the file population.c right now, ...
1
vote
1
answer
14
views
Nested for loop not returning to parent in substitution.c
I have a nested for loop of
for(int i = 0; i < strlen(key); i++)
{
for(int j = i + 1; j < strlen(key); i++)
{
if(toupper(key[i]) == toupper(key[j]))
{
...
0
votes
1
answer
581
views
I need help to fix my selection sort code - Practice Problems (Average High Temperatures)
I need help fixing my code. I don't know what else to do, I've been trying to sort all the temps array in descending order. But I don't know what I'm doing wrong. Can you help me saying what things I ...
0
votes
0
answers
61
views
CS50 python problem set 1 bug
about the problem set 1 (bank), I have wrote the "bank" codes correct and tested several times and it works but still edx check think the codes are incorrect.
is it vocode or GitHub bug or ...
0
votes
1
answer
51
views
PSET 5 "SPELLER" : Why this hash function resulting in SEGMENTATION FAULT(core dump)?
If i run it in another smaller program it works fine( returns the key correct) but on the pset 5 speller it gives segmentation fault. why?
0
votes
1
answer
59
views
this program is supposed to be greedy algorithms that meant to count the number of coins to make the change owed = 0 , the output is always less by 1
#include <cs50.h>
#include <stdio.h>
int get_cents(void);
int calculate_quarters(int cents);
int calculate_dimes(int cents);
int calculate_nickels(int cents);
int calculate_pennies(int ...
1
vote
0
answers
1k
views
pset2 - Bulbs - reversing array turns out wrong
I managed to make the right sequence of binary code (in reverse).
Next, I do a for loop for reversing it, but it prints out wrong. I have no idea what happens, as the original array is correct, ...
0
votes
1
answer
42
views
cs50x Pset5 Speller has a memory leak that I can't find
I am currently taking CS50x and am on Pset5: Speller. My code works as intended, however when I run the check50 function my program fails Valgrind.
This is particularly confusing to me because when I ...
0
votes
0
answers
65
views
pset 3 tideman - vote function - rank int
I am having trouble figuring out how to set up the rank integer in the vote function of pset3.
I could do this to ask the user to rank the candidate, but I assume that wouldn't work with the sample ...
0
votes
1
answer
85
views
Why do the recovered images do not match (pset4 recover)
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
int main(int argc, char *argv[])
{ typedef uint8_t BYTE;
FILE *file = fopen(argv[1], "r");
int counter=0;
FILE *...
0
votes
1
answer
56
views
Pset3 runoff: why does the is_tie function work one way but the inverse does not?
I completed the problem set runoff and finally got it after initially way overthinking.
I often find myself just needing to invert/revert logic on these problem sets which is frustrating because I ...
0
votes
1
answer
38
views
Invalid vote while testing Tideman problem
am working on Tideman.c problem. When I go to test the code by doing the following:
-cd Tideman.c
-clang tideman.c -lcs50
-./tideman Alice Bob Charlie
-Number of voters: 3
-Rank 1: Alice
"Invalid ...
0
votes
1
answer
269
views
PSET2 Substitution
#include <cs50.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
int main(int argc, string argv[])
{
// Checks if there are two ...
0
votes
1
answer
459
views
expected to find "112.00" in page, but it wasn't found on PSET 9 - FINANCE
it is my first time asking here as I've tried various methods and solutions but still unable to solve this problem. I always get stuck on "buy handles valid purchase - expected to find "112....
0
votes
2
answers
51
views
Hello guys... Good day. I'm currently on the pset 4 (recover). program is working well, but the (valgrind) requirement in the check50 isn't checking
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
typedef uint8_t BYTE;
int main(int argc, char *argv[])
{
// Check that command-line arguments is 2
if (argc != 2)
...
0
votes
2
answers
198
views
Valgrind error in pset5 speller
newbie here this is my first post, I hope you guys can help me! I am stacked with speller, my program works apparently fine but the valgrind test outputs some errors that I can't understand. I have ...
0
votes
1
answer
75
views
I get Segmentation fault (core dumped) in Caesar
I'm trying to solve the Caesar pset, and I think I'm mostly on the right way, but I just started getting the error "Segmentation fault (core dumped)". I've attached the code, hopefully ...
0
votes
2
answers
17
views
Getting segmenatation fault even though i freed memory
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
typedef uint8_t BYTE;
int main(int argc, char *argv[])
{
// Only allow 2 command line arguments
if (argc != 2)
...
0
votes
2
answers
827
views
How to set loop limit on an array with unknown size
I have been thinking about looping through arrays whose sizes are not fixed in advance... for example, allowing a user to input as many elements into an array as they want.
Question 1: How would I set ...
0
votes
1
answer
101
views
CS50 PS9 finance :( buy exception raised in application: TypeError: '<' not supported between instances of 'str' and 'float'
@app.route("/buy", methods=["GET", "POST"])
@login_required
def buy():
"""Buy shares of stock"""
if request.method == "GET":
...
0
votes
1
answer
22
views
Pset 4: Why Error at end of checkcs50?
this is how my code looks. Only *filename has a malloc attached to it.
Why this valgrind error.
This is how the logs look.
0
votes
1
answer
34
views
cs50 ide problem
every time I write a code and I wnat ot run the simple programme I can't.
I tried to do everything I know, I made make hello and gcc hello.c, no one worked and give out message that tell me "bash:...
0
votes
1
answer
40
views
pset2 substitution - handles multiple duplicate characters timeout
One last issue with my Substitution code. I keep getting the following error when I run check50:
:( handles multiple duplicate characters in key
timed out while waiting for program to exit
My solution ...
0
votes
1
answer
46
views
pset2 substitution, segmentation fault
So my code for pset2 Substitution works about 99% correctly. When I ran check50, I realized that there is still an issue if the user does not type the key right after the program name at the command ...
0
votes
1
answer
21
views
pset 2 Substitution - extra char(s) in output
So I’ve figured out 99% of the code for the substitution problem. My plaintext input is being output correctly, with the correct enciphered letters and the correct case.
However, I keep getting extra ...
1
vote
2
answers
1k
views
check50 error message when testing test_fuel.py
:) test_fuel.py exist
:( correct fuel.py passes all test_fuel checks
expected exit code 0, not 2
:| test_fuel catches fuel.py returning incorrect ints in convert
can't check until a frown ...
0
votes
1
answer
171
views
Undeclared Identifier error in array
In the code below (photo), I am trying to index into the two different arrays, one with capital letters and one with lowercase letters. When I make this program, I keep getting the following error ...
0
votes
1
answer
40
views
pset 5 speller, turning frowns upside down
I thought i had wrote a correct programme for speller, check 50 says that my code compiles but that is all it does! I have been running my programme and combing through each function and I still can't ...
0
votes
1
answer
42
views
How to get accurate float average of numbers
I'm in Lecture 2 on Arrays, and I am playing with the example Professor Malan gave about taking a user's input for the number of test scores, as well as for the scores themselves, and outputting the ...
0
votes
2
answers
60
views
How to output each element of an array
In the Lecture 2 Short on Arrays, Doug Lloyd suggests that it would be a good practice problem to try to output each element of a 100-element array as an integer corresponding to its index position.
...
0
votes
1
answer
34
views
How to Add results of a for loop
any ideas on how I could add the results of a for loop in C?
I'm currently working my way through lecture 1, so I only know a few skills in C so far. My for loop does what I need it to do - it outputs ...
0
votes
1
answer
20
views
Week 7 Regular Expressions - Why is re.search(".@.", email) returning valid for "a@bc" and "aa@b"?
Why is re.search(".@.", email) returning valid for "a@bc" and "aa@b" ?
To my understanding "." is used to represent any single character except a newline. So ...
0
votes
2
answers
32
views
Mario-less Style50 problem, the test is wrong, how to solve
The problem is that style50 highlights the printf(" "); function, everything works, if there is printf("-"); it doesn't say anything, but i need there space not a line.
}
0
votes
1
answer
707
views
Readability CS50
I've coded this solution for the readability exercise of CS50 Week 2, but after three long days I really don't see where I went wrong. It compiles and calculates the right number of words, sentences ...
0
votes
1
answer
174
views
check cs50 pset9 finance buy and sell errors
:( buy handles fractional, negative, and non-numeric shares
expected status code 400, but got 200
:( buy handles valid purchase
expected to find "112.00" in page, but it wasn't found
:| sell ...
0
votes
0
answers
45
views
CS50x pset 4 - Recover = correct code, no jpegs?
I've been working on CS50x pset 4 - Recovery and check50 is saying that I have done everything correctly. The problem is that I don't see any jpgs in the folder. What do I seem to be doing wrong?
#...
0
votes
1
answer
19
views
how can i get for it reprompt if the user types negative integer or number more 8 . my code does the oppoiste of what i want it to do how do reprompt
I want to prompt user for range to print something but if it user puts negative or more 8 to reprompt.
0
votes
3
answers
108
views
cannot compile code
the code and the terminal message photo
I have tried to compile this file as an application to make number input in arrays and then get the average of these numbers but the compiler always sends this ...
0
votes
1
answer
660
views
pset3 Tideman record_preferences
Even from my view it's not the most effective solution, but I though it should work properly, however I can't really understand my mistake. Check50 says the function works incorrectly.
void ...
0
votes
1
answer
87
views
pset2 - caesar : output is providing extra symbols after specific input cases
If someone has the time to explain to me how I can fix my code that would be greatly appreciated! Thanks :)
Problems that I need help with:
1 - Program needs to accept single character inputs like 'a' ...
0
votes
1
answer
35
views
pset2 readability test not calculating correct grade
I believe I've written the readability.c program correctly to count letters, words, and sentences based on readability prompt and calculate the grade index. But whenever I test the grade index, I'm ...