0

This seems to be a faq on this problem set, although I looked at all other answers that pertained to this problem, I have been unable to fix the error. I am having trouble with one check50 spec where by using "baz", for "World, say hello", I am getting out "xoqmd, szz gflkp". I know the problem is due to the fact that the key is incrementing with i, and fails to skip none alpha chars. I know to fix this I have to create a separate index for j, and increment when i is alpha. But i I don't know how to do that, I have tried everything and nothing seems to work.

3
  • all you need to do is to create an int variable and increment it every time an alphabetical char is encrypted. this variable should have at least the same scope as i (which I assume keeps track of the current character in the plain text). what's difficult about that? what have you tried so far?
    – kzidane
    Sep 11, 2015 at 6:00
  • yes that is exactly what I am trying to do, I have been trying to create a variable for j and increment when the alpha chars is encrypted, but I am unable to do so successfully. so if i set j = 0 and increment every time p[i] is alpha should that do the trick? the problem is that the j increments along with i, so how would i separate it to continue after only chars that are encrypted. Sep 11, 2015 at 16:00
  • I solved the problem, thanks for the help Kareem. Sep 11, 2015 at 16:20

1 Answer 1

0

This is a common question. Over in the subreddit, I posted a thread: "thinking about vigenere and nested loops... Perhaps that would give you a hint on how to handle more than one counter, with one that only increments some of the time.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .