A different, but more procedural approach is:
efn2=.'ABCDEFGHIJKLMNOPQRSTUVWXYZ'{~[:}.((<.@%&26 , 26&|) @ <:@{. ,
}.)^:(0~: {.)^:_
, and I don't like it much. :(
On Mon, Oct 21, 2013 at 10:52 AM, 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