DEV Community

matthijs pouwels
matthijs pouwels

Posted on

First pseudocode lines!

Hey guys, I’ve started introduction to IT course on CodeCademy and I wrote my first pseudocode lines. I’m very curious for feedback and ideas.

This was the assignment:

  1. Take two string values called text and pattern.
  2. Search through the value of text to check if the value pattern can be found within text.
  3. Notify the user if pattern was found in text or not.

This is my solution:

  1. Input the pattern that needs to be searched
  2. To keep track of whether the text contains the pattern, establish a contains_pattern variable and initially set it to False.
  3. Has the  pattern been found? If not, continue to step 3. If so, skip to step 5.
  4. Is the current word equal to pattern? If not, go back to step 3 and continue to iterate over the entire text. If so, set the contains_pattern variable to True and then continue to step
  5. Is the contains_pattern equal to True? If not, then the pattern is not in the text. If so, then the pattern is in the text!

Would love to hear your thoughts! Any improvements or alternative approaches you'd suggest? 🚀

Top comments (0)