« first day (1885 days earlier)      last day (762 days later) » 

12:19 AM
is there an efficient method to remove middle element of an array assuming it is always having odd numbers?
 
 
3 hours later…
3:18 AM
@LdBeth What is your non-efficient technique?
 
@PaulMansour I was trying to do something like b←3 3⍴1 1 1 1 0 1 1 1 1 ⋄ {⌈/,b×⍵}⌺3 3 on a larger 2D array
but instead of fixed 3 3 I'd like to have the window size to be parametric
 
Oh, I wrongly assumed you were starting with a vector... It's not clear to me how one removes an element from a rank 2 or greater array...
I've been putting off learning stencil, probably should look at it.
Oh, is it just the vector arg?
 
the can be flatten by , so it could be just a vector of odd length with the center element removed
 
3:34 AM
cmpx '{⍵/⍨~(⍳≢⍵)∊⌈2÷⍨≢⍵}a'  '{⍵[(⍳≢⍵)~⌈2÷⍨≢⍵]}a'
  {⍵/⍨~(⍳≢⍵)∊⌈2÷⍨≢⍵}a → 7.7E¯3 |    0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  {⍵[(⍳≢⍵)~⌈2÷⍨≢⍵]}a  → 1.8E¯2 | +137% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
Looks like compression works better than bracket indexing.
I can't imagine taking and dropping and catenating would be better.
You can use = of course, don't know why I used ∊
 
They are roughly the same efficiency on 18.2
 cmpx '{⍵/⍨~(⍳≢⍵)∊⌈2÷⍨≢⍵}a'  '{⍵[(⍳≢⍵)~⌈2÷⍨≢⍵]}a'
  {⍵/⍨~(⍳≢⍵)∊⌈2÷⍨≢⍵}a → 1.1E¯6 |  0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  {⍵[(⍳≢⍵)~⌈2÷⍨≢⍵]}a  → 1.1E¯6 | -1% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
 
Oh yes, I was 18.0! I had known work had been done optimizing compression, I guess that's on hold now.
 
Guess either one would work for me, thanks!
 
I'm not sure there are many other options?
 
{a⌽1↓⍵⌽⍨a←⌊2÷⍨≢⍵} could work but still slower
But the whole thing I was writing comes out not very useful: it is an image processing function that only fixes salt & pepper noise, that means replaces small pixels of pure white or pure black with nearby ones
 
 
6 hours later…
10:05 AM
@Adám are there plans to change phase 2 to allow trains?
 
@rak1507 I'm pretty sure we used to have instructions on how to use tacit solutions. We're looking into adding those.
 
10:31 AM
@rak1507 update: the triple rank is now only a double rank :(
 
11:24 AM
@rak1507 saddest news of the year ;-;
 
12:01 PM
@Razetime made it ~60x faster though so not all bad
 
 
2 hours later…
2:09 PM
@rak1507 I've updated the Phase 2 intro to explain tacit usage.
 
@xpqz We've published your blog post
 
@RikedyP Amazeballs. Thank you
 
@Adám but why can't we submit foo←1+⊢?
 
@rak1507 Because we don't have the ability to do a syntax sanity check on that.
 
@Adám Doesn't bother me personally idk about others but I think being able to submit trains > being told your dyadic dfn is indeed a dyadic dfn
 
2:23 PM
Is it a huge bother to wrap it in {⍺()⍵} or {()⍵}?
 
no, other than aesthetics
it seems easier to not check syntax though
also, if other things are included like comments or other helper definitions, will they go through too? I want to comment the solutions, but if they're fairly short, commenting inside the function breaks it up too much imo
 
Yeah, but in previous years, we've had people fail due to simple errors like bad naming or syntax.
@rak1507 Of course. We don't pick out things from your submission, we just analyse it as-is.
 
who judges the competition?
 
@Adám this is why I think the ideal competition is entirely objective... if the submissions returned an exact score, syntax errors would be impossible and you could submit whatever you wanted
maybe code quality etc could be a tiebreaker to retain that aspect
 
isn't it how P1 works already
 
2:31 PM
@rak1507 and what do you get points for?
 
@rak1507 That would require running the solutions immediately, as with phase 1, no?
 
@Adám yes
@KamilaSzewczyk well, sort of
@RikedyP correct answers
 
We already rank based on correctness during the judging process, so it very quickly goes straight to the code quality tie breaker, as you described
since many people correctly solve many if not all of the problems
 
@rak1507 There are two objections to that. 1: We need a more capable sandboxing system than TryAPL's. 2: Some think that being able to make sure your submission is correct is part of the challenge (the superficial syntax checking was chosen as a middle ground between that camp and those that wanted phase 1 style checking).
 
@rak1507 then you'd just have n% (where n is large) of submissions needing to be tiebreaker-ed, and (100-n)% of solutions with some very small mistake that have zero chance to win
 
2:35 PM
@dzaima this is a good point, we are also able to be more lenient in small/obvious mistakes
 
@dzaima 1. have more/harder problems 2. yes, but knowing you got it wrong there and then would make it easier to fix small problems
 
also, it wouldn't anymore be an array language competition, but just a programming competition with a weird language requirement that for whatever reason has : before your usual control structures
 
@RikedyP I made a small mistake last year and there wasn't any lenience (and that was after the tests said it was 'correct')
 
Speaking of which, APL Quest is coming up in 20 mins.
 
@rak1507 if you immediately showed the score, then, if the competitiong has a long time frame, everyone trying would eventually get 100% correct. If there's a small time frame, though, there's very little (or negative) incentive to make array-y solutions, again defeating the purpose of "APL" in "APL Problem Solving Competition"
 
2:41 PM
@dzaima that's assuming the problems are easy enough, it could be hard enough that no one actually gets 100%, especially if you take into consideration speed and things
 
@rak1507 but then it's no longer accessible to its target demographic
 
@RikedyP it would still be accessible it would just also be hard? not every problem would have to be hard
 
And I don't think we'd have the resources for such a competition either.
 
@rak1507 taking speed into consideration is another option, but that'd devolve into benchmarking dozens of different ways to write the same thing in Dyalog APL
@dzaima (at least if I got to participate)
 
And should it be allowed to ⎕NA into C?
 
2:44 PM
mon.stepik.org/2021 this was a competition a couple of people here did, and look, no one got 100%
 
But only runs for 24 hours.
 
@dzaima Are you not taking part this year?
 
@dzaima as long as it was fast enough to pass, using time as a tiebreaker is probably bad for that reason
@Adám true, but even if it ran for longer there's no guarantees lots/any people would get 100%
 
@rak1507 then you run into the issue of some nice solution not passing because it needs to manually implement a non-O(n^2) scan
 
@dzaima slow solutions aren't nice imo
 
2:46 PM
not having an O(n) scan isn't nice
 
I agree
 
@rak1507 (where can i find info about how that was scored :|)
 
I think the Dyalog comp is a good compromise -- not as stressy as AoC
It's nice to have the time to try to do a good job, rather than just mad-hacking it
 
@xpqz I find it quite stressful not knowing if my solution will please the overlords or not
@xpqz yes but 'good job' is subjective and I have no guarantees that what I think is a good job will be universal
 
I think you're probably ok there :)
 
2:50 PM
I agree that a longer contest is good
I just don't agree that it can't be mostly objective
 
@rak1507 I think that Dyalog's "good job" metric is probably still a better metric of solution array-iness than any objective metric for array-iness one can think of though
 
Not that different to any run of the mill code review, right.
 
@xpqz well no, could be one of the phase 1s 'passed' and missed a crucial test case, or I didn't comment enough, or that I didn't include testing in with my solutions (what? who would do that?)...
 
@rak1507 this one was brutal
 
Which number are we on for Quest?
 
2:54 PM
@dzaima maybe, idk, they don't publish solutions
 
according to the wiki, today is 11
whoops 8
 
@dzaima dyalog could run a completely different contest about solution speed or programming speed or algorithm design or some combination of those, but I do not think that'll ever come close to measuring actual array-iness
 
8th one
 
I have a great solution! Just like all of yours!
 
2:56 PM
:)
 
I have some fun ideas, that hopefully will make today's Quest less boring.
 
I like the competition btw a lot. I am trying to reach the end of phase 1
Most difficult are the edge cases all the time
input ⍬ etc.
Sometimes you can catch them by using a conditional statement but nicer is to include it in the solution itself
 
@rak1507 Agreed. And because this happened to you last year, we've added lots of peer review to the test cases this year.
@Richard A good array-oriented solution will often "just work" on edge conditions.
 
My experience is if there's a problem in edge case in phase1, it is high chance there exists a better method
 
yes exactly. So still trying...
 
3:00 PM
Welcome to the APL Quest! This week's quest is Go Forth And Multiply:
> Write a dfn which produces a multiplication table.
 
{≢∘,¨∘.(∘.∨)⍨(/∘1)¨⍳⍵}
 
∘.×⍨⍳
 
∘.×⍨⍳
shoot ninja'd
 
:D
 
was not prepared for this one
 
3:01 PM
@Razetime That's… unusual.
 
@Razetime what have you done...
 
OK, so with the basic solution out of the way, let's have some fun:
Write it without outer product!
 
{×/¨⍳⍵ ⍵}
 
Good. How about using Rank?
 
×⍤0 1⍨⍳
 
3:02 PM
Nice.
OK, now write it using only functions, and no operators whatsoever. (You may want to use a dfn instead of a tacit function.)
 
i think i have an idea
 
It can be written as a tacit function too, though. Bonus points?
 
I want to see a J solution ...
 
To the basic problem or "without operators"?
 
{⍵ ⍵⍴(⍵/⍳⍵)×(⍵×⍵)⍴⍳⍵}
 
3:05 PM
{{⍵×⍉⍵}⍵ ⍵ ⍴⍳⍵}
 
Whoa. Both of those count, but I have a much simpler solution in mind.
 
{↑(⍳⍵)×⊂⍳⍵}
 
Nice! That's what I had in mind.
 
ah that makes more sense to tacitify
↑⍳×⊂∘⍳
 
>
 
3:06 PM
no operators
 
@Adám basic problem...
 
↑⍳×(⊂⍳)
 
@PyGamer0 i.*/i. or */~@i. I think.
 
k solution to the basic problem: {(!x)*/:!x}
and bqn: ×⌜˜↕
 
@Razetime Or (↑⊂×⊢)⍳ etc. which avoids recalculating
 
3:09 PM
yep, better
always replace × with ∧×∨
 
How about a solution that uses no arithmetic functions at all? ( and operators are allowed)
 
huh ...
 
I mean, i can change {≢∘,¨∘.(∘.∨)⍨(/∘1)¨⍳⍵} to not use arithmetic ops
 
Yes, my solution is kind of like that, but simpler. 11 chars.
I actually have two different 11-char approaches.
Down to 10.
OK, I've got another 10.
Any bids before I begin to reveal mine?
 
{≢¨,∘⍳¨⍳⍵ ⍵}
is a 12
 
3:17 PM
@Adám i read that as kids lmao
 
@Razetime That's one of mine too: ≢⍤,⍤⍳¨⍳⍤,⍨
 
cute
 
Trying something with the power operator but not working yet
 
@Adám maybe increase by one since J is zero based: */~ @: >: @ i.
 
Here's a simple one: ∘.{≢⍺/⍵/#}⍨⍳
 
3:21 PM
What is #?
 
what is the '#' doing?
 
@Adám similar one - ∘.(≢⍸⍤/)⍨⍳
 
# is a scalar reference to the root namespace.
I just used it to avoid a number, and save quotes for a char.
@dzaima Nice!
 
≢⍤⍸¨⍳∘./⍳
 
Outer replication. Noice. And shortest too (9).
@Richard I found one. Want me to reveal?
 
3:27 PM
@Adám yes ok, keep getting errors
 
∘.{≢#,⍣⍺⍣⍵⊢⍬}⍨⍳
 
I wonder if an O(n^2) solution without arithmetic is possible
 
It appends # to , times, times.
@dzaima Uh, do you have a O(<n²) solution at all?
 
@Adám I mean that the current no-arithmetic ones are all O(n^4). ∘.×⍨⍳ is O(n^2) but that of course uses arithmetic
 
Oh, I see what you mean.
@dzaima What is the complexity of ×?
 
3:32 PM
(an O(n^3) one - {↑⍵{v←⍬ ⋄ d←⍳⍵ ⋄ {v,←d⋄≢v}¨⍳⍺}¨⍳⍵})
@Adám doesn't matter as it's arithmetic :)
 
Sure, but I wonder if × isn't secretly implemented as O(n²) itself, meaning that ∘.×⍨⍳ is O(n⁴).
 
which one is fastest? The one without multiplications?
 
well, for IEEE754 64-bit floats × is O(1). Arbitrary precision multiplication is O(n log n) as of recently
 
@Richard I've very sure ∘.×⍨⍳ is fastest.
@dzaima Only on galactic scale.
 
of course.
 
3:38 PM
Here's one with a scan: {↑+\↓⍵ ⍵ ⍴⍳⍵}
 
Oh wow.
Can also be written as {↑+\↓⍵⍴⊂⍳⍵}
Or {+⍀⍵ ⍵⍴⍳⍵}
Tacit: +⍀,⍨⍴⍳
That's actually pretty cool.
 
Thanks! +⍀ is what I was looking for.
 
Two +⍀s instead of : +⍀,⍨⍴+⍀⍤⍴∘1
 
@BojanPetrović nice
 
Another fun one of that family: +⍀,⍨+\⍤⍴≢
OK, I think we've exhausted this problem. Who would have thought we'd be able to spend 45 minutes on this problem‽
See you next week for It Is a Moving Experience.
 
3:46 PM
thanks!
 
after asking for help in the k tree, here it is golfed: */:/&=:
 
Another one without arithmetic just for fun: {{≢,⍵⍴#}¨⍳⍵ ⍵}
 
@rabbitgrowth Sure, but:
{{≢,⍵⍴#}¨⍳⍵ ⍵}
{{≢,⍳⍵}¨⍳⍵ ⍵}
{≢⍤,⍤⍳¨⍳⍵ ⍵}
{≢⍤,⍤⍳¨⍳,⍨⍵}
≢⍤,⍤⍳¨⍳⍤,⍨
 
Oh wow.
 
 
2 hours later…
5:50 PM
@PyGamer0 You may or may not be interested in github.com/xpqz/dyalogk/blob/main/phase1.k
 
6:16 PM
does ⍴⍣¯1 dyadically work in any cases?
 
 
2 hours later…
8:41 PM
@BrianBED I don't think there is such a function
apparently, a function needs to be bijective to have an inverse
 
what does bijective mean?
 
9:36 PM
bijective
ah i see what you mean. i don't think ⍸ is bijective but it does also work. it picks the smallest size for an array when reversed
 

« first day (1885 days earlier)      last day (762 days later) »