Yeah. I suggest other people to test their solutions against mine (maybe
with >:i.1000) or (] -: u inv@u).

Pascal, what's the definition for deb?

And I'd like to see your description for correcting expressed in J. :)



On Mon, Oct 21, 2013 at 11:48 AM, Pascal Jasmin <[email protected]>wrote:

> we have kind of the same answer, but they are both wrong.  efn 26 -> Z.
>
>    ('ZABCDEFGHIJKLMNOPQRSTUVWXYZ' deb@:{~ (26)&#.^:_1) 26
> AZ
>    ('ZABCDEFGHIJKLMNOPQRSTUVWXYZ' deb@:{~ (26)&#.^:_1) 27
> AA
>    ('ZABCDEFGHIJKLMNOPQRSTUVWXYZ' deb@:{~ (26)&#.^:_1) 26^2
> AZZ
>    ('ZABCDEFGHIJKLMNOPQRSTUVWXYZ' deb@:{~ (26)&#.^:_1) 26*2
> BZ
>
> all the ones ending in Z are wrong.  The pattern for correcting them is to
> decrement letter for any preceding letter to Z except if preceeding is Z,
> and A becomes null.
>
>
>
>
> ----- Original Message -----
> From: Ganesh Rapolu <[email protected]>
> To: [email protected]
> Cc:
> Sent: Sunday, October 20, 2013 9:21:11 PM
> Subject: Re: [Jprogramming] converting excel column name to/from number
>
> My previous solution fails for multiples of 26. Here is the corrected
> version.
>
>    base26 =. 26&#.
>    alph =. 'A' , a. {~ (a. i. 'A') + i.26
>    efn =. (base26^:_1) { alph"_
>    nfe =. [: base26 alph&i.
>
>    efn 65535
> CRXO
>    nfe 'CRXO'
> 65535
>    efn 26
> AA
>
>
> On Sun, Oct 20, 2013 at 4:13 PM, Pascal Jasmin <[email protected]
> >wrote:
>
> > 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
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to