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:

  1. Both letters are the same case (Either both are uppercase or both are lowercase, never a mix)
  2. 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)

  1. Your code can at most be two lines long
  2. You code can at most be 100 charaters long
  3. 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:

More By Author:

Check out these other kata created by KH!

Stats:

CreatedApr 3, 2024
PublishedApr 3, 2024
Warriors Trained400
Total Skips8
Total Code Submissions2371
Total Times Completed138
Python Completions138
Total Stars16
% of votes with a positive feedback rating96% of 45
Total "Very Satisfied" Votes42
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes1
Total Rank Assessments14
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • KH! Avatar
  • dfhwze Avatar
Ad