straight bash
filter: 97 chars
{ read c;i=0;while [ $c ];do eval s=({A..${c:0:1}});i=$((i*26+${#s[@]}));c=${c:1};done;echo $i;}
Usage:
echo ROFL | { read c;i=0;while [ $c ];do eval s=({A..${c:0:1}});i=$((i*26+${#s[@]}));c=${c:1};done;echo $i;}
326676
function: 98 chars
C(){ i=0;while [ $1 ];do eval s=({A..${1:0:1}});i=$((i*26+${#s[@]}));set -- ${1:1};done;echo $i;}
Usage:
C ROFL
326676
Explanation of the filter version:
read c;i=0;
Initialize the column and the total.
while [ $c ];do
while there are still column characters left
eval s=({A..${c:0:1}});
${c:0:1} returns the first character of the column; s=({A..Z}) makes s an array containing the letters from A to Z
i=$((i*26+${#s[@]}));
$((...)) wraps an arithmetic evaluation; ${#s[@]} is the number of elements in the array $s
c=${c:1};done;
${c:1} is the characters in $c after the first. done ends the while loop
echo $i
um i forget
better but dubious
Removing the 5 characters "echo " will result in the output for an input of "ROFL" being
326676: command not found
Also the i=0 is probably not necessary if you're sure that you don't have that variable set in your current shell.