maybe a silly version of efn:
(' ABCDEFGHIJKLMNOPQRSTUVWXYZ' deb@:{~ (10 $ 26)&#:) 65535
CRXO
has 10 letter maximum
----- Original Message -----
From: June Kim (김창준) <[email protected]>
To: Programming forum <[email protected]>
Cc:
Sent: Sunday, October 20, 2013 8:52:03 PM
Subject: [Jprogramming] converting excel column name to/from number
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