« first day (2375 days earlier)      last day (497 days later) » 

04:15
In the nub sieve implementation (⍳⍤≢=⍳⍨)⍤(∪⍳1/⊢) in aplwiki.com/wiki/Nub_Sieve, isn't the ∪⍳ part redundant?
04:36
@rabbitgrowth What is (∪⍳1/⊢) trying to do anyway? Doesn't (⍳∘≢=⍳⍨) alone work?
Anyway, (∪⍳1/⊢) is the same as (∪⍳(1/⊢)), which gives the indices of where each element first occurs. Though, isn't (∪⍳⊢) the same? Not sure what 1/⊢ is doing there. Maybe something to do with a non-Dyalog APL?
I think 1/⊢ converts a scalar to a 1-vector? I'm not sure why ∪⍳ is needed at all
@rabbitgrowth Ah, nice catch!
Yeah, why? ∪⍳ does seem weird.
Also don't understand the comment ⍝ Pre-correction of "bad meme" (⍳≢⍵)=⍵⍳⍵
(∪⍳1/⊢) is a nice way to shove your data into the integer domain using the smallest set of indices possible. Not sure why that's needed here, but it's nifty on its own.
04:52
∪⍳ part makes it work for string/char array
05:03
Doesn't (⍳∘≢=⍳⍨) alone work on string/char arrays too?
(⍳≢⍵)=⍵⍳⍵ is equivalent to (⍳∘≢=⍳⍨) for sure
05:13
@rabbitgrowth Yes, but the second line (2≠/¯1,⌈\)⍤(∪⍳1/⊢) won't work if without ∪⍳1/⊢, so it is there to show how the optimized version is derived
thus this is why it is stated as "pre correction"
05:31
Ah, I see
The "optimized" version actually seems to be slower though?
      f←(⍳⍤≢=⍳⍨)⍤(∪⍳1/⊢)
      g←(2≠/¯1,⌈\)⍤(∪⍳1/⊢)
      x←⎕A[?1000⍴26]
      cmpx'f x' 'g x'
  f x → 2.0E¯6 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  g x → 2.9E¯6 | +41% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
 
1 hour later…
06:46
@B.Wilson Without you get unpredictable results due to ⎕CT.
@Adám Both and take ⎕CT as an implicit arg, right? I'm not immediately seeing what you're talking about.
Yes, but consolidates values into ⎕CT-distinct values.
07:05
See Roger's presentation Tolerant Unique and Index-Of on Multiple Floats.
08:01
@Adám More wisdom from above :D Thank you.
08:15
Thank you!
08:31
Ah, so "bad meme" means "widespread but problematic expression"
09:11
Yes.
09:45
just realized my solution to the float->function is the same as the one on aplcart, is that an issue?
No. But you could comment it to show you know what you're doing.
comment as in Left/Right with strings, or are actual comments allowed?
I don't even know what problem you're talking about. Is this in Phase 1?
yes
oh I wrote function instead of fraction
1.7
Oh, then don't worry about it.
09:50
alright thanks
Lol. "How I won the 2023 APL Problem Solving Competition": ]aplcart and bothering @Adám.
It's my job.
@B.Wilson "I stole 2.1.3 from this nice article and changed it just enough for the judges not to notice"
(not true)
I actually somewhat dislike the solution there, it's way too complicated
but obviously it's there to showcase dyadic transpose, not to be a good solution
Hahaha. Kind of only partial jokes. I mean, it definitely says something positive about the community if there's enough material out there that it starts impinging on competition problem sets.
I was also wondering on when will Quests catch up with competitions
it would be really funny if 2024 problems were done during the 2024 competition
10:11
Next year.
 
4 hours later…
14:50
@rabbitgrowth I tested on 18.2
      cmpx'f x' 'g x'
  f x → 3.6E¯6 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  g x → 3.2E¯6 | -10% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
I wonder if you are using an unreleased version lol
Welcome to APL Quest 2020-8! Today's quest is Zigzag Numbers:
> A zigzag number is an integer in which the difference in magnitude of each pair of consecutive digits alternates from positive to negative or negative to positive.
Write a function that takes a single integer greater than or equal to 100 and less than 10¹⁵ as its right argument and returns a 1 if the integer is a zigzag number, 0 otherwise.
Note the upper bound, which is to ensure that our value is represented exactly as an integer.
{∧/0>2×/2-/10⊥⍣¯1⊢⍵}
Heh, that's clever.
I went with a much more straight-forward approach, step-by-step until the result.
I had {2∧.=|2-/×2-/10⊥⍣¯1⊢⍵}
@LdBeth I was on 18.1 I think
Yes, that's exactly the same way as mine, save for spelling differences.
@rabbitgrowth Unlikely. Maybe 18.0, which is much faster than 18.2 for certain things.
15:04
If it is 18.0 there are some magic optimization on , I remember
I don't remember about specifically, but many things, yes.
The wiki article on nub is written back in the 2019
@rabbitgrowth I like the inner product!
someone wants to compare speed of these two?
no noticable difference.
I have 1=≢∪{⍵<10:1⋄(∇⌊⍵÷100),-×-⌿(2⍴10)⊤100|⍵} btw
Time for some haskell
15:11
oh. needs to be 1=∘≢∘∪{⍵<10:1⋄(∇⌊⍵÷100),-×-⌿(2⍴10)⊤100|⍵}
Maybe {⍵<10:⍬⋄(-∇⌊⍵÷10),-×-⌿(2⍴10)⊤100|⍵}
this approach is much slower
@LdBeth Why doesn't the (2⍴10) strip all but the last two digits?
@LdBeth that doesn't work
@Richard only looking at the last 2 anyway: 100|
Restate fixed answer 1=∘≢∘∪{⍵<10:⍬⋄(-∇⌊⍵÷10),-×-⌿(2⍴10)⊤⍵}
15:17
I wonder if we can get a speedup by using instead of ⊥⍣¯1
Isn't there an easier way to detect a 0 1 0 1 pattern? Couldn't think of any
but feel there should be
You could check if it is either 0 1⍴⍨≢ or 1 0⍴⍨≢
Applying de Morgan gives 1=∘≢∘∪{⍵<10:⍬⋄-(∇⌊⍵÷10),×-⌿(2⍴10)⊤⍵}
@Adám Sorry, I misremembered. I was on 18.2, 18.2.45505 specifically
      n←123 132 31115 3141514131415 3141514131414
      ]runtime -c "RS¨n" "RG¨n" "AB¨n"

  RS¨n → 1.0E¯5 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  RG¨n → 1.0E¯5 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  AB¨n → 6.9E¯6 | -32% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
{∧/0>2×/2-/r/⍨∨\0≠r←10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10⊤⍵}
15:25
{∧/0>2×/2-/r/⍨∨\0≠r←(16⍴10)⊤⍵}
Oops, I wanted n←123 132 31115 3141514131415 3141514131410 but that doesn't make a difference.
@Richard Of course, but I wanted to squeeze every little bit of gain.
Hm, could we fold the digits into two columns, and compare?
Why is it that ⊤ wants each digit mentioned?
for that reason I never use it but always go for ⍣¯1
So you can choose the width. This is essential in many cases.
15:29
ok, yes
Is {r/⍨∨\0≠r←10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10⊤⍵} supposed to be faster than {10⊥⍣¯1⊢⍵}?
and is it faster? and why?
@rabbitgrowth ah sorry, you already asked
it is just a matter of difference in (probably integer) log computation
      ]runtime -c {r/⍨∨\0≠r←(16⍴10)⊤⍵}3141514131415 {10⊥⍣¯1⊢⍵}3141514131415

  {r/⍨∨\0≠r←(16⍴10)⊤⍵}3141514131415 → 1.1E¯6 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  {10⊥⍣¯1⊢⍵}3141514131415           → 1.5E¯6 | +42% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
Yeah, ⊥⍣¯1 needs to take the logarithm and also check that the result is OK.
@rabbitgrowth That's more strange
      f←(⍳⍤≢=⍳⍨)⍤(∪⍳1/⊢)
      g←(2≠/¯1,⌈\)⍤(∪⍳1/⊢)
      x←⎕A[?1000⍴26]
      )copy dfns cmpx
/Applications/Dyalog-18.2.app/Contents/Resources/Dyalog/ws/dfns.dws saved Wed Ap
r  6 18:21:30 2022
      cmpx'f x' 'g x'
  f x → 3.7E¯6 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  g x → 3.3E¯6 | -11% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
After updated to 18.2.45505, this is what I got (on Intel Mac)
15:33
@Adám Nah, that won't work, as we need every digit compared to both neighbours.
Also it would be annoying when there's an odd number of digits
pair flip panik
Tried to make it work on all positive integers: {{(∧/2≠/⍵,0)∧~0∊⍵}×2-/10⊥⍣¯1⊢⍵}
Oh, nice.
@LdBeth I'm on an M1 MacBook, if that matters
15:41
@rabbitgrowth You could probably speed that up by using ,0/⍨⍵≤99
Anyway, I think we got this one.
Note that from 06 October, we'll start 2 hours earlier, at 13:00 UTC.
But for now, we keep the same time, including next week's 2020-9: Rise and Fall.
thanks and till next week
@Adám cool, I might be able to make it more often then!
@Adám There's more overhead here with ⊥⍣¯1 as the interpreter translates that to another APL expression and then runs that, rather than the pure C implementation of ⊤
@Adám I don't think that'd work, because in the inner dfn is the vector of signs, not the original integer. Also the ,0 is only for ⍵≤9
Oh, right, but ,0/⍨⍬≡⍵ then.
15:51
@Silas So compiling the code would make it even?
Possibly, I don't know much about compiler side of apl
It does just transform the ⊥⍣¯1 to a ⊤ though, with log to correctly replicate ⍺ :)
      f←{{(∧/2≠/⍵,0)∧~0∊⍵}×2-/10⊥⍣¯1⊢⍵}
      g←{{(∧/2≠/⍵,0/⍨⍬≡⍵)∧~0∊⍵}×2-/10⊥⍣¯1⊢⍵}
      h←{⍵≤9:1 ⋄ d←10⊥⍣¯1⊢⍵ ⋄ ⍵≤99:≠/d ⋄ 2∧.=|2-/×2-/d}
      n←1 11 12 123 132 31115 3141514131415 3141514131410
      cmpx'fgh',¨⊂'¨n'
  f¨n → 1.6E¯5 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  g¨n → 1.6E¯5 |  +3% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  h¨n → 1.3E¯5 | -18% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
Amazing, and then use r/⍨∨\0≠r←10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10⊤⍵ instead of 10⊥⍣¯1 for ultimate speed.
woo.
Well done.
15:59
I can't help giggling a bit at r/⍨∨\0≠r←10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10⊤⍵
@rabbitgrowth quirks with the emulated instruction set I guess. M1 fallbacks to use slower code since there is no AVX instructions provided by rosetta.
16:21
Hmm, maybe I should start taking my cmpx results with a grain of salt then
Btw, why is 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 faster than 16⍴10?
Because it avoids computing 16⍴10 every time.
The ready-made vector is stores as-is in the token stream.
parsing APL/J is like magic
Ah, I see
This will continue to work with the new array notation, right?
16:43
@rabbitgrowth Yes, rest assured that any changes I propose will only add to the language, not remove. Except scalar⊤. I want that to be scalar⊥⍣¯1
17:14
Yeah, seems like a waste of glyph space for scalar⊤ to do the same thing as scalar|
@Adám Not quite - the token stream has Constant N (I believe to prevent long constants limiting stream length). Still prevents recalculation!
 
1 hour later…
18:29
It seems APL was the first programming language that introduced trig functions for complex numbers dl.acm.org/doi/10.1145/390007.805368
2
 
3 hours later…
21:34
I do understand it is quite late, but I just realized that
> Participants must provide truthful and accurate information regarding contact and personal information.
might include needing to register with legal name?
cc dyalog people
 
2 hours later…
23:26
hmm I don't get the 0 as a left argument case to phase 1 p10 lol oh well too late
23:39
there's still, like, 20 minutes left, right?
yea
think so
Wonder if I should bother making my p10 not terrible
maybe not enough to make a pretty solution but probably enough to add a special case check
yep, got two of them, it's my longest solution (by lots)
@rak1507 my 1.10 is genuinely awful
55 chars long
mine is uh over 100
23:42
uh
I shouldn't try and do everything at the last minute
I may or may not have solved 2.2.4 two days ago :)
I did all of phase 2 today lol
kinda want to share all the notes I've written for the competition
@rak1507 didn't think somebody could be worse than me!
I am unbeatable when it comes to procrastinating
23:45
that's what I thought too
I basically did most of the problems on the first couple days, then forgot about the competition till a week ago
yeah I was kinda busy with uni stuff when it started and mostly forgot about it until now
and assumed it was open for all of july not just until today
"all of July" does end in like two days though
two days is many more than 0
you really are good at procrastinating:)
expert! :)
anyway goodnight, I don't even want to think about the problems now lol, too easy to overanalyse
23:52
@rak1507 a ⌊⌿⍬ relative increase!
@rak1507 maybe you're right I should not be awake at 2am waiting for the competition to end

« first day (2375 days earlier)      last day (497 days later) »