That passed the test! Thank you!
- 8 Posts
- 21 Comments
It’s for CS50P which uses a customized VS Code. It has an automated code checker which I ran when I was done.
outputs “Just right!” when guess is correct
timed out while waiting for program to exit
Was using tabs but I went through it to make sure and seemed to be ok.
- milon@lemm.eeOPtoPython@programming.dev•Why can't I use the '|' bitwise operator in this statement?7·4 months ago
Thank you for the reply. It seems bitwise operators are somewhat of an advanced concept that I may revisit down the road.
- milon@lemm.eeOPtoPython@programming.dev•Why can't I use the '|' bitwise operator in this statement?4·4 months ago
Thanks. I think I understand why I wouldn’t want to use it in this case. But what is an example of where I can use it? This makes me think I should avoid using bitwise operators with integers and keep it to strings only, but I know that’s not true from what I’ve learned.
- milon@lemm.eeOPtoPython@programming.dev•Why can't I use the '|' bitwise operator in this statement?2·4 months ago
Thank you for breaking it down.
I’m just now sure when it is appropriate to use ‘|’. If bitwise operators can only be used with integers (and not floats), what’s an example where I can use it.
- milon@lemm.eeOPtoPython@programming.dev•Why can't I use the '|' bitwise operator in this statement?1·4 months ago
Yes I did eventually think of that as well but just wanted to understand why ‘|’ wasn’t producing the results I expected.
- milon@lemm.eeOPtoProgramming@programming.dev•Why does the for loop repeat in this recursion?1·2 years ago
Yes, that helps. Thanks. I see now how n goes from 1 to 2 to 3…etc. Now not so sure how i = 1 when the for loop starts.
- milon@lemm.eeOPtoProgramming@programming.dev•Why does the for loop repeat in this recursion?2·2 years ago
Yes - I finally caught that part about n as it’s just moving in reverse so it gets decremented. Now I’m not sure about i. In the debugger when the program gets to the for loop both n and i are equal to 1. The n I understand but i?
- milon@lemm.eeOPtoProgramming@programming.dev•Why does the for loop repeat in this recursion?1·2 years ago
Gotcha. Thanks for the explanation.
- milon@lemm.eeOPtoProgramming@programming.dev•Why does the for loop repeat in this recursion?1·2 years ago
I see. I guess my understanding was that the recursion was over after the recursive call, but it’s actually for all the code in draw().
- milon@lemm.eeOPtoProgramming@programming.dev•Why does the for loop repeat in this recursion?1·2 years ago
Thanks. I did see that. I have a general understanding of how recursion works I think where the function calls itself again and again but I don’t get why the code (for loop) below the draw(n - 1) is recursive.
- milon@lemm.eeOPtoProgramming@programming.dev•Why does the for loop repeat in this recursion?1·2 years ago
Right. I was aware it was recursion as stated in the title of my post. I had two questions specific to where the for loop returns after printing #.
- milon@lemm.eeOPtoProgramming@programming.dev•Why does the for loop repeat in this recursion?2·2 years ago
Why does the for loop return when it hits the end of the function? Isn’t the recursive portion already completed in draw(n - 1)? The rest of it is just normal non-recursive code if I understand it correctly.
- milon@lemm.eeOPtoProgramming@programming.dev•Why does the for loop repeat in this recursion?2·2 years ago
It’s supposed to be a pyramid but not my code. It’s an example of a recursive function from a CS50 lecture and I’m just trying to understand how the code works line by line.
- milon@lemm.eeOPtoProgramming@programming.dev•Why does isalpha() fail to identify an alphabetic character?2·2 years ago
Good point!
- milon@lemm.eeOPtoProgramming@programming.dev•Why does isalpha() fail to identify an alphabetic character?4·2 years ago
Ah ha! Yes, I did check the docs but I think I just glanced over that portion. Be more careful next time. Now that I took another look at the other ctype.h functions, they all return 1 or 0. I think I confused equivalent python built-in functions as those evaluated to true/false. The < is a less than sign but it seems it doesn’t render correctly on Lemmy.
- milon@lemm.eeOPtoProgramming@programming.dev•Why does isalpha() fail to identify an alphabetic character?3·2 years ago
Sorry. It’s in C. Updated post. Yes those are titles. I just included the relevant portions rather than the entire code.
The idiom allowed it to pass the checker’s tests! Thanks for your help!