I have a question concerning pset2, SUBSTITUTION. I finalized the 3 initial filters of this problem:

  • character count
  • argument count
  • non-alphabetical characters.

now I'm moving to the fourth condition to sort out of potential keys.

Could there be more than 1 way to check for repeat characters in the key? Could this be correct?

so far I have thought of 2 different ways.

Both techniques involve converting the individual elements to ascii codes and then comparing the ascii codes in pairs.

a. Use a particular element of the array as an anchor and compare it against the other 25 elements in the key. If nothing happens, repeat the cycle for a different anchor element until all 26 elements are used as anchors.

b. Use a character from the alphabet and look for it within the key. If it appears more than once, that's a trigger to stop the operation, use printf to let the user know there is a repeat element. If nothing happens, use another letter from the alphabet, repeat the verification.

thank you for any input,


1 Answer 1


Both methods described could work just fine. Another way is to check off a character from the alphabet as you loop over each character in the key. So if the first character in the key is 'B' for example, Then you might set the second index in an array to true. And then if another character in the key is also 'B', and you see that the second index in your verification array is already set to true, then you know you've encountered a duplicate.

Use whichever method you feel most comfortable using.

  • thank you @Fuelled_By_Coffee Commented Feb 15, 2022 at 16:18

You must log in to answer this question.

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