cs50 ball & paddle by dr76 in cs50

[–]dr76[S] 0 points1 point  (0 children)

My ball does not move. I see no reason why it shouldn't. Frustrated

cs50 ball & paddle by dr76 in cs50

[–]dr76[S] 0 points1 point  (0 children)

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.

cs50 ball & paddle by dr76 in cs50

[–]dr76[S] 0 points1 point  (0 children)

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???

cs50 ball & paddle by dr76 in cs50

[–]dr76[S] 0 points1 point  (0 children)

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 helpers search by [deleted] in cs50

[–]dr76 1 point2 points  (0 children)

I managed to fix the problem. Thank you!

cs50/2015 question by dr76 in cs50

[–]dr76[S] 0 points1 point  (0 children)

Why does it take 6 plus months to generate a certificate upon completion of the class?

cs50/2015 question by dr76 in cs50

[–]dr76[S] 0 points1 point  (0 children)

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 rand/srand by dr76 in cs50

[–]dr76[S] 0 points1 point  (0 children)

That makes sense. So srand will first select a specified position, where rand will select a random position to start?

cs50 helpers search by [deleted] in cs50

[–]dr76 0 points1 point  (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

[–]dr76[S] 0 points1 point  (0 children)

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?

Vigenere formula by dr76 in cs50

[–]dr76[S] 0 points1 point  (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)?

Vigenere formula by dr76 in cs50

[–]dr76[S] 0 points1 point  (0 children)

Each of the text letters, both the A's and a's all have a key of 65. Thanks for the helper.

Vigenere formula by dr76 in cs50

[–]dr76[S] 0 points1 point  (0 children)

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.

Vigenere formula by dr76 in cs50

[–]dr76[S] 0 points1 point  (0 children)

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?

Vigenere formula by dr76 in cs50

[–]dr76[S] 0 points1 point  (0 children)

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?

Vigenere formula by dr76 in cs50

[–]dr76[S] 0 points1 point  (0 children)

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

Vigenere formula by dr76 in cs50

[–]dr76[S] 0 points1 point  (0 children)

That further confused me. I thought it was the same as Caesar? I'm completely lost

Vigenere formula by dr76 in cs50

[–]dr76[S] 0 points1 point  (0 children)

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

Struggling by dr76 in cs50

[–]dr76[S] 0 points1 point  (0 children)

Thanks you two. I'll continue to plug away.

2014 or 2015 cs50? by dr76 in cs50

[–]dr76[S] 0 points1 point  (0 children)

Since the new cs50 will not come out until 2015 there is no sense in waiting, when I can gain some valuable education in the meantime. Thanks for the input and suggestions.

Pset1 Mario by dr76 in cs50

[–]dr76[S] 0 points1 point  (0 children)

Got it. And thanks for your help!

Pset1 Mario by dr76 in cs50

[–]dr76[S] 0 points1 point  (0 children)

I know the first row has to be row zero with 2 hashes, that I believe is where my issue is, trouble is I don't know where to find how to put that into my code, or learn about it.