Sounds like a standard reduce to me:
Python:
def excel2num(x):
return reduce(lambda s,a:s*26+ord(a)-ord('A')+1, x, 0)
C#:
int ExcelToNumber(string x) {
return x.Aggregate(0, (s, c) => s * 26 + c - 'A' + 1 );
}
More Related Contents:
- Expand a random range from 1–5 to 1–7
- How to find list of possible words from a letter matrix [Boggle Solver]
- How to find all combinations of coins when given some dollar value [closed]
- Finding a single number in a list [duplicate]
- Algorithm to generate anagrams
- How to generate Sudoku boards with unique solutions
- Efficiently reverse the order of the words (not characters) in an array of characters
- Fastest algorithm for circle shift N sized array for M position
- How to print all possible balanced parentheses for an expression?
- complexity in terms of big O
- Why is the constant always dropped from big O analysis?
- How can building a heap be O(n) time complexity?
- Is there an O(n) integer sorting algorithm?
- Which algorithm is faster O(N) or O(2N)?
- find the only unpaired element in the array
- Determine font color based on background color
- Nearest neighbors in high-dimensional data?
- Algorithm for finding similar images
- Why does this simple shuffle algorithm produce biased results?
- design a stack such that getMinimum( ) should be O(1)
- What is the fastest way to find the closest point to a given point?
- Best Fit Scheduling Algorithm
- O(n) algorithm to find the median of n² implicit numbers
- how to find longest palindromic subsequence?
- Given two arrays a and b .Find all pairs of elements (a1,b1) such that a1 belongs to Array A and b1 belongs to Array B whose sum a1+b1 = k
- Examples of Algorithms which has O(1), O(n log n) and O(log n) complexities
- How to cartoon-ify an image programmatically?
- Is there any fast method of matrix exponentiation?
- Why use binary search if there’s ternary search?
- Algorithm for reflecting a point across a line