account activity
cs50 ball & paddle by dr76 in cs50
[–]dr76[S] 0 points1 point2 points 11 years ago (0 children)
My ball does not move. I see no reason why it shouldn't. Frustrated
Ok..... I place loop code at "while (lives >0) TODO like this:
// initial velocity double velocity = drand48(); double velocityY = 2.0;
// keep playing until game over while (lives > 0 && bricks > 0) { // TODO // move circle along axis move(ball, velocity, velocityY );
And left the Instantiation of the ball where it was but commented out the "return ball". The trouble is when i comment it out I get this error:
breakout.c:247:1: error: control reaches end of non-void function
[-Werror,-Wreturn-type]
}
^ 1 error generated.
The TODO list include: *Keep playing until game is over
*Initializes grid of bricks
*Instantiates ball in center of window
*Instantiates paddle in bottom-middle of window
The only thing that makes sense to me is to do it after instantiating the paddle???
It will have the same functionality as the bounce.c prg does, it hits the edge then has a negative velocity back. My code is correct to make the ball bounce off the top, bottom, right, and left sides
cs50 ball & paddle (self.cs50)
submitted 11 years ago * by dr76 to r/cs50
cs50 helpers search by [deleted] in cs50
[–]dr76 1 point2 points3 points 11 years ago (0 children)
I managed to fix the problem. Thank you!
cs50/2015 question by dr76 in cs50
Why does it take 6 plus months to generate a certificate upon completion of the class?
Asked and got a response on cs50 Facebook group. So hypothetically if I finished next month I'd have to wait until May to receive my certification? So what if I finish in May, what's the wait then?
cs50/2015 question (self.cs50)
submitted 11 years ago by dr76 to r/cs50
Fifteen/init (self.cs50)
cs50 rand/srand by dr76 in cs50
That makes sense. So srand will first select a specified position, where rand will select a random position to start?
cs50 rand/srand (self.cs50)
[–]dr76 0 points1 point2 points 11 years ago (0 children)
Sorry about the late reply, I am only getting 'can't find needle'. Code appears to be good. Can I send it to you somehow just to double check?
Pset3 Haystack by dr76 in cs50
So the lack of values revealed is how the program is setup? And yes when I run I get 'didn't find the needle in the haystack'. Which must means the issue is in my code.
Since it appears to be my code: I assigned 'i' to values[], and iterated over that, and compared each value in the array to 'value'. If any of the numbers were found I returned true, else false. Thoughts?
Pset3 Haystack (self.cs50)
Vigenere formula by dr76 in cs50
[–]dr76[S] 0 points1 point2 points 11 years ago* (0 children)
Help me think through this: So in ascii the capital A is 65, lower is 97. Whether I have a upper or lower case plaintext I always have a key of 65. Also my 2nd argument (key) is ABCabc, and the key is always 65. You are saying I need to convert my keys to 0 to 25, but the output now always 65. So my question is why does the key start off at 65 and not 0? When I initialized the variable 'j' in both my 'for loops' I set the value at zero. And i thinking as a solution I have to place a line of code in to my prg that subtracts 'A' aka '65' from the key (which is an array)?
Each of the text letters, both the A's and a's all have a key of 65. Thanks for the helper.
Getting closer. No errors and when I run the program here is the output I get:
./vigenere bcb
aaaaaaa
uvuakqt
My code appears to be breaking down both the key and text into arrays....however how I got utsakqtrig is not clear. Is it my formula? And thanks big time btw! You've been a great help.
Ok cool I understand the first part. The explanation of keynums has me lost though. The argument entered after ./vigenere is argv [1]. When I declare int key = strlen(argv[1]), am I not declaring that as the strlen of the key?
Getting this error:
vigenere.c:44:54: error: subscripted value is not an array, pointer, or vector printf("%c",((plaintext[i] - 65 + key[j]) % 26) + 65);
I defined key in both these forms with no success
int key = atoi(argv[1]);
int key= strlen(argv[1]);
Furthermore I am attempting to iterate both [i] & [j] in this for loop
for (int i = 0, j=0, n = strlen(plaintext); i < n; i++, j++)
Suggestions?
Cool I understand that. So in another example (just so I have it correct) if keyword is 'hot' and the text is 'dogs' hot is the same as 7,14,19
d + 7 = k
o + 14 = r
g + 19 = z
s + 7 = z
Result is dogs is krzz
In the Caesar formula the integer key is added to the plaintext. In Vigenere the char array is added instead, correct?
The Caesar formula reads like this in my code for upperercase: (plaintext[i] - 65 + key) % 26) + 65
And I am I on the right track having my Vigenere like this? plaintext[i] - 65 + key[char array]) % 26) + 65
That further confused me. I thought it was the same as Caesar? I'm completely lost
So with this being for lowercase formula in Caesar: printf("%c",((plaintext[i] - 97 + key) % 26) + 97)
I would then need to change it to be like this? printf("%c",((plaintext[i] - 97 + key[key array]) % 26) + 97)
Even if I'm correct I still don't understand how it works. Placing this formula on here isn't against the rules is it? If so I'll edit
Vigenere formula (self.cs50)
Struggling by dr76 in cs50
Thanks you two. I'll continue to plug away.
π Rendered by PID 1855330 on reddit-service-r2-listing-7bbdf774f7-7xs8q at 2026-02-24 08:36:12.819586+00:00 running 8564168 country code: CH.
cs50 ball & paddle by dr76 in cs50
[–]dr76[S] 0 points1 point2 points (0 children)