#!/usr/bin/env cscript
#include <inttypes.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#define ALPHABET "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

int
scan_column_index(const char column_string[3 + 1]) {
	unsigned int index, value;
	char *needle;

	for (index = 0, value = 0, needle = &column_string[strlen(column_string) - 1];
	     needle >= column_string; needle--) {
printf("@ %d\n", (strchr(ALPHABET, *needle) - ALPHABET) * pow(strlen(ALPHABET), index));
		value += (1 + strchr(ALPHABET, *needle) - ALPHABET) * pow(strlen(ALPHABET), index);
	}

	return value;
}


int
main(int argc, const char *argv[]) {
	printf("XFD -> %ld\n", scan_column_index("XFD"));
	return 0;
}