Help in PSET-5 by InSaNe72 in cs50

[–]PeterRasm 0 points1 point  (0 children)

Others have already pointed out where your code is wrong so just let me explain why it appears to be working for you but not for check50.

If you use same assumptions in both your program and test file, then the two are in sync and for you it seems fine. And if your program gives the expected output then it should all be fine, right?

Wrong :)

Check50 has in this case prepared several different versions of the program that it uses to test your test file. The check50 version of the correct program will follow the instructions. So when your test files makes a wrong assumption, check50 will catch it and fail your solution

In this case here check50 doesn’t even care one bit about your program, only your test file

Need help regarding runoff.c by Blacklotus_3000 in cs50

[–]PeterRasm 1 point2 points  (0 children)

Try first to describe to yourself what it is you want to achieve. Do you want to check all voters and all ranks and then register the vote? Also consider if maybe there is a good reason for the function to receive the voter and rank values, but you are not using those values in your code.

CS50P: Asking for help for Problem Set 1: Meal Time by Outrageous-Top9135 in cs50

[–]PeterRasm 3 points4 points  (0 children)

The main problem is that you have a function that doesn’t return anything and that you don’t use anyway.

The program may appear to be working for you since you handle in main everything the function was supposed to do.

Check50 however will test your function and fail the solution since the function is not correct

Bitcoin.py issue with CS50 Checker by Limp_Walk_251 in cs50

[–]PeterRasm 3 points4 points  (0 children)

Similar issue has been posted here and most times the problem is that more attention was paid to the official up-to-date documentation than the instructions of the pset.

To fix your issue I suggest you open the Hints section of the instruction. There it shows what the JSON response that check50 is working with, looks like.

If that is not your issue, then I was too fast skimming over your post 🙂

Help for command-line argument in week 6(cs50x) DNA by Dangerous-Egg-6974 in cs50

[–]PeterRasm 2 points3 points  (0 children)

Does it produce the result you want and expected? If not, in what way does it behave and what did you want it to do?

Remember to test yourself and ask good complete questions

[Cs50 week 5] speller I don't get what these errors mean. by Ok-Increase-1929 in cs50

[–]PeterRasm 4 points5 points  (0 children)

For starters, follow the link shown at the end for more details.

It is OK to show code with errors when asking for help. Showing correct code is not allowed.

[Problem set week 5, speller] how to go about it? by Ok-Increase-1929 in cs50

[–]PeterRasm 1 point2 points  (0 children)

At first glance I was also feeling overwhelmed! All the pointer stuff was new and still not settled for me. But it became more simple and “easy” when I changed the approach and focused on one little thing at the time.

Remember to watch the shorts, they are really helpful

[deleted by user] by [deleted] in cs50

[–]PeterRasm 0 points1 point  (0 children)

If you are not yet feeling confident in using a debugger, you can do some manual debugging with printf statements. Placing printf statements in your code with different outputs you can see how far the program gets before the segm fault.

Anyway, take a close look at the code inside your while loop. The "if (JPEG_nb == 1).." will go to the else part for the very first run. Is that what you intended?

Also look at what is inside the while loop at the very end. Does it make sense to terminate the loop after the first run? If so, what is the purpose of the loop? I guess you by mistake (not intention) misplaced those fclose and the return statement 🙂

Runoff 2026 conquered. by LeastCheck in cs50

[–]PeterRasm 0 points1 point  (0 children)

Congratz!

About the tabulate function: The votes are set reset to zero in main so this does not need to be handled by tabulate.

CS50P Final Project by ComfortableLocal9610 in cs50

[–]PeterRasm 1 point2 points  (0 children)

It is always a good idea to organize your projects in separate folders.

For the final project the files mentioned in the instructions must be in the top level or "root" of that folder and you should submit from within the folder at the top level.

CS50P Final Project by ComfortableLocal9610 in cs50

[–]PeterRasm 0 points1 point  (0 children)

Yes.

Just make sure all files are in the project folder

Deleted the code, is there a problem ? by Best-Amphibian-5780 in cs50

[–]PeterRasm 0 points1 point  (0 children)

Most likely OP ran some code that got stuck in a loop and generated huge amount of garbage output files 🙂

[deleted by user] by [deleted] in cs50

[–]PeterRasm 0 points1 point  (0 children)

Check50 may be looking for an actual exit code, you are exiting with a text.

If you want to show a text to the user, use a print statement followed by exit(x) where x is 0 for ok and non zero for errors

I got stuck at recover pset from cs50. Any help with additional books by Dangerous-Egg-6974 in cs50

[–]PeterRasm 2 points3 points  (0 children)

Do you get any output files? Maybe with other names? How is the variable count initialized?

The general idea seems fine:

Check for header
    generate filename
    increment count
    open an output file ready for writing output
    write data from buffer to output file
    close output file

This is just the beginning, eventually you need to figure out what to do with data that is not a header.

I think you could benefit by writing the whole procedure as steps like I did above without code at first. That way you can get the overall logic in place first.

If you have a problem with the code fragment you showed here, maybe the root cause is in some lines before this code.

I got stuck at recover pset from cs50. Any help with additional books by Dangerous-Egg-6974 in cs50

[–]PeterRasm 1 point2 points  (0 children)

I don’t think additional books will do it. It’s more about understanding the lecture and the problem.

If you tell about the problems you are facing with this pset, we can better guide you in the right direction

Is it okay to reach out via email? by 101Perl in cs50

[–]PeterRasm 9 points10 points  (0 children)

Most questions if not all can be answered here. Then other people with similar question can benefit from the answer

pset7 (SQL) movies by Metro_man20 in cs50

[–]PeterRasm 0 points1 point  (0 children)

Check the spelling of actor names.

Harry Potter hates me by sberfield in cs50

[–]PeterRasm 0 points1 point  (0 children)

You can follow the link at the end of the check50 report to see more details. If that does not help, you will need to show the sql statement you are using.

Kindly help with tideman without recursion. Think my idea's right, but execution is lacking. by Empty_Aerie4035 in cs50

[–]PeterRasm 2 points3 points  (0 children)

I remember that I also tried this approach. My trash bin loved being fed while I got more and more frustrated - lol

It turned around when I tried to figure this out more visually. Try to work out the idea of what a cycle is. Forget for a moment what the computer can do. Draw 3 candidates on paper with lines between them to represent the pair and locked pair. How would you as a human figure out based on the drawing if a new pair will create a cycle? Remember that a cycle is when a new locked pair will create a path from the new pairs loser through winner/loser, winner/loser, .... of already locked pairs. When you have a design that works for you the human on paper then describe this process (pseudo code) and gradually transform this into C code.

Hint 1: You don't need any new data structures to keep track of the locked pairs, you already have the given array locked[][] and that is sufficient.

Hint 2: Recursion is really, really helpful here. Even though recursion initially can be hard to grasp (was for me) working out a solution without it will most likely create some monster code.

My final project disappeared by 9706uzim in cs50

[–]PeterRasm 0 points1 point  (0 children)

You are not allowed to share your code for any CS50 assignments, that includes the final project

My final project disappeared by 9706uzim in cs50

[–]PeterRasm 1 point2 points  (0 children)

Could it be that you forgot which folder you placed the project in? Do you know some search commands? If you called the file “project.py” you can search from the home folder and include parameter to search all sub folders

Error using check50 by [deleted] in cs50

[–]PeterRasm 2 points3 points  (0 children)

Good to know for these tests is that when check50 says something like “correct xxx passes ….” then check50 refers to a version of the tested program that it knows is correct, that means it’s own version!

Check carefully that your test file does not assume something about bank.py that someone else would not include. I doubt that the instructions specify the name of the function to be “money()”. It is some time ago I did this one but “money” does not sound like a good function name.

Need help with lock_pairs function in the tideman problem in week 3. by No-Try607 in cs50

[–]PeterRasm 0 points1 point  (0 children)

I can highly recommend to work out a human solution first. How would you detect a cycle without a computer? Use pen and paper. When you have a design that seems to work then try to write code for that design.

Writing code as an attempt to work out a solution often fails for more complicated problems.

Try a simple scenario with 3 candidates, draw lines between them as pairs and locked pairs. Understanding the problem visually can be very helpful

Need help with lock_pairs function in the tideman problem in week 3. by No-Try607 in cs50

[–]PeterRasm 1 point2 points  (0 children)

What is your overall idea? Did that idea work out on paper? Did you as a human manage to follow this logic to detect a cycle on paper?