Skip to content

Commit

Permalink
Added 30-10-2024 Solution and 31-10-2024 Question
Browse files Browse the repository at this point in the history
Added 30-10-2024 Solution and 31-10-2024 Question
  • Loading branch information
madhurimarawat authored Oct 31, 2024
1 parent 9b566f5 commit 11e5341
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 0 deletions.
41 changes: 41 additions & 0 deletions 30-10-2024/Explanation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#### **Explanation**

**"Why did ‘flaG’ get rejected?**
Because it couldn't commit to a style—half formal, half casual, and totally confused! Just like programmers: 10% web dev, 80% DSA, 10% everything else, and 100% Stack Overflow and GitHub!" 😂

We leverage Python's built-in string methods to simplify the validation process:

- `isupper()`: Checks if all letters are uppercase.
- `islower()`: Checks if all letters are lowercase.
- `istitle()`: Checks if the first letter is uppercase and all subsequent letters are lowercase.

Using these methods, we can validate capitalization usage in a single line by combining conditions with the `or` operator.

### **Step-by-Step Solution:**

1. **Input Validation:** Ensure the input `word` is a valid string.
2. **Check Capitalization Conditions:**
- Use `isupper` to validate if all letters are uppercase.
- Use `islower` to validate if all letters are lowercase.
- Use `istitle` to validate if only the first letter is uppercase.
3. **Return Result:**
- If any of the conditions return `True`, the function outputs `True`; otherwise, it outputs `False`.

### **Time and Space Complexity:**

- **Time Complexity:** \(O(n)\) – where \(n\) is the length of the word, as string methods operate in linear time.
- **Space Complexity:** \(O(1)\) – No additional space is used.

#### **Examples:**

- Input: `"USA"`
Output: `True`
Explanation: All letters are uppercase.

- Input: `"Google"`
Output: `True`
Explanation: Only the first letter is uppercase.

- Input: `"flaG"`
Output: `False`
Explanation: Capitalization does not match any defined case.
9 changes: 9 additions & 0 deletions 30-10-2024/Solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def capital_usage_validator(word):
# Check if the word meets any of the correct capitalization conditions
return word.isupper() or word.islower() or word.istitle()


# Example Test
print(capital_usage_validator("USA")) # Output: True
print(capital_usage_validator("Google")) # Output: True
print(capital_usage_validator("flaG")) # Output: False
69 changes: 69 additions & 0 deletions 31-10-2024/Question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
## Question: **Diya Harmony Pattern Printer** 🎆🪔

**Happy Diwali!**
Diwali, also known as the "Festival of Lights," is a joyous celebration in India symbolizing the triumph of light over darkness and good over evil. Homes are adorned with oil lamps, candles, and colorful decorations, making it one of the most vibrant festivals worldwide. [Learn more about Diwali here](https://www.britannica.com/topic/Diwali-Hindu-festival).

**Wishing you a bright and joyous Diwali filled with light and laughter!** 🌟✨

**Why did the diya refuse to play hide and seek?**

Because it couldn't resist shining brightly and giving away its hiding spot! 😄

**Difficulty Level:** 🟢 Beginner
**Domain:** Loops and Patterns

- Develop a program to print an engaging pattern called the "Diya Harmony Pattern."
- This pattern showcases rows of colored diyas (represented by emojis) in a symmetrical and visually pleasing arrangement.
- The user will specify the number of rows \( r \). The program should print a pattern of colored diyas based on the following rules:
- Each row will display a sequence of colored diyas, cycling through the colors available.
- If \( r \) is greater than the number of available colors (5), the program will repeat the same pattern for additional rows using the modulus operation. This ensures that the same sequence of colors continues even as the number of rows increases.

### **Input:**

- An integer \( r \) representing the number of rows (1 ≤ \( r \)).

### **Output:**

- A visually appealing arrangement of colored diyas based on the number of rows specified.

### **Examples:**

#### For \( r = 5 \):

#### Input:

```
Enter Number of Rows: 5
```

#### Output:

```
🔴 🟡 ⚪ 🟢 🔵
🟡 ⚪ 🟢 🔵 🔴
⚪ 🟢 🔵 🔴 🟡
🟢 🔵 🔴 🟡 ⚪
🔵 🔴 🟡 ⚪ 🟢
```

#### For \( r = 7 \):

#### Input:

```
Enter Number of Rows: 7
```

#### Output:

```
🔴 🟡 ⚪ 🟢 🔵 🔴 🟡
🟡 ⚪ 🟢 🔵 🔴 🟡 ⚪
⚪ 🟢 🔵 🔴 🟡 ⚪ 🟢
🟢 🔵 🔴 🟡 ⚪ 🟢 🔵
🔵 🔴 🟡 ⚪ 🟢 🔵 🔴
🔴 🟡 ⚪ 🟢 🔵 🔴 🟡
🟡 ⚪ 🟢 🔵 🔴 🟡 ⚪
```

**Note:** This can be implemented in any programming language like C, C++, Python, Java, Ruby, or others.

0 comments on commit 11e5341

Please sign in to comment.