base26 =. 26&#.
alph =. ' ' , a. {~ (a. i. 'A') + i.26
efn =. base26^:_1 { alph"_
nfe =. [: base26 alph&i.
efn 65535
CRXO
nfe 'CRXO'
65535
On Sun, Oct 20, 2013 at 3:52 PM, June Kim (김창준) <[email protected]> wrote:
> Hi
>
> A SW dev company posted its hiring post on its site and there is a coding
> program for the applicants. You can choose any language you want.
>
> The problem is:
>
> Write a code that converts an order number to the excel column name. The
> number starts from 1.
>
> e.g. 1->A, 2->B, 26->Z, 27->AA, ...
>
> Having no intention for applying, I thought this was a simple but
> interesting and authentic problem. Here is my solution (I included the
> inverse function as well for the fun):
>
> f=.26&#.
> efn=.'ABCDEFGHIJKLMNOPQRSTUVWXYZ' {~ }.@(1&, -&.f 1 #~ #)@(f inv)
> nfe=.[:f ' ABCDEFGHIJKLMNOPQRSTUVWXYZ'&i.
>
> efn 65535
> CRXO
> nfe 'CRXO'
> 65535
>
> Could you come up with simpler and more elegant solution? I'd like to see
> your solutions.
>
> June
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm