Problem Set 1: Recurring Letter

When you start a new problem set, your first instinct might be to open your computer and begin typing code right away. While this can feel productive, it often leads to frustration when things don't work as expected. Instead, take a few minutes to slow down and plan.

Here are some helpful strategies:

  1. Understand the problem clearly
    • Read the instructions carefully — twice if needed.
    • Ask yourself: What exactly is being asked?
  2. Break the problem into smaller steps
    • Think about the smallest possible actions the computer will need to perform.
    • For example: If the task is to find the first recurring letter in a word, what steps must happen first?
  3. Try solving it on paper first
    • Write out your steps in plain language (pseudocode).
    • Test your steps with a simple example before touching the keyboard.
  4. Translate your steps into code
    • Start small — write only a few lines at a time and test often.
    • Don't worry about perfection at first; get a working version, then improve it.
  5. Check your solution
    • Run it with different examples, including edge cases.
    • Ask: Does this solve the problem in all situations?

  • Read the question carefully (twice).
  • Break the task into the smallest steps.
  • Sketch or write pseudocode before coding.
  • Start small — test as you go.
  • Check your solution with different cases.

Problem Statement
Write a program that finds the first recurring letter in a string.
A recurring letter is a letter that appears more than once in the string.
The program should return the first letter that repeats. If no letter repeats, the program should return "No recurring letters found".


Instructions

  • Input: Your program should take a string (a sequence of characters).
    • Example: "computerprogramming"
  • Process:
    1. Scan through the string letter by letter.
    2. Keep track of the letters you have already seen.
    3. As soon as you find a letter that you have already seen, stop.
  • Output: Print the first recurring letter OR "No recurring letters found" if none exists.

Example Runs

Example 1:
Input:

computerprogramming

Output:

p

Explanation: "p" is the first recurring letter. It appears at positions 3 and 9.

Example 2:
Input:

abcdefg

Output:

No recurring letters found

Explanation: All letters are unique.

Example 3:
Input:

swiss

Output:

s

Explanation: "s" is the first recurring letter. It appears at positions 0 and 3.


Testing Your Program
Try these additional inputs:

  • "banana" → should return "a"
  • "apple" → should return "p"
  • "xyz" → should return "No recurring letters found"
  • "mississippi" → should return "i"

Success Criteria

  • Program correctly identifies the first recurring letter.
  • Program handles strings with no recurring letters.
  • Program works with both short and long strings.
  • Program output matches the examples.