Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion string_1/concat-double-char/io.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,13 @@
{"input": ["dog", "go"], "output": "dogo"},
{"input": ["aa", "a"], "output": "aa"},
{"input": ["", "start"],"output": "start"},
{"input": ["end", ""], "output": "end"}
{"input": ["end", ""], "output": "end"},
{"input": ["hello", "orange"], "output": "hellorange"},
{"input": ["test", "test"], "output": "testest"},
{"input": ["abc", "def"], "output": "abcdef"},
{"input": ["a", "a"], "output": "a"},
{"input": ["a", "b"], "output": "ab"},
{"input": ["a", "A"], "output": "aA"},
{"input": ["end.", ".start"], "output": "end.start"},
{"input": ["hello ", " orange"], "output": "hello orange"}
]
4 changes: 3 additions & 1 deletion string_1/concat-double-char/starter.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
def concat_no_double(a: str, b: str) -> str:
def concat_no_double(a: str, b: str) -> str:
# Your code here
pass
15 changes: 15 additions & 0 deletions string_1/double-n-th/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Write a function `double_nth(str: str, n: int) -> str` that takes 2 inputs: a string `str` and an integer `n` . The function looks at the string and counts letters starting from 1 (not 0), restarting from 1 everytime `n` is reached. It should return a new string where every `n`-th character is repeated based on the following conditions:

- If everything is normal, return a string with every `n`-th character repeated.
- If `n` is greater than the string length, return the original string.
- If `n` is less than or equal to 0, return `""`.
- if `str` is empty, return `""`.


For example:
- `double_nth("programming", 2)` → `"prroggraammminng"`
- `double_nth("hi", 3)` → `"hi"`
- `double_nth("bonjour", -2)` → `""`
- `double_nth("null", 0)` → `""`
- `double_nth("", -2)` → `""`

28 changes: 28 additions & 0 deletions string_1/double_n-th/io.json → string_1/double-n-th/io.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,33 @@
{
"input": ["", -1],
"output": ""
},
{
"input": ["programming", 2],
"output": "prroggraammminng"
},
{
"input": ["hi", 3],
"output": "hi"
},
{
"input": ["bonjour", -2],
"output": ""
},
{
"input": ["null", 0],
"output": ""
},
{
"input": ["", -2],
"output": ""
},
{
"input": ["abcdefg", 3],
"output": "abccdeffg"
},
{
"input": ["aaaaaa", 1],
"output": "aaaaaaaaaaaa"
}
]
File renamed without changes.
3 changes: 3 additions & 0 deletions string_1/double-n-th/starter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def double_nth(str: str, n: int) -> str:
# Your code here
pass
15 changes: 0 additions & 15 deletions string_1/double_n-th/description.md

This file was deleted.

1 change: 0 additions & 1 deletion string_1/double_n-th/starter.py

This file was deleted.

10 changes: 9 additions & 1 deletion string_1/even-length/io.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,13 @@
{"input": ["abc"], "output": false},
{"input": [""], "output": true},
{"input": ["😊😊"], "output": true},
{"input": ["x"], "output": false}
{"input": ["x"], "output": false},
{"input": ["hello!"], "output": true},
{"input": ["hello"], "output": false},
{"input": ["12345678"], "output": true},
{"input": ["1234567"], "output": false},
{"input": [" "], "output": false},
{"input": [" "], "output": true},
{"input": ["😊"], "output": false},
{"input": ["😊😊😊"],"output": false}
]
4 changes: 3 additions & 1 deletion string_1/even-length/starter.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
def is_even_length(s: str) -> bool:
def is_even_length(s: str) -> bool:
# Your code here
pass
10 changes: 9 additions & 1 deletion string_1/first-chars-or-at/io.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,13 @@
{"input": ["A"], "output": "A@"},
{"input": [""], "output": "@@"},
{"input": ["ab"], "output": "ab"},
{"input": ["😊"], "output": "😊@"}
{"input": ["😊"], "output": "😊@"},
{"input": ["Hi"], "output": "Hi"},
{"input": ["H"], "output": "H@"},
{"input": [" "], "output": " @"},
{"input": [" "], "output": " "},
{"input": ["X"], "output": "X@"},
{"input": ["XY"], "output": "XY"},
{"input": ["Good"], "output": "Go"},
{"input": ["G "], "output": "G "}
]
4 changes: 3 additions & 1 deletion string_1/first-chars-or-at/starter.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
def first_two(s: str) -> str:
def first_two(s: str) -> str:
# Your code here
pass
10 changes: 9 additions & 1 deletion string_1/first-last-n-chars/io.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,13 @@
{"input": ["Python", 1], "output": "Pn"},
{"input": ["edge", 2], "output": "edge"},
{"input": ["abc", 0], "output": ""},
{"input": ["aabbcc", 3], "output": "aabbcc"}
{"input": ["aabbcc", 3], "output": "aabbcc"},
{"input": ["abcdef", 2], "output": "abef"},
{"input": ["hello", 4], "output": "hellello"},
{"input": ["world", 5], "output": "worldworld"},
{"input": ["test", 1], "output": "tt"},
{"input": ["example", 3], "output": "exaple"},
{"input": ["data", 2], "output": "data"},
{"input": ["x", 1], "output": "xx"},
{"input": ["openai", 0], "output": ""}
]
4 changes: 3 additions & 1 deletion string_1/first-last-n-chars/starter.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
def front_back_n(s: str, n: int) -> str:
def front_back_n(s: str, n: int) -> str:
# Your code here
pass
5 changes: 0 additions & 5 deletions string_1/first-two/description.md

This file was deleted.

7 changes: 0 additions & 7 deletions string_1/first-two/io.json

This file was deleted.

10 changes: 0 additions & 10 deletions string_1/first-two/meta.json

This file was deleted.

1 change: 0 additions & 1 deletion string_1/first-two/starter.py

This file was deleted.

12 changes: 10 additions & 2 deletions string_1/front-again/io.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
[
{"input": ["edited"], "output": true},
{"input": ["edit"], "output": false},
{"input": ["level"], "output": true},
{"input": ["level"], "output": false},
{"input": ["aa"], "output": true},
{"input": ["abcab"], "output": false}
{"input": ["abcab"], "output": true},
{"input": ["noon"], "output": false},
{"input": ["hello"], "output": false},
{"input": ["hellohe"], "output": true},
{"input": ["abxxab"], "output": true},
{"input": ["abab"], "output": true},
{"input": ["eoe"], "output": false},
{"input": ["testtest"], "output": false},
{"input": [""], "output": true}
]
4 changes: 3 additions & 1 deletion string_1/front-again/starter.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
def front_again(s: str) -> bool:
def front_again(s: str) -> bool:
# Your code here
pass
9 changes: 6 additions & 3 deletions string_1/fuzzy-first-char/description.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Write a function `start_word(s: str, word: str) -> str` that returns the beginning of `s` if `word` **matches** `s` at the front **except** the first character need not match.
If it matches, return that front portion of `s`; otherwise return an empty string.
The parameter `word` is at least length 1.
Write a function `start_word(s: str, word: str) -> str` that does the following:

* Check if the substring of `s` starting from the second character matches the substring from `word` starting from its second character.
* If it matches, return the first part of `s` that has the same length as word.
* If it doesn't match, return an empty string `""`

Examples:
* `("hippo", "hi")` → `"hi"`
* `("hippo", "xip")` → `"hip"`
12 changes: 10 additions & 2 deletions string_1/fuzzy-first-char/io.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
[
{"input": ["hippo", "hi"], "output": "hi"},
{"input": ["hippo", "xip"], "output": "hip"},
{"input": ["hippo", "zip"], "output": ""},
{"input": ["hippo", "zip"], "output": "hip"},
{"input": ["h", "a"], "output": "h"},
{"input": ["abc", "abc"], "output": "abc"}
{"input": ["abc", "abc"], "output": "abc"},
{"input": ["abc", "xbc"], "output": "abc"},
{"input": ["abc", "axc"], "output": ""},
{"input": ["a", "a"], "output": "a"},
{"input": ["a", "b"], "output": "a"},
{"input": ["a", "ab"], "output": ""},
{"input": ["hello", "he"], "output": "he"},
{"input": ["hello", "xe"], "output": "he"},
{"input": ["hello", "helloo"], "output": ""}
]
4 changes: 3 additions & 1 deletion string_1/fuzzy-first-char/starter.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
def start_word(s: str, word: str) -> str:
def start_word(s: str, word: str) -> str:
# Your code here
pass
11 changes: 10 additions & 1 deletion string_1/greeting/io.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,14 @@
{"input": ["Bob"], "output": "Hello Bob!"},
{"input": ["Alice"], "output": "Hello Alice!"},
{"input": ["Eric"], "output": "Hello Eric!"},
{"input": [""], "output": "Hello !"}
{"input": ["John Doe"], "output": "Hello John Doe!"},
{"input": ["Jane Smith"], "output": "Hello Jane Smith!"},
{"input": ["O'Neil"], "output": "Hello O'Neil!"},
{"input": ["Li"], "output": "Hello Li!"},
{"input": ["Anne-Marie"], "output": "Hello Anne-Marie!"},
{"input": ["😊"], "output": "Hello 😊!"},
{"input": ["123"], "output": "Hello 123!"},
{"input": ["Dr. Robert"], "output": "Hello Dr. Robert!"},
{"input": [" "], "output": "Hello !"},
{"input": ["Jean-Luc"], "output": "Hello Jean-Luc!"}
]
4 changes: 3 additions & 1 deletion string_1/greeting/starter.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
def hello_greeting(name: str) -> str:
def hello_greeting(name: str) -> str:
# Your code here
pass
11 changes: 9 additions & 2 deletions string_1/half-digit/io.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@

[
{"input": ["123abc"], "output": true},
{"input": ["12a3bc"], "output": false},
{"input": ["00xx"], "output": true},
{"input": ["9Z"], "output": true},
{"input": ["ab12"], "output": false}
{"input": ["ab12"], "output": false},
{"input": ["4567abcd"], "output": true},
{"input": ["1234abcd"], "output": true},
{"input": ["123x5678"], "output": false},
{"input": ["0000zzzz"], "output": true},
{"input": ["98765432"], "output": true},
{"input": [" "], "output": false},
{"input": ["12ab34cd"], "output": false},
{"input": ["11112222"], "output": true}
]
4 changes: 3 additions & 1 deletion string_1/half-digit/starter.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
def is_half_digit(s: str) -> bool:
def is_half_digit(s: str) -> bool:
# Your code here
pass
3 changes: 0 additions & 3 deletions string_1/halve-string/description.md

This file was deleted.

7 changes: 0 additions & 7 deletions string_1/halve-string/io.json

This file was deleted.

10 changes: 0 additions & 10 deletions string_1/halve-string/meta.json

This file was deleted.

1 change: 0 additions & 1 deletion string_1/halve-string/starter.py

This file was deleted.

10 changes: 9 additions & 1 deletion string_1/html-tagged/io.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,13 @@
{"input": [""], "output": "<>"},
{"input": ["123"], "output": "<123>"},
{"input": ["<tag>"], "output": "<<tag>>"},
{"input": ["&"], "output": "<&>"}
{"input": ["&"], "output": "<&>"},
{"input": ["hello world"], "output": "<hello world>"},
{"input": ["!"], "output": "<!>"},
{"input": ["a"], "output": "<a>"},
{"input": ["<>"], "output": "<<>>"},
{"input": ["{}"], "output": "<{}>"},
{"input": ["<>123"], "output": "<<>123>"},
{"input": ["😀"], "output": "<😀>"},
{"input": ["<tag>"], "output": "<<tag>>"}
]
4 changes: 3 additions & 1 deletion string_1/html-tagged/starter.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
def html_bracket(s: str) -> str:
def html_bracket(s: str) -> str:
# Your code here
pass
15 changes: 14 additions & 1 deletion string_1/ly-ending/io.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,18 @@
{"input": ["sad"], "output": false},
{"input": ["fly"], "output": true},
{"input": ["LY"], "output": false},
{"input": ["ly"], "output": true}
{"input": ["ly"], "output": true},
{"input": ["apply"], "output": true},
{"input": ["flyer"], "output": false},
{"input": ["lyric"], "output": false},
{"input": ["daily"], "output": true},
{"input": ["ally"], "output": true},
{"input": ["delay"], "output": false},
{"input": ["lying"], "output": false},
{"input": ["family"], "output": true},
{"input": ["only"], "output": true},
{"input": ["slyly"], "output": true},
{"input": [" "], "output": false},
{"input": ["bully"], "output": true},
{"input": ["flyby"], "output": false}
]
4 changes: 3 additions & 1 deletion string_1/ly-ending/starter.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
def ends_with_ly(word: str) -> bool:
def ends_with_ly(word: str) -> bool:
# Your code here
pass
10 changes: 9 additions & 1 deletion string_1/make-abba/io.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,13 @@
{"input": ["Yo", "Alice"], "output": "YoAliceAliceYo"},
{"input": ["What", "Up"], "output": "WhatUpUpWhat"},
{"input": ["", "X"], "output": "XX"},
{"input": ["X", ""], "output": "XX"}
{"input": ["X", ""], "output": "XX"},
{"input": ["a", "b"], "output": "abba"},
{"input": ["hello", "world"], "output": "helloworldworldhello"},
{"input": ["123", "456"], "output": "123456456123"},
{"input": ["repeat", "repeat"], "output": "repeatrepeatrepeatrepeat"},
{"input": ["first", "second"], "output": "firstsecondsecondfirst"},
{"input": ["abc", "def"], "output": "abcdefdefabc"},
{"input": ["x", "y"], "output": "xyyx"},
{"input": ["dog", " "], "output": "dog dog"}
]
Loading
Loading