[Community Puzzle] Spreadsheet Labels

Using the Excel Spreadsheet column logic you need to write a script which calculates the column position based on any number input and vice versa, calculate a number based on any word input.

Example: 1237890619700 = EXCELLENT and LKWRNM = 148020041

I am able to solve Letters to Numbers but I am unsure how to solve Numbers to Letters.
I am also able to figure out the length of word but then struggle to figure out what those letters should be.

I am hoping someone can point me in the direction of a technique or algorithm I should be looking at to solve this type of problem.

To convert from numbers to letters, it is very similar to converting a base-10 number to a base-26 number, with the reminder that it is 1-based (without 0)

If base-26 is too odd to understand, try thinking how base-16 and base-10 are inter-convertible, e.g.

They are similar but the tricky part is to handle the 1-based condition.

When you have solved this Excel puzzle, reuse your source code to solve another one:


I am not familiar with base-x is this an formula?
I can pass this challenge by brute-forcing it however it’s much too slow.

What I have attempted is continuously dividing the number by 26 until I reach a value less than 26 and that tells me how many letters are in the number eg.

var x = 1237890619700;
var count = 0;

while (x >= 26) {
    x /= 26;

Know I am trying to figure out what the letters are.

Not, if you use a binary search. While that’s not a nice solution, it will give you access to other solutions.

I’m failing the last testcase Big Numbers and Letters. I get this:


ADVBKCFT JOB YOUR PROGRAM K HAN... S K 6722172310625687000 FDSMVZLW O EKCCUIZY 660283592480108500



I first thought it was because the numbers get too big to handle for int ?

For example this custom test case fails (it is the first number from inputs):

### Standard Output Stream:

[ '1237890619700' ]


### Failure





The default code shows you how to print to the error stream. You may follow that syntax to add some code to output the values of the variables at various points of code execution for debugging. This will help you identify where the variables are not calculated as per your expectation.

I will try that, I use the console error quite a lot already. I just found it weird it passed the rest :slight_smile:

Edit: I’m using javascript. Bad choice for really big numbers it seems.