[Ruby] Convert alphabets to hexadecimal number + length of array

less than 1 minute read

Here is a reference when solving paiza’s problem

Convert alphabet to hexadecimal number (1 to 26)

S=”abcdefghijklmnopqrstuvwxyz” S.index(x)+1 The character string up to the 26th is made with S, and it is converted into a number depending on the number of the actual alphabet. (There seems to be a better way…)

array length

x = [1,2,3,4,5] x.length (=5) (x.length -1) (=4) You can use it with one short length.

Tags:

Updated: