Japt -m
, 13 12 bytes
-1 byte thanks to Shaggy
;¤?UÉ:Cg8+Uc
##Explanation: ;o ?UÉ:Cg8+Uc -m // Map U through the input: o // Try to create a range [1...U] ? // If that creates a range (number): UÉ // Return U-1 : // Else, return: ; C // alphabet (a...z) g // Index: 8+Uc // 8 + char-code of U
Explanation:
;o ?UÉ:Cg8+Uc
-m // Map U through the input:
o // Try to create a range [1...U]
? // If that creates a range (number):
UÉ // Return U-1
: // Else, return:
; C // alphabet (a...z)
g // Index:
8+Uc // 8 + char-code of U
Note: ;
turns C
into the lowercase alphabet