« first day (2340 days earlier)      last day (309 days later) » 

 
3 hours later…
11:09 AM
@Adám Very nice one, thanks!
 
 
4 hours later…
3:00 PM
Welcome to APL Quest 2020-3! Today's quest is Excel-lent Columns:
> Write a function that, given a right argument which is a character scalar or non-empty vector representing a valid character Excel column identifier between A and XFD, returns the corresponding column number.
 
{26⊥64-⍨⎕UCS ⍵}
 
Heh, what if I told you you can make that much shorter?
Nothing to do with this task, btw, just your 64-⍨⎕UCS
 
26⊥⎕A∘⍳ ?
 
Yes, indeed.
Or {26⊥⎕A⍳⍵} if you want a dfn.
 
:)
 
3:02 PM
This one is fun: ⎕A(≢⍤⊣⊥⍳)⊢
As brief as this is, the inverse is non-trivial.
We can leave that as a challenge to the underwhelmed.
Another thing that may be interesting is implementing it without
 
⎕UCS 64+{26⊥⍣¯1⊢⍵}
 
Haha. Nope.
E.g. on 26 it'll give A@
@Adám {i+.×26*¯1+⌽⍳≢i←⎕A⍳⍵} simply implements for vectors
The inverse will take significantly more code. Probably at least 5 times as much code, so I think we should call it for this week.
 
ovs
@Adám ⎕A∘dfns.adic :P
 
Yup.
 
(26⊥⎕A∘⍳)⍣¯1 also fails on 26 etc. but I'm impressed it works at all
 
3:14 PM
Yes, ⍳⍣¯1 is fun. So too ⌷⍣¯1
Anyway, see you next week for 2020-4: Take a Leap!
 
Any good example for ⌷⍣¯1 ?
 
3:31 PM
The inverse is fairly trivial of you generate all the possible column names, there are not that many. You can also then use that for the original problem. Bonus is that this technique works for array input directly. In a a production system you can precompute the column names, and if done, I think that might be the fastest solution.
 
 
2 hours later…
5:53 PM
I have {⍵<1:''⋄(∇⌊⍵÷26),⎕ucs 65+26|⍵-1} for the inverse
I guess an alternative way is with computing the three letters separately (assuming the same bounds) and then use /
 
6:21 PM
{⍵<1:'' ⋄ (∇⌊⍵÷26),⎕UCS 65+26|⍵-1}¨24 25 26 27
X  Y  AZ  AA
 
I was thinking why the upper limit to input is 'XFD'
'27*3' is far less than a signed integer
Oh so in Excel that's the upper limit
Which is '2*14' btw
 
@RubenVerg It gets tricky every 26
 
6:39 PM
@PaulMansour wat
I thought I tested it
okay this works
 {⍵<1:''⋄(∇¯1+⌈⍵÷26),⎕ucs 65+26|⍵-1}
 
@RubenVerg Nice.
 
 
5 hours later…
11:56 PM
@LdBeth 27*3? 26=≢⎕A
 

« first day (2340 days earlier)      last day (309 days later) »