6 kyu
Alphabet slice puzzle!
138KH!
Description:
In this kata, you need to code a function that takes two parameters, A and B, both representing letters from the English alphabet.
It is guaranteed that:
- Both letters are the same case (Either both are uppercase or both are lowercase, never a mix)
- B is always a letter that comes after A in the alphabet (or is the same letter). For instance (A="A", B="F") and (A="g", B = "g") are valid parameter sets for the function. On the other hand (a="N" b="H") is not
Your mission, if you accept it, is to write a function slice() that returns the inclusive slice of the English alphabet starting at A and ending at B. A few examples are provided for clarity:
slice("A", "B") --> "AB"
slice("D", "H") --> "DEFGH"
slice("f", "f") --> "f"
slice("x", "z") --> "xyz"
Astute readers will probably think there may be a catch given the Kyu rating on this Kata. And you would be wrong! There is not ONE catch, not TWO, But THREE catches (a-ha-ha)
- Your code can at most be two lines long
- You code can at most be 100 charaters long
- Finally, you may not use the quoting characters (' and ") as well as "str" or square braces in your code
(Note to contributors: Please inform me if there is any hack I might have missed that would allow a too-trivial solution for this to exist.)
Happy coding!
Puzzles
Strings
Functional Programming
Restricted
Similar Kata:
Stats:
Created | Apr 3, 2024 |
Published | Apr 3, 2024 |
Warriors Trained | 400 |
Total Skips | 8 |
Total Code Submissions | 2371 |
Total Times Completed | 138 |
Python Completions | 138 |
Total Stars | 16 |
% of votes with a positive feedback rating | 96% of 45 |
Total "Very Satisfied" Votes | 42 |
Total "Somewhat Satisfied" Votes | 2 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 14 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |