Skip to content

Greeting

Raymond Chen edited this page Aug 1, 2024 · 7 revisions

TIP102 Unit 1 Session 1 Standard (Click for link to problem statements)

Problem Highlights

  • 💡 Difficulty: Easy
  • Time to complete: 5 mins
  • 🛠️ Topics: Functions, Strings, Paramters

1: U-nderstand

Understand what the interviewer is asking for by using test cases and questions about the problem.

  • Established a set (2-3) of test cases to verify their own solution later.
  • Established a set (1-2) of edge cases to verify their solution handles complexities.
  • Have fully understood the problem and have no clarifying questions.
  • Have you verified any Time/Space Constraints for this problem?
  • The function greeting() should take a single parameter, name, and print a specific greeting message that includes the provided name.
HAPPY CASE
Input: "Michael"
Expected Output: Welcome to The Hundred Acre Wood Michael! My name is Christopher Robin.

Input: "Winnie the Pooh"
Expected Output: Welcome to The Hundred Acre Wood Winnie the Pooh! My name is Christopher Robin.

EDGE CASE
Input: "" (empty string)
Expected Output: Welcome to The Hundred Acre Wood ! My name is Christopher Robin.

2: M-atch

Match what this problem looks like to known categories of problems, e.g. Linked List or Dynamic Programming, and strategies or patterns in those categories.

This problem falls under: Function Definition and String Formatting.

3: P-lan

Plan the solution with appropriate visualizations and pseudocode.

General Idea: Define a function that takes a parameter and prints a formatted string using that parameter.

1. Define the function `greeting(name)`.
2. Use the `print()` function to display the string "Welcome to The Hundred Acre Wood {name}! My name is Christopher Robin." using the provided name.

⚠️ Common Mistakes

  • Incorrectly formatting the string (ensure it matches exactly).
  • Forgetting to pass the parameter to the function.
Clone this wiki locally