« first day (2319 days earlier)      last day (328 days later) » 

3:53 AM
Anyway, here's my ⎕IO-independent rendition: ⌽⍤{⍺←0 ⋄ (⊣,⍨≢|(1-⎕IO)+1∘↓⍳⊃)⍣⍵⊢⍺}.
Looks to be basically the same as the J. Recursing like this is pretty terrible, though :/
 
 
2 hours later…
5:50 AM
0
Q: Get the Highest temperature in the table (Day/s)

bRaNdOnHello im trying to get the highest temperature (day/s) in my APL basically this is my code days ← 'Monday' 'Tuesday' 'Wednesday' 'Thursday' 'Friday' 'Saturday' 'Sunday' temp ← 7 1 1 ⍴78 80 89 82 79 89 73 Centigrade ← (5÷9) × {(⍵ - 32)} AverageTemp ← days,⍪(+/÷≢)⍤1⊢Centigra...

 
 
9 hours later…
3:00 PM
Welcome to APL Quest 2019-10! Today's quest is Odds & Evens:
> Given a vector of words, separate the words into two vectors – one containing all the words that have an odd number of letters and the other containing all the words that have an even number of letters.
Last 2019 quest!
 
A straight forward one which probably can use a ⍥
{(⊂⍵/⍨m),⊂⍵/⍨~m←2|≢¨⍵}
 
Interestingly, the hint given here is to use but I found it easier to not do that.
@Richard Yes, you can use ,⍥⊂ as in {(⍵/⍨m),⍥⊂⍵/⍨~m←2|≢¨⍵} or just stranding: {(m/⍵)(⍵/⍨~m←2|≢¨⍵)}
Btw, other than for symmetry, not really any reason to commute the left /
 
ah no :) Was left over of trying a ⍥
 
Here's a double-over: {,⍥⊂⍥(/∘⍵)∘~⍨2|≢¨⍵}
Could of course also be written {,⍥(⊂⍤/∘⍵)∘~⍨2|≢¨⍵} but note that the is necessary here to force /'s hand.
Ooh, that makes this last one use all the compositions: over, atop, beside, and bind!
 
:)
I did not try a solution with ⌸ but found no reason for it
 
3:05 PM
Same, but we can try.
 
Sorting is probably quite expensive on processor time
 
A no-paren version: {⍵/¨∘⊂⍨,⍥⊂∘~⍨2|≢¨⍵}
Trainable, but ugly, imo: ⊢⊢⍤/¨∘⊂⍨2,⍥⊂∘~⍨⍤|≢¨
@Richard You don't need to sort all the data.
 
Starting with something like this?
{⍺⍵}⌸⊢≢¨t
 
Did you mean instead of ?
When we're done with , let's try
 
no
{⍵}⌸⊢≢¨t
gives all the indices of the even and odd
then something with ⌷
 
3:11 PM
You need 2| no?
 
no, the first row gives the indices of the uneven and the second row the indices of the even ones
but might be too cumbersome. Just trying something
 
I don't follow. What is t?
 
o sorry, my test data. Just a vector of words
 
Surely, ≢¨'one' 'two' gives 3 3
 
yes you're right. Wrong approach
 
3:16 PM
Want to see my -based solution?
 
yes please
 
1↓¨(1 0,2|≢¨)⊂⍤⊢⌸0⍬∘,
Oh, I can get rid of that paren: 1↓¨0⍬∘,⊂⍤⊢⌸⍨1 0,2|≢¨
 
⍨ (confused)
 
⊢⊂⍤⊢⌸⍨2|≢¨ would work except the order of even/odds depends on what appears first.
(that's simply a "group by 2-remainder of lengths")
 
smart
 
3:19 PM
So we inject an odd-length and an even length element: 0⍬
And their corresponding group numbers 1 0
1↓¨ drops them from each list.
 
now I see, thanks
 
And now for !
Here's the idea: If we start by sorting by 2-remainder of the length, then all that remains is a partitioning into two segments.
 
yes was working on that
but I am not that fast
 
Take your time :-)
 
and using ⍸ I asume
 
3:25 PM
I didn't, but by all means, enlighten me!
Ooh, the above key-based solution should really use (,' ')'' instead of 0⍬ to get the empty result right.
 
how should I find where to split it?
⍒2|≢¨ gives the indices, but how to know where to split?
 
Once sorted, how many leading elements will have odd lengths?
I did say "partitioning" above, but then I found using and simpler.
 
@Adám you can not know??
 
Given 2|≢¨ you should be able to compute how many there are in total in the given argument.
And since sorting only moves elements around (it is a permutation), the sorted list must have the same total number of odd-length elements.
 
so something like this.
n↑⍒n←2|≢¨
But now ⍒ is dyadic
oh no sorry, stupid
 
3:37 PM
You're trying to make this tacit?
 
(+/n)↑⍒n←2|≢¨
sorry, not my best day
 
That's almost right. You're just missing ⍵[⍵]
Remember that doesn't sort, it only grades
 
yes, was not finished. :)
and now ⍒ is dyadic, so ↑ must be separated from ⍒
 
Still doing tacit? Don't.
 
{⍵[(+/n)↑⊢⍒n←2|≢¨⍵]}
{⊂t~⍵}{⊂⍵[(+/n)↑⍒n←2|≢¨⍵]}
 
3:44 PM
Surely, your (+/n)↑ needs to be outside the square bracket.
But your way of forming the pair is awkward.
So {o(⍵~o←(+/n)↑⍵[⍒n←2|≢¨⍵])} does work.
I had {(+/n)(↑,⍥⊂↓)⍵[⍒n←2|≢¨⍵]}
 
Does ↑, needs to be (↑,) ?
 
How so, it is a fork (↑ ,⍥⊂ ↓)
 
does ⍥ not only take the first function?
which is ,
ah yes
 
That's what I want. ,⍥⊂ is the same as {⍺ ⍵}
Here's an exploded version: {n←2|≢¨⍵ ⋄ c←+/n ⋄ s←⍵[⍒n] ⋄ (c↑s)(c↓s)}
 
yes I understand now. Thanks
 
3:56 PM
I think it'll be quite complex to compute a left arg for to do the split, so maybe we'll just stop here?
 
ok!
 
Then we'll start the 2020 problems next week with 2020-1: Let’s Split!
 
See you next week
 

« first day (2319 days earlier)      last day (328 days later) »