I was recently asked in a job interview to resolve a programming puzzle that I thought it would be interesting to share. It\'s about translating Excel column letters to actu
This version is purely functional and permits alternative 'code' sequences, for example if you wanted to only uses the letters 'A' to 'C'. In Scala, with a suggestion from dcsobral.
def columnNumber(name: String) = {
val code = 'A' to 'Z'
name.foldLeft(0) { (sum, letter) =>
(sum * code.length) + (code.indexOf(letter) + 1)
}
}