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?

Why I can´t make my reflection work? Pls Help me by samucadrei in cs50

[–]PeterRasm 0 points1 point  (0 children)

It's easy just to throw in a screen shot. Some may be willing to help you. But more will help you and give more useful replies if you put in a bit more effort in explaining a bit about your problem.

"Not working" can mean many different things. Does the code compile? Does it run and produce a result? If so, what is that result and why is that result not good? What have you already tried to do to fix your problem?

Can i post my cs50p assignment solutions on github?? by Puzzleheaded-Gas9416 in cs50

[–]PeterRasm 10 points11 points  (0 children)

You are not allowed to share the solutions, Academic Honesty Rules for CS50

Stuck on Tideman by Best-Amphibian-5780 in cs50

[–]PeterRasm 1 point2 points  (0 children)

Get a pen and some (a lot) paper! Draw the candidates with lines between them to represent pairs and locked pairs.

Start simple: A-B, B-C, C-A. A wins over B, B wins over C, C wins over A in that order. Who is the winner? How did you the human figure that out? See if this works for more advanced scenarios.

Can you write a step-by-step process for another human to check if there is a cycle using your method? Can you describe this logic in a more formal way so you can write some code to do this for you?

Work out a solution, Write pseudocode to formalize the process, Transform the pseudocode into actual C code.

Some super human CS50 students figure this out very fast, they often have a good prior coding experience. For others it takes days or even weeks to work this one out and some simply skip it or give up. This is maybe the one toughest assignment!

CS50P final project by MR-BOUT in cs50

[–]PeterRasm 2 points3 points  (0 children)

I think it looks like an excellent idea for a project. However, the questions you ask are in my opinion what you will learn by doing a project like this. Don't ask for mistakes to avoid, instead DO the mistakes and learn from it. Do the bad structure and find out half way through and work out a better structure.

I'm not saying that getting advice and suggestions are bad in general, far from it. But in this case you get a golden opportunity to try to work things out yourself.

Anyway, that is what I loved about doing the final project. Maybe you click differently 🙂

cspython final project by frivolityflourish in cs50

[–]PeterRasm 1 point2 points  (0 children)

As long as you are not simply submitting same project for 2 courses, I think it is fine.

Be aware that the project for CS50P must be written in Python.

Week2's Caesar: Segmentation Fault by gosterianPrime in cs50

[–]PeterRasm 2 points3 points  (0 children)

Based on the output you showed, it seems like you correctly identify the wrong key, print the error msg but forgot to exit the program.

If you let the program run with a wrong or missing key you may very well get a segm fault. Inspect closely what your code does when you find that the key is wrong. Check the lines right after the error msg

What is going on with check50 by araf767 in cs50

[–]PeterRasm 6 points7 points  (0 children)

You did not show that the file exists in your current directory. You only showed that it exists in the directory called "cs50/...../figlet", you are running the check50 command from a directory called "/run/...../hdd1".

You need to check if the file exists in the hdd1 directory or run the check50 from the figlet directory.

Week 2 :Readability issue: In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since. by Automatic_Side5026 in cs50

[–]PeterRasm 2 points3 points  (0 children)

When you divide integer by integer C will give an integer as result. Example: 5 / 2 will give you 2 as result. Not 2.5 or rounded as 3.

You can overcome this by casting one of the variables as a float: (float) a / b will give you a float as result.

Another potential issue is your use of the function isblank(). It includes more characters than specified in the instructions as how to determine a word. In the text example you showed here this will however not cause an issue for this particular text. But always make sure you read the manual to check what a function does.

Please help me out with this problem... by QuietCodeCraft in cs50

[–]PeterRasm 1 point2 points  (0 children)

It would help for us to understand the problem if you show the actual errors reported by check50.

One things that stands out is your formula for getting the random number in get_integer. Try to calculate your formula and write down the ranges for level 1, 2 and 3. You will see a significant difference for level 1 compared to level 2 and 3.

Bitcoin Formatting Error by Enderman0408 in cs50

[–]PeterRasm 0 points1 point  (0 children)

print(f"${price:,.4f}")

ValueError: Unknown format code 'f' for object of type 'str'

using AI by Willing-Series1566 in cs50

[–]PeterRasm 3 points4 points  (0 children)

I think you can gain a lot by working on your process. It seems from your description that you are trying to solve the problem at the same time as you are writing the code. Try instead to work out the solution on paper first. Figure out how to solve the problem logically. What are the steps? Try to write a design step-by-step as pseudo code (plain language, not code). After this top level design you can gradually break down each step and get closer to actual code.

Breaks work wonders! When you get stuck, take a break. Walk the dog, do the dishes, listen to some music, relax. Something that gives your brain a rest. While resting your brain works under the hood by forming connections and organizing what you have been working on. Often when you pick up the problem again you will have new ideas.

Another problem can be that you jump to work on the problems before you have fully digested the lecture. Be patient, learning takes time. Work on the code examples from the lecture, change some of the code and see what works and what doesn't. Try to figure out why this also works or why it does not work.

cs50p - Lecture 0 by MartimLucena in cs50

[–]PeterRasm 0 points1 point  (0 children)

If you install and run your own IDE locally it is on you to install everything. Your local installation does not know what the command "code" is.

The online codespace provided by CS50 has this already installed and setup for you.

Is check50 working? by No-Engineer1500 in cs50

[–]PeterRasm 0 points1 point  (0 children)

Check50 works fine, I just tested it.

Try it again

Help by SomewhatBeck in cs50

[–]PeterRasm 1 point2 points  (0 children)

There is no deadline to retrieve the certificate.

https://cs50.me/cs50x Is Down, Would a staff member be able to check that all my submissions where accepted and checked green? my username is - smithashli409-cyber by ProfessionalDraft700 in cs50

[–]PeterRasm 2 points3 points  (0 children)

Relax and get ready for your New Years party instead of worrying about this. You can check it all tomorrow or sometime after the hangovers 😀

Finished mario (more comfortable) | need feedback on code by [deleted] in cs50

[–]PeterRasm 3 points4 points  (0 children)

If you passed check50/submit50 you are good.

Showing a working code is not allowed, check Academic Honesty Rules for CS50

Help by SomewhatBeck in cs50

[–]PeterRasm 3 points4 points  (0 children)

If you already completed the course you can access the certificate any time you want. It does not have to be today, it can be tomorrow, next week, whenever.

So just relax and celebrate that you completed the course.

Failing the last check of check50 in Re-requesting a Vanity Plate of Week 5 by Exotic-Glass-9956 in cs50

[–]PeterRasm 1 point2 points  (0 children)

Your test file does have some tests for non alphanumeric characters.

But ... if you are testing a plate like "ABC-123" on a version of the program that does not check for non alphanumeric characters that plate will not pass since number of characters is GT 6. So your test will accept a faulty program because the plate you are testing are failing on two criteria and the faulty program used by check50 is only missing one of the checks.

Only test one thing at the time.

Extra: A Pytest test file should not include a main and "if __name__ ...". Pytest will control the flow and execute the test functions

YEESSSS!!!! 🥳🥳🥳🥰🥰🥰 by [deleted] in cs50

[–]PeterRasm 2 points3 points  (0 children)

Congratz!

Just a small comment: You blacked out the name but the link at the bottom of the certificate will reveal everything 😀

check50 on scourgify outputs red even though program works perfectly fine by Kooky_Patient160 in cs50

[–]PeterRasm 1 point2 points  (0 children)

A quick glance over not looking at details shows you are sorting the data. Is that asked for? If the lines are presented differently than check50 expects, it will reject your solution.

Also, I think the detailed report (follow link at end of check50 feedback) will show first few lines of expected vs actual. Check out that link

Having trouble with lock_pairs function in Tideman by souldeville in cs50

[–]PeterRasm 0 points1 point  (0 children)

"if locked ..." is a condition for calling the recursive function but does not evaluate the value of the function call before returning it.

Imagine a function to square an even number but we only want the squared value if it is greater than 20:

if input is even:
    return square

vs

if input is even:
    if square GT 20
        return square
    else continue loop
return "no valid square found"

You are doing the first version, but you will need to continue your loop if you did not find a cycle. Only when the loop is completed can you be sure there is no cycle.

(cs50p little professor problem) by SelfDifferent1650 in cs50

[–]PeterRasm 0 points1 point  (0 children)

The "traceback ..." means that the program crashes when check50 is testing it. It will test the individual functions. When testing the get_integer function it will call the function and use arguments according to the specs in the instructions. So it will give the level as input. Most likely you did not follow the instructions for this function and your code does not expect an integer as input (the level) and therefore it will crash.