« first day (1653 days earlier)      last day (175 days later) » 

12:49 AM
@Adám Yes, I did. I got the "gold trophy" icon for all the ten problems.
6 hours later…
6:57 AM
Is there a better way to find the index of max element in matrix?
@AndyS It is 163 the two byte element type. Seems 512M is still not sufficient for larger colored images
7:24 AM
@LdBeth You can get all indices of an array with ⍳⍴⍵
⋄ f←{⎕IO←0⋄(⍴⍵)⊤⊃⍒,⍵} ⋄ f 3 3⍴3 1 4 1 5 9 2 6 5
@Bubbler 1 2
@Bubbler Was just about to write that.
7:37 AM
My old brain would have gone for something along the lines of {⎕IO←0 ⋄ (⍴a)⊤(,⍵=(⌈/⌈/⍵))⍳1} .. rather more long winded, but for large arrays, potentially rather quicker
it won't exceed 64 64 though for my case.
also, when you say "the index of the max element in matrix" is it possible that there are more than 1 occurrence of the maximum value, and if so, are you interested in only the first or do you want all of them ?
It is okay with arbitrary of the maximum
I guessed the former since the code already uses ⊃⍒
@user15588729 Hi Corey Shuman. If you want to participate here, just email access@apl.chat
7:46 AM
Of course what I should have written was
{⎕IO←0 ⋄ (⍴⍵)⊤(,⍵=(⌈/⌈/⍵))⍳1}
      cmpx '{⎕IO←0 ⋄ (⍴⍵)⊤(,⍵=(⌈/⌈/⍵))⍳1}a' '{⎕IO←0⋄(⍴⍵)⊤⊃⍒,⍵}a'
  {⎕IO←0 ⋄ (⍴⍵)⊤(,⍵=(⌈/⌈/⍵))⍳1}a → 1.6E¯6 |    0% ⎕⎕⎕⎕⎕
  {⎕IO←0⋄(⍴⍵)⊤⊃⍒,⍵}a             → 1.4E¯5 | +744% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
@Razetime Finger trouble allowed you to beat me to it ! - only I saw much bigger differences. What is your a ?
100 100⍴1000?1000
cmpx 'f1 testv' 'f2 testv'
f1 testv → 6.5E¯6 | 0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
f2 testv → 1.7E¯6 | -74% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕

for `test←?64 64⍴255`
@LdBeth Use ctrl+k to get monospace font.
7:49 AM
Might forget that when pasting
Of course what you have to remember in all of this is that if you're running this expression lots of times it's worth spending time comparing the performance of different expressions. If you're running it once then the performance improvement may not be worth the time spent on experimentation - your time may be better spent elsewhere in the code !
Sure. Change this definition actually improved the time from 03.53 sec to 02.48 for my blue noise generate function, with a moderate amount of output size specified.
Deciding how big to set MAXWS is always interesting .. if you're the only person on the box and you only ever run 1 APL session in parallel then you can set it big. But in my time I've killed many a box by running too many APL processes in parallel where MAXWS is set too large and I've been close to filling all of them up !
We've done a fair amount of testing with MAXWS=90G, but I know that someone ran a simple addition in a 2T workspace where the addition needed all that space.
.. and that the 2TB was all in memory, no swapping
curious to how much time would that take, a week?
8:12 AM
I stupidly didn't ask that question; all I can say is that it was less than 4 hours .. and I think considerably less than that
@user @Adám @ZribiMehdi thank you for pointing these things out. I've clarified and fixed; changes should now be live.
@LdBeth Well, addition is limited by memory bandwidth, not by the CPU. If the RAM can sustain 10 GB/s then the whole thing should be done in under 4 mins.
9:10 AM
I tried to solve differently this Rosetta Code String Task
The original recursive solution is :
⋄'th' 'abab' 'dog'  {0=x←⊃⍸⍺⍷⍵:0 ⋄ 1+⍺∇(¯1+x+⍴⍺)↓⍵}¨ 'the three truths' 'ababababab' 'cat'
@brgal 3 2 0
I tried this :
⋄ 'th' 'abab' 'dog' {to ←{(⍵[2]@(n+1))(⊃⍵)+⍺×(×d)×0,⍳n←⌈⍺÷⍨|d←--/⍵} ⋄ ≢∪((≢⍺) to 1(≢⍵))⍸(⍸⍺⍷⍵)}¨'the three truths' 'ababababab' 'cat'
@brgal 3 2 0
@brgal You got 96% of the maximum achievable score.
@Adám Thanks for the reply. For which problems did I lose some points ?
9:15 AM
oh wait it's already used
@Razetime I do use it.
I tried to find a solution with Stencil but it is ugly.
@brgal Only for P1, where I deducted a little because you divided the Boolean vector instead of summing it first.
so if an occurrence overlaps with more than one occurrence, remove it right
@Adám Thanks for the clarification.
@brgal So it is simply {≢⍺⎕S 3⊢⍵}?
9:20 AM
has anyone ever made a programming language in apl?
@PyGamer0 See the dfns ns
@xpqz @PyGamer0 More like the dfns website: dfns.dyalog.com
@PyGamer0 I have :)
9:22 AM
there's some interpreters on code golf for multiple esolangs
Plus Joy and BF.
It also used to be fairly common to implement DSLs in APL. flipDB is a commercial application that does this.
Someone once described a language in TNB, I think, and I went and implemented it in APL in minutes.
Was never able to find the transcript location later.
@Adám Yes, you're right and it is also already in APLcart...
They suggested promoting APL as a a good language implementation language.
@Adám With Stencil and a TO fct from the dfns I got this :
{(alpha doublev)←((' ',⎕A)⍳1∘⎕C)¨⍺ ⍵ ⋄ res←{⊂(⍵≡alpha)}⌺(⍪(≢⍺)1)⊢doublev ⋄ +/0≠∪(⍸res)⍸ ( ((⊃⍸res) TO (≢res) (≢⍺)))}
9:38 AM
Iterative solution: +/∘×≢⍤⊣{(⍺↑2)@((⍳⍺)+⍵⍳1)⊢⍵}⍣{~1∊⍺}⍷
@brgal Hey, I think this reduction works: {≢⊃(⊢,⊣~⌊/⍤⊢-(⍳≢⍺)⍨)/⍸⍺⍷⍵}
:-( Fails if there are no matches.
@Adám Thanks anyway.
@brgal Fixed: {¯1+≢⊃(⊢,⊣~⌊/⍤⊢-(⍳≢⍺)⍨)/⍸⍺⍷⍺,⍵}
More efficient to do ⍵,⍺ at the end though.
@Adám does not give the right results apparently
 ⋄'th' 'abab' 'dog'   {¯1+≢⊃(⊢,⊣~⌊/⍤⊢-(⍳≢⍺)⍨)/⍸⍺⍷⍺,⍵}¨'the three truths' 'ababababab' 'cat'
9:51 AM
@brgal 2 1 0
⋄'th' 'abab' 'dog'  {0=x←⊃⍸⍺⍷⍵:0 ⋄ 1+⍺∇(¯1+x+⍴⍺)↓⍵}¨ 'the three truths' 'ababababab' 'cat'
@brgal 3 2 0
@brgal Sorry, ⎕IO←0
@Adám Sorry. I used ⎕IO←1
Of course, that's the default. My bad for not stating.
10:03 AM
@brgal Performance is interesting:
      x←'th' 'abab' 'dog'
      y←1e3⍴¨'the three truths' 'ababababab' 'cat'
      Red←{⎕IO←0 ⋄ ≢1↓⊃(⊢,⊣~⌊/⍤⊢-(⍳≢⍺)⍨)/⍸⍺⍷⍵,⍺}
      Rec←{⎕IO←1 ⋄ 0=x←⊃⍸⍺⍷⍵:0 ⋄ 1+⍺∇(¯1+x+⍴⍺)↓⍵}
      Iter←{⎕IO←1 ⋄ ∨/⍺⍷⍵:⍺(+/∘×≢⍤⊣{(⍺↑2)@((⍳⍺)+⍵⍳1)⊢⍵}⍣{~1∊⍺}⍷)⍵ ⋄ 0}
      ]runtime -c "x Red y" "x Rec y" "x Iter y"

  x Red y  → 2.7E¯6 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  x Rec y  → 1.5E¯6 | -44% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  x Iter y → 1.4E¯6 | -48% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
@Adám The same magnitude order
My stencil solution was super slow
Roughly 1.0E¯4
Similar to ⎕S
@Adám Ah, ok.
I definitively have to think about using more the power ⍣ function. Thanks again @Adám for all these solutions.
@brgal No problem. One last one (about same speed as the reduction), is traversing: {⎕io←1 ⋄ m←-l←≢⍺ ⋄ ¯1+≢m⊣{m,←⍵/⍨l<⍵-⊃⌽m}¨⍸⍺⍷⍵}
@Adám Merci beaucoup !
11:03 AM
is there a shorter way to do that?
@PyGamer0 -⍨
I came up with ≢∘∪≢⍤⊣⌊⍤÷⍨⍸⍤⍷ but it doesn't seem particularly fast
That's short.
I'm not convinced it 100% works but I think so
      ]runtime -c "x Red y" "x Rec y" "x Iter y" "x f y"

  x Red y  → 5.2E¯6 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  x Rec y  → 2.7E¯6 | -48% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  x Iter y → 2.6E¯6 | -51% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  x f y    → 2.3E¯6 | -56% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
@rak1507 No need for is there?
11:06 AM
not bad
@Adám true I could do ⍸⍤⍷÷≢⍤⊣
≢⍤∪⍸⍤⍷⌊⍤÷≢⍤⊣ so many ⍤s!
      a ← ⎕A[?⍨3]
      b ← ⎕A[?1e6⍴26]
      ]runtime -c "x Red y" "x Rec y" "x Iter y" "x f y"

  x Red y  → 5.3E¯6 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  x Rec y  → 2.8E¯6 | -48% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  x Iter y → 2.5E¯6 | -54% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  x f y    → 1.4E¯6 | -75% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
Nice. However, I have no clue how or why it works.
oops I used x and y not a and b there lol
so yours is f?
@rak1507 Nice !!!
@Razetime yes
hang on, I think I might have thought of a bug
11:13 AM
huh wow
      'aaaa' f 'xxxaaaaa'
      'aaaa' Red 'xxxaaaaa'
I think I can fix it
actually no, I don't think I can, rip
11:28 AM
⋄ 'aaaa'(≢⍤∪⍸⍤⍷⌊⍤÷≢⍤⊣) 'xxxaaaaa'
@brgal 1
the idea was to divide indices by the length so 0 2 -> 0, 4 5 -> 1, but that doesn't work if the indices are 3 5 for example, they'll go to 0 and 1 and the result will be 2 not 1
⋄ ⎕IO←0 ⋄  'th' 'abab' 'dog'(≢⍤∪⍸⍤⍷⌊⍤÷≢⍤⊣) ¨'the three truths' 'ababababab' 'cat'
@brgal 3 2 0
 ⋄  ⎕IO←1 ⋄ 'th' 'abab' 'dog'(≢⍤∪⍸⍤⍷⌊⍤÷≢⍤⊣) ¨'the three truths' 'ababababab' 'cat'
11:30 AM
@brgal 3 2 0
11:41 AM
@brgal Pro tip: If you edit your code, the bot will update its answer!
Iter is broken in some way
⋄ 'ABC'{⎕IO←1 ⋄ ∨/⍺⍷⍵:⍺(+/∘×≢⍤⊣{(⍺↑2)@((⍳⍺)+⍵⍳1)⊢⍵}⍣{~1∊⍺}⍷)⍵ ⋄ 0}'ABC'
      'ABC'{⎕IO←1 ⋄ ∨/⍺⍷⍵:⍺(+/∘×≢⍤⊣{(⍺↑2)@((⍳⍺)+⍵⍳1)⊢⍵}⍣{~1∊⍺}⍷)⍵ ⋄ 0}'ABC'
also it seems to infinitely loop for some arguments
'Red' seems to have the best performance (discounting Iter because it doesn't seem to work) for longer arrays
I still feel like there might be something a bit more array-y than a reduction but can't figure it out
Q: Is this Game of Go configuration fully alive?

BubblerBackground This challenge is about the Game of Go. Here are some rules and terminology relevant to this challenge: Game of Go is a two-player game, played over a square board of size 19x19. One of the players plays Black, and the other plays White. The game is turn-based, and each player makes ...

I was trying something like this, take the difference bigger than ≢⍺, But doesn't work in case of 'abababab', Cause the pairwise difference would be 2 2
A B←'abab' 'ababcabababcabababab' ⋄ A {⍉(1 1 0 1 0 1),⍨{⍵,⍪4,2-⍨/⍵}⍸⍺⍷⍵} B ⍝ A {2-⍨/⍸⍺⍷⍵} B
11:55 AM
@MasterQuiz Did you forget to add backticks around your code (`⎕←code`)? You can edit your message and I will edit my reply.
@MasterQuiz Did you forget a closing backtick (`⎕←code`)?
Just for information, a French APLer in the early 80s wrote a Computer Go program in APL. That French APLer was also a French Go champion ! That Code-golf problem by Bubbler reminds me of that bit of APL history concerning computer GO that is not mentioned anywhere.
@Adám Have you ever heard of any computer GO program in APL from the 70s or 80s ?
12:19 PM
@xpqz Here xpqz.github.io/learnapl/…. it would useful add the command ]map, I wish I've learnt it when I started studying APL.
Is there another way to suggest things, instead of fill this chat (If it might bother)?
Doesn't bother anyone
@brgal No.
@MasterQuiz PR or log issue.
@xpqz Maybe enable discussions?
@MasterQuiz log issues in the repo if that works for you — that way I can track stuff in a sensible way. Thanks!
2 hours later…
2:29 PM
@Adám the recursive version of P5 annihilates the non-recursive one. That surprised me a bit. But my performance intuition is pretty much always wrong.
@xpqz phase 2?
Phase 1
huh, interesting
what solutions are you comparing?
{N,⍵÷1⌈N←⌈/0,⍵∨⍳⌊⍵*÷2} vs {⍵=0:2⍴0 ⋄ ⍵ {0=⍵|⍺: ⍵,⍺÷⍵ ⋄ ⍺∇⍵-1} ⌊⍵*÷2}
∨ is slow
2:31 PM
for a large number (I used 98776512304)
@rak1507 yeah, it must be.
      g←{⍵=0:2⍴0 ⋄ ⍵ {0=⍵|⍺: ⍵,⍺÷⍵ ⋄ ⍺∇⍵-1} ⌊⍵*÷2}
      f 98776512304
280888 351658
      g 98776512304
280888 351658
      ]runtime -c 'f 98776512304' 'g 98776512304'

  f 98776512304 → 1.2E¯2 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  g 98776512304 → 1.9E¯2 | +57% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
Is that yours?
Can I use that as an example (suitably attributed?)
2:33 PM
Using factors or pco from dfns.dws is probably the best.
@Adám maybe not considering you have to find the closest factor pair
⊢∨⍳ is a nice golfing trick but very slow.
factors produces 2 2 2 2 35111 175829, getting that into the desired format seems non trivial
Right, you want divisors, not factors.
@Adám @PyGamer0 @xpqz @Razetime Found it!
Unfortunately, the original spec is gone :-(
      overkill←{⍵(÷,⊢)⊃⌊/d/⍨(⍵*÷2)<d←×/1⌈a×⍤1⍉2⊥⍣¯1⍳2*≢a←factors ⍵}
      ]runtime -c 'f 98776512304' 'g 98776512304' 'overkill 98776512304'

  f 98776512304        → 8.4E¯3 |    0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  g 98776512304        → 1.8E¯2 | +110% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  overkill 98776512304 → 4.4E¯3 |  -48% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
well it is faster
2:40 PM
And pco?
not tried pco but from what I remember factors is faster
just realised that ⊃ is unnecessary too, should shave off a few microseconds lol
Dfns could do with a divisors
although because of the square root thing it's definitely going to be easier just going up to the square root and taking the largest divisor 'manually'
but in general a divisors function would be useful
You're writing my blog post for me :)
Announcement: My 4th webinar on error handling in 15 mins.
2:45 PM
@Adám any chance of this chat.stackexchange.com/transcript/message/58798935#58798935 later/tomorrow?
@rak1507 Thank you for the reminder. Will do.
Great thanks
2 hours later…
4:17 PM
@Adám your implementation is the only surviving proof of its existence
What's this? An example of language implemented in APL?
@MasterQuiz Yes. Someone was designing a new language, and I just implemented it. The funny thing was that my implementation was almost identical to his spec doc, only with some APL symbols thrown in here and there.
2 hours later…
6:13 PM
@rak1507 Note that braces and parens can be included or excluded for dfns/dervs:
 1 14
 2  7
 3 13
 4 11
 5 22
 6 26
 7 14
 8 17
 9 17
10  9
Longest solutions:
 1  33
 2  32
 3  56
 4  36
 5  81
 6 117
 7 227
 8  58
 9 117
10  65
@Adám braces can be excluded for dfns?!
@Adám ok, 227, what on earth
@rak1507 People might think that they have to "fill in" the dfn, or that the solution has to be an expression in terms of ( and) . Instead of protesting, I simply parse the input and add braces if necessary. However, these statistics are on the raw submission. Many have unnecessary spaces too, and one even had a comment despite instructions.
Also, some have prepended P7← etc.
what was the shortest for 4? something shorter than (.5-⍨○÷4)××⍨? nice
@rak1507 (○-+⍨)4÷⍨×⍨
I quite liked 2-⍨∘○⍥÷4 as the constant just because of the ∘○⍥ combination
6:21 PM
@rak1507 {M←⍵ ⋄ colSum←+/[1]M ⋄ rowSum←+/[2]M ⋄ identity←(⍴M)⍴1,((⊃⍴M)⍴0) ⋄ diagonalSum←{+/+/M×⍵} ⋄ mainDiagSum←diagonalSum identity ⋄ offDiagSum←diagonalSum⌽identity ⋄ allSum←colSum,rowSum,mainDiagSum,offDiagSum ⋄ ∧/allSum=mainDiagSum}
I suppose I can't be too harsh considering theirs works and mine didn't :P
Right, plus, it is very readable.
14 for 7?! what magic is that
@rak1507 The magic of insufficient test cases. Someone found a super-short function that correctly identified the magic squares, without solving the problem at all.
oh right, do you know what the shortest that did actually solve it was? otherwise {?2} could be valid if someone ran it enough times
6:30 PM
@rak1507 ∧.=∘⊃⍨⌽,⍥(+/⊢⍪1 1∘⍉)⍉ because nobody submitted ∧/2=/⌽,⍥(+⌿⊢,1 1⍉⊢)⍉
6:50 PM
cool, same sort of thing

« first day (1653 days earlier)      last day (175 days later) »