You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Agent Skill Examples: Counting R's in "Strawberry"
1. Direct Answer Skill
---id: skill_count_r_directtitle: Count R's in Strawberry - Direct Answertags: [skill, example, text-analysis]created: 2026-02-05updated: 2026-02-05---# Count R's in Strawberry - Direct Answer## Skill Description
Counts the letter 'r' in the word "strawberry".
## Implementation
Direct character counting by inspection.
## Answer
The word "strawberry" contains **3** letter r's:
- st**r**awbe**rr**y
- Position 3: r
- Position 7: r
- Position 8: r
## Use Case
Quick reference for letter frequency questions.
2. Grep-Based Skill
---id: skill_count_r_greptitle: Count R's in Strawberry - Grep Methodtags: [skill, example, bash, grep]created: 2026-02-05updated: 2026-02-05---# Count R's in Strawberry - Grep Method## Skill Description
Uses grep to count occurrences of 'r' in "strawberry".
## Implementation```bash#!/bin/bash# Count r's using grep with -o flag (only matching)echo"strawberry"| grep -o 'r'| wc -l
Output
3
Explanation
grep -o 'r' outputs each match on a separate line
wc -l counts the number of lines
Case-sensitive by default (use grep -io for case-insensitive)
Alternative Methods
# Case-insensitive versionecho"strawberry"| grep -io 'r'| wc -l
# Using sedecho"strawberry"| sed 's/[^rR]//g'| wc -c
# Using trecho"strawberry"| tr -cd 'rR'| wc -c
## 3. Python-Based Skill
```markdown
---
id: skill_count_r_python
title: Count R's in Strawberry - Python Method
tags: [skill, example, python, string-manipulation]
created: 2026-02-05
updated: 2026-02-05
---
# Count R's in Strawberry - Python Method
## Skill Description
Python implementation for counting 'r' characters in "strawberry".
## Implementation
```python
def count_letter(word: str, letter: str, case_sensitive: bool = True) -> int:
"""Count occurrences of a letter in a word."""
if not case_sensitive:
word = word.lower()
letter = letter.lower()
return word.count(letter)
# Example usage
word = "strawberry"
letter = "r"
count = count_letter(word, letter)
print(f"The word '{word}' contains {count} letter '{letter}'s")
# Alternative: using list comprehension
count_alt = sum(1 for char in word if char.lower() == letter.lower())
print(f"Alternative method: {count_alt}")
# Show positions
positions = [i for i, char in enumerate(word) if char.lower() == letter.lower()]
print(f"Positions: {positions}")
Output
The word 'strawberry' contains 3 letter 'r's
Alternative method: 3
Positions: [2, 6, 7]