Pattern Recognition CS Thinking Example 3
Follow the full solution, then compare it with the other examples linked below.
Example 3
easyIdentify the pattern: Monday → M, Tuesday → T, Wednesday → W. How would you extract the first letter of any day?
Solution
- 1 Step 1: The pattern takes the first character of each string.
- 2 Step 2: In code, this would be: firstLetter = dayName[0].
Answer
Extract the first character of the string. Pattern: take index 0 of each word.
Pattern recognition in programming means noticing repeating operations that can be generalised into a single rule or function.
About Pattern Recognition
Pattern recognition is the process of identifying similarities, trends, or regularities across data or problems in order to build general solutions. By spotting what is the same across different cases, you can create reusable strategies instead of solving each case from scratch.
Learn more about Pattern Recognition →More Pattern Recognition Examples
Example 1 easy
Look at the sequence: 2, 6, 18, 54, ... Identify the pattern and predict the next number.
Example 2 mediumThree programs are described: (a) calculates total price of items in a shopping cart, (b) calculates
Example 4 mediumThree tasks all require counting items that meet a condition: counting even numbers in a list, count