« first day (2431 days earlier)      last day (306 days later) » 

12:20 AM
@RubenVerg Haha. You've inspired me:
(5 5 5⍴⍳125){(+⌿÷≢)⌷∘⍺¨,⊃∘.,⌿↓(⌊⍵),⍪⌈⍵}0.9 2.2 3.1
Not quite four characters, though ⍨
Oh, wait. That's not right. I'm not actually lerping correctly there. Oh well.
 
7 hours later…
7:26 AM
@RubenVerg Uh oh, now we need to decide if satire/humour posts go on ∘.×
8:00 AM
@Adám I think there's just enough actual APL stuff in there that it might fit on jdt
8:25 AM
@B.Wilson I think (1⊥,⍤⊢×(×⌿¨⍤1∘|⍤|⊂⍤⊣-¨~⍤,⍤⍳⍤⍴⍤⊢))(2↑⌊⍤⊣↓⊢) works with io 0
 
2 hours later…
10:25 AM
@RubenVerg You're a train monster.
10:50 AM
@B.Wilson I'll take that as a compliment :)
 
3 hours later…
2:17 PM
That does seem to break the idea of taking a[1.5] <- 4 as inserting between a[1] and a[2] though...
2:58 PM
@Silas Stictly speaking, they don't conflict.
Welcome to APL Quest 2021-6! Today's quest is Fischer Random Chess:
> Write a function that:
> • has a character vector right argument that is a permutation of 'KQRRBBNN'
> • returns 1 if the following are true:
⠀ ○ the K is between the two Rs
⠀ ○ the Bs occupy one odd and one even position
otherwise a 0 is returned.
have two solutions, partly different
Yes, there are a lot of interesting approaches to this.
{(≠/2|⍸'B'=⍵)∧⊃1=⍸/⍸¨,/'RK'∘.=⍵}
{(≠/2|⍸'B'=⍵)∧1='R'⍸⍥(⍸⍤=∘⍵)'K'}
{(≠/2|⍸'B'=⍵)∧'RKR'≡⍵∩'KR'}
@rabbitgrowth That looks very familiar.
3:02 PM
2(⊣|↑+.∧↑∘⊖<.<⊃⍤↓)⍋
@mitchelljohnstone If you edit your message (press UpArrow) and insert either 4 leading spaces, or backticks (`) around your code, it will look better.
Did that help?
Yes.
Now, that solution looks very interesting. I need to study how it works, unless you want to explain.
3:04 PM
@mitchelljohnstone ⍨
@rabbitgrowth I have (≠/2|∘⍸'B'∘=)∧('RKR'≡∊∘'RK'⊢⍤/⊢) which is pretty much the same thing
@rabbitgrowth last part is smart!
@RubenVerg Yes, you just implemented
ye, that intersection is really nice
@Adám The main idea was that if you use , Bishops will be the first 2 spots, Rooks will be the last 2, and the King will be the 3rd.
@Richard Where would I as the ?
3:09 PM
@mitchelljohnstone was just confused about your nice solution :)
@Richard Lol, thanks!
ah, then ∘.○
The other solutions are obvious. I'm still trying to grasp the -based approach.
Comparing the position of the the King (⊃⍤↓) and the position of the Rooks (↑∘⊖), We can get a single result 1 or 0 from <.<. Then, grabbing the position of the bishops (), it get's "anded" by the prior result and added +.∧. If the rook/king comparison was 0, the ∧0 will result in 0. Otherwise, the ∧1 is an identity, so it moves onto the bishop position sum (mod 2)
3:19 PM
@mitchelljohnstone Yeah, I was just finishing up the reasoning too. Amazing. Just amazing. Wow!
@Richard You're using a lot of =⍵. Have you considered breaking that out to a small utility?
{I←⍸=∘⍵ ⋄ (≠/2|I'B')∧1='R'⍸⍥I'K'}
You may also want to fix the '' case.
no i did not. Just thought ⍸/⍸ looked nice. But yours is better indeed.
I quite like this variant: {I←⍸=∘⍵ ⋄ (2|I'B')∧⍥(≠/)'K'<⍥I'R'}
@Adám didn't manage without {⍵='': 0 ⋄ }
3:29 PM
@rabbitgrowth You can make the right side of be tacit.
I think it actually looks better because it avoids nested enclosures:
{(≠/2|⍸'B'=⍵)∧'RKR'≡⍵∩'KR'}
 {≠/2|⍸'B'=⍵}∧'RKR'≡∩∘'KR'
We can even make the right side explicit for symmetry and ease of grouping:
 {≠/2|⍸'B'=⍵}∧{'RKR'≡⍵∩'KR'}
I like making small function that do one thing each, and then chain them together in conditions using logical functions.
Then my code can become almost (?) a DSL:
    Char←0 2∊⍨10|⎕DR
    Num←2|⎕DR
    Null←∧/⎕NULL≡¨⊢
    Simple←{1=≡,⍵}
    Scal←⍬≡⍴
    Vec←{1=≢⍴⍵}
    Mat←{2=≢⍴⍵}
    String←Simple∧Char∧Vec∨Scal
    Table←Mat>0∊(String∨Simple∧Scal∧Num∨Null)¨
(from here)
Anyway, I think that'll be enough for today.
@Adám you say can't do ^.= but could you do ^.≡ ?
Yes, but that's not clearer.
Next time will be 2021-7: Can You Feel the Magic? and will be the last quest at this UTC time. We're then moving two hours earlier.
@Adám true, just thought might be faster, although probably not with the each
@Adám I think I like this one best. The other one feels like an odd mix of dfn and tacit
Thanks Adám!
 
2 hours later…
Ven
Ven
5:56 PM
At a first glance, I wrote:
`+/({'RKR'≡⍵}⌺3)` for the first requirement
`{1=+/2|⍸'B'=⍵}` for the second requirement
∩'KR' is very clever
Why stencil? Does windowed reduction not work?
Ven
Ven
I just wanted to note down the first solutions that came to mind before scrolling down to answers

« first day (2431 days earlier)      last day (306 days later) »