« first day (71 days earlier)      last day (2891 days later) » 

6:34 PM
@LuisMendo There has to be a better way, right? codegolf.stackexchange.com/a/85836/51939
SEems like we need a third output from sort to indicate the location in the final array
 
7:25 PM
@Suever I think &S&Sq (on the phone now, but it works for the example)
 
7:42 PM
Yep, it seems to work for other cases (I haven't tested them all)
 
 
2 hours later…
9:19 PM
Hmm I had tried that but it didn't seem to work, I'll try again
 
9:50 PM
Putting the finally statement to good use!
0
A: Calculate the Super-Logarithm

Luis MendoMATL, 15 12 bytes 0`ZetG>~}x@q Try it online! Or verify all test cases (slightly modified version to handle several inputs). How it works Starting with 0, apply iterated exponentiation until exceeding the input. The output is the number of iterations minus 1. 0 % Push 0 ` % Do.....

 
10:31 PM
evening, @Luis
 
@beaker Hello!
 
reading up on the super-logarithm
 
Nothing terribly fancy. I just noticed that the result is essentially how many iterated exponentials are needed to exceed the input
 
i was playing around with the finally statement before... can't remember which challenge it was for
 
The only use I've found for it (but an important one) is to be able to use the index of the last iteration before it's lost when exiting the loop
 
10:39 PM
yeah, that saves you having to keep a counter
 
On a different subject: that J language looks cool. It has verbs, adverbs, conjunctions and the like :-) I might take a look at it when I have some time
 
actually taking the logarithm was longer?
 
@beaker It was 15 bytes (same as the initial version of the exponential) because 0 and 1 needed to be special-cased
 
:D
 
Perhaps special casing could be avoided somehow, but I didn't see how
Thanks for the upvote! :-)
 
10:44 PM
log(0) gives -Inf :/
:D
it's always those edge cases that get you
that dijkstra challenge would have been easy if it weren't for null inputs
 
@beaker Yes, totally. I initially asked that (but then deleted the comment when the challenge was edited)
3-output find does most of the work
I initially had a neater (but longer!) version with 2D arrays
Here, under "old version"
 
I did one kinda like that that didn't account for null
dj=@(m)nnz(m==[1:([a,b]=size(m))]'+[1:b])
 
Good use of that Octave "in-between assignment" feature!
Does it have a name?
The fact that you assign to a variable and use the value at the same time
 
i don't think so
 
Does this work? dj=@(m)nnz(m==[1:(a=size(m))]'+[1:a(2)])
It would be shorter
 
10:53 PM
it's just a side-effect that if you use a vector where it expects a scalar, it will only take the first element of the vector
 
@beaker Yes, that's nice too
But I meant the fact that you assign to a variable for later use
 
i don't know... i had problems with the operator precedence
oh
um
don't know about that either
 
I think you need two sum's rather than nnz?
 
I can't find anything relevant... I guess that the assignment just evaluates to its lhs
 
>> dj=@(m)sum(sum((m.*(m==[1:(a=size(m))]'+[1:a(2)]))));
>> dj([3 -1 3 3; 3 -1 3 1])
ans =  3
 
10:58 PM
sum(...)(:)
this is octave ;)
 
Oh, true :-)
Also, you can remove some parens
 dj=@(m)sum(sum((m.*(m==[1:a=size(m)]'+[1:a(2)])))
Or dj=@(m)sum((m.*(m==(1:a=size(m)])+(1:a(2)))(:))), that is
You should post it!
 
that doesn't get around the null problem though
 
Oh, you mean empty input?
 
yeah, and i'm getting errors trying to define the function
 
Yes. Error with empty input
 
11:01 PM
who knew a 1x0 array would mismatch a 0x1 array ;)
 
Yeah :-(
This would work except that the result is logical
dj=@(m)~~numel(m)&&sum((m.*(m==(1:a=size(m)])+(1:a(2)))(:)))
We need a short-circuiting * operator :-)
This seems to solve the issue
 dj=@(m)sum(((m=blkdiag(m,0)).*(m==[1:(a=size(m))]'+[1:a(2)]))(:))
It makes sure m is not empty by diagonally including a harmless 0
But blkdiag is long
I'm going to bed. See you! Good evening for you! @beaker
 
hehehe
g'nite @LuisMendo
 

« first day (71 days earlier)      last day (2891 days later) »