Repository navigation
Fix String 2 problems #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| def camel_to_snake(s: str) -> str: | ||
| def camel_to_snake(s: str) -> str: | ||
| # Your code here | ||
| pass |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| def censor_word(s: str, word: str) -> str: | ||
| def censor_word(s: str, word: str) -> str: | ||
| # Your code here | ||
| pass |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| Write a function `contains_code_like(s)` that takes a string `s` and returns `True` if the string contains the word "code" with any character in place of the third character. Specifically, the function should return `True` if anywhere in the string `s` there is a substring that matches the pattern "co?e", where `?` stands for any single character. | ||
| Write a function `contains_code_like(s: str) -> bool` that takes a string `s` and returns `True` if the string contains the word "code" with any character in place of the third character. Specifically, the function should return `True` if anywhere in the string `s` there is a substring that matches the pattern "co?e", where `?` stands for any single character. | ||
|
|
||
| For example: | ||
| - `contains_code_like("I love to decode")` should return `True` because it contains "code". | ||
| - `contains_code_like("coding and cobe")` should return `True` because it contains "cobe" (which fits the pattern). | ||
| - `contains_code_like("coding and cobe")` should return `True` because it contains "cobe". | ||
| - `contains_code_like("cofe is life")` should return `True` because it contains "cofe". | ||
| - `contains_code_like("cone")` should return `False` because it does not contain a substring that fits the pattern. | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| def contains_code_like(s): | ||
| def contains_code_like(s: str) -> bool: | ||
| # Your code here | ||
| pass |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| def count_pairs(string, a, b): | ||
| def count_pairs(string: str, a: str, b: str) -> int: | ||
| # Your code here | ||
| pass |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| Given 2 strings `a` and `b`, return the total amount of sequences where `b` is repeated in a row. Note: the string `a` can be of any length and `b` will always be one character. | ||
| Write a function `count_repeat(a: str, b: str)` given 2 strings `a` and `b`, return the total amount of sequences where `b` is repeated in a row. Note: the string `a` can be of any length and `b` will always be one character. | ||
|
|
||
| For example: | ||
| - `count_repetition("byzzx", "z") → 1` | ||
|
Comment on lines
+1
to
4
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,26 +1,42 @@ | ||||||||||
| [ | ||||||||||
| { | ||||||||||
| "input": ["xyzcvvzx", "b"], | ||||||||||
| "output": 0 | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| "input": ["xyvxx", "x"], | ||||||||||
| { | ||||||||||
| "input": ["xyzcvvzx", "b"], | ||||||||||
| "output": 0 | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| "input": ["xyvxx", "x"], | ||||||||||
| "output": 1 | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| "input": ["xxxxvxxxxxxxvxvx", "x"], | ||||||||||
| "output": 2 | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| "input": [" ", "x"], | ||||||||||
| "output": 0 | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| "input": ["hello", "l"], | ||||||||||
| "output": 1 | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| "input": ["RAHHahh", "h"], | ||||||||||
| "output": 1 | ||||||||||
|
Comment on lines
+23
to
24
|
||||||||||
| "input": ["RAHHahh", "h"], | |
| "output": 1 | |
| "input": ["RAHHahh", "h"], | |
| "output": 1 |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,2 +1,3 @@ | ||||||
| def countRepeat(a: str, b: str) -> bool: | ||||||
|
|
||||||
| def count_repeat(a: str, b: str): | ||||||
| # Your code here | ||||||
|
||||||
| # Your code here | |
| # Your code here |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,2 +1,3 @@ | ||||||
| def count_vowels(string): | ||||||
|
|
||||||
| def count_vowels(s: str) -> int: | ||||||
| # Your code here | ||||||
|
||||||
| # Your code here | |
| # Your code here |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| Given a string and a positive integer n, return a modified string where every character at position n and its multiples is doubled. Count positions starting from 1. | ||
| Write a function `double_nth_char(text: str, n: int) -> str` given a string and a positive integer n, return a modified string where every character at position n and its multiples is doubled. Count positions starting from 1. | ||
|
|
||
| For example: | ||
| double_nth(“hello", 2) → 'heelllo' (doubles chars at positions 2,4) | ||
| double_nth('python', 3) → 'pytthonn' (doubles char at position 3,6) | ||
| double_nth('code', 1) → 'ccooddee' (doubles every char) | ||
|
|
||
| - double_nth('hello', 2) → 'heelllo' (doubles chars at positions 2,4) | ||
| - double_nth('python', 3) → 'pytthonn' (doubles char at position 3,6) | ||
| - double_nth('code', 1) → 'ccooddee' (doubles every char) | ||
|
Vysan13 marked this conversation as resolved.
Resolved
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1 +1,3 @@ | ||||||
| def double_nth_char(text: str, n: int) -> str: | ||||||
| # Your code here | ||||||
|
||||||
| # Your code here | |
| # Your code here |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1 +1,3 @@ | ||||||
| def double_letter(word): | ||||||
| def double_letter(word: str) -> str: | ||||||
| # Your code here | ||||||
|
||||||
| # Your code here | |
| # Your code here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds a test for an empty
word(expects the input string unchanged). Since""is a tricky edge case for many implementations, the problem description should explicitly document the expected behavior whenwordis empty.