« first day (2501 days earlier)      last day (148 days later) » 

5:50 AM
Advent of Code Day1 part two
 fn←{A←1↓⍎¨(⊂'1'),⍵/⍨I←⍵∊⎕D
     B←⍸I ⋄ C←⊃,/⍸¨K←ds⍷¨⊂⍵
     D←(⍳9)/⍨+/¨K
     V←(A,D)[⍋B,C]
     10⊥(⊃V),⊃⌽V}
ds←'one' 'two' 'three' 'four' 'five' 'six' 'seven' 'eight' 'nine'
It is a surprise to me that day 1 already need to write several lines in APL
 
6:08 AM
welp I can match ds and ⎕D together
 
(part 1 is something like +⌿((⍎⊃,⊇)⎕d∘∩)¨)
 
 
2 hours later…
8:13 AM
?
 
@RubenVerg What is ?
 
last
 
Ah. You do realise that no APL implementation has that, right?
 
Would use ⊣/,⊢/ in APL though
 fn←fn;f ⍝ revised
 f←{
     ds←'one' 'two' 'three' 'four' 'five' 'six' 'seven' 'eight' 'nine'
     ds,←1↓⎕D
     D←(18⍴⍳9)/⍨+/¨K←ds⍷¨⊂⍵
     10⊥(⊣/,⊢/)D[⍋⊃,/⍸¨K]
 }
 fn←+/f¨
 
@LdBeth (⊂'1') is '1'
 
8:18 AM
@Adám doesn't Vision have that?
 
Not really an APL implementation.
 
fair enough :)
 
@LdBeth 18⍴⍳9 is just ,⍨⍳9
@LdBeth Why not write …'eight' 'nine',1↓⎕D?
 
@Adám Would be less obvious if something is trailing at the end of a long line
 
ok
 
8:26 AM
@Adám I did the problem with a friend, we are both rusty on programming now :D spend lot of time without getting a right answer, he was tripped by C++ regexp, I was trying to figuring out a fix for ⍎¨ when argument is .
 
9:20 AM
@RubenVerg Ah, I forgot about again. Wrote ⍵/⍨⍵∊⎕D
 
 
1 hour later…
10:21 AM
@RubenVerg That intersection should take quad D on the right - all examples have increasing digits so I didn't notice
 
11:19 AM
My take on AoC day1: xpqz.github.io/AoC-day1
 
 
2 hours later…
1:00 PM
Welcome to APL Quest 2022-6! Today's quest is Pyramid Scheme:
> Write a monadic function that:
> • takes an argument n that is an integer scalar in the range 0–100.
> • returns a square matrix "pyramid" with 0⌈¯1+2×n rows and columns of n increasing concentric levels.
> ⠀ By this we mean that the center element of the matrix will be n, surrounded on all sides by n-1.
 
Got two different ones
 
Good.
 
∘.⌊⍨(⊢,1↓⊖)⍤⍳
 
I had ∘.⌊⍨⍳,1↓⌽⍤⍳
 
(∘.⌊⍨⍳⌊⌽∘⍳)0⌈(-∘1×∘2)
{∘.⌊⍨(⍳⍵),⌽⍳(0⌈⍵-1)}
last one not tacit, yet
 
1:02 PM
@rabbitgrowth That's just the unrolled-fork version of @RubenVerg's.
 
Yeah, I guess it's better not to twice
 
But is O(n) against ∘.⌊'s O(n²).
@Richard ⍥
 
I also had this very ugly one: {(⊢⌊⌽⍤⊖)∘.⌊⍨⍳0⌈1-⍨2×⍵}
 
{⍵=0:0 0⍴0 ⋄ {1⍪1⍪⍨1,1,⍨1+⍵}⍣(⍵-1)⊢1 1⍴1}
:)
 
Cute.
Btw, ⊢1 1⍴1 is just ⍪1
 
1:08 PM
Ah
 
And a real golfing trick: 0 0⍴0 is ⍬⊤⍬
@rabbitgrowth The inner function might look cooler if tacit, with 1 as left arg.
 
for extra ugly points: {0≡⍵:0 0⍴0⋄1≡⍵:1 1⍴1⋄1,1,⍨1⍪1⍪⍨1+∇⍵-1}
 
@Adám You'd need to repeat a bunch of times, right?
{⍵=0:⍬⊤⍬ ⋄ 1(⊣⍪⊣⍪⍨⊣,⊣,⍨+)⍣(⍵-1)⍪1}
 
@RubenVerg ⊢⌊⌽⍤⊖ can be the much nicer ⌽⌊⊖
@rabbitgrowth Yes.
@rabbitgrowth Now you can unswap ⊣,⍨+
 
{⍵=0:⍬⊤⍬ ⋄ 1(⊣⍪⊣⍪⍨⊣,+,⊣)⍣(⍵-1)⍪1}
 
1:13 PM
@rabbitgrowth How about making all non-empty constants be 1 — for fun: {1≤⍵: 1(⋄ ⍬⊤⍬}
@Richard Did you get my reaction?
 
not yet, was looking at the other solutions
 
{1≤⍵: 1(⊣⍪⊣⍪⍨⊣,+,⊣)⍣(⍵-1)⍪1 ⋄ ⍬⊤⍬}
Without the guard: {{1⍪⍨1,⍨(1⍪1∘,)⍣(1∊⍵)⊢1+⍵}⍣⍵⊢0 0⍴0}
I thought {{1⍪⍨1,⍨(1⍪1∘,)(⍣1∊⍵)1+⍵}⍣⍵⊢0 0⍴0} would work.
 
I myself had (⌽⌊⊖)≡∘.⌊⍨∘⍳⍤⌈+⍨-≢ and ∘.⌊⍨≢(⊢,↓∘⌽)⍳
There's something beautiful/obscene about avoiding constants altogether (please don't do this in production code!)
@rabbitgrowth But (⍣1∊⍵) is (⍣1)(∊⍵)
@rabbitgrowth (1⍪1∘,) can become 1(1⍪,)
 
@Adám Ah yes, of course. (⍣(1∊⍵)) does work.
 
@rabbitgrowth How about {{1+0⍪⍨0,⍨0(0⍪,)⍣(1∊⍵)⊢⍵}⍣⍵⊤⍨⍬}
 
1:22 PM
nasty!
 
I thought it was better to first add 1 to , then append 1s, instead of append 0s, then add 1, since you do fewer additions that way.
 
Surely, this approach isn't for performance.
 
@rabbitgrowth why the ⍣1∊⍵ ? That just a generalisation?
 
Otherwise it expands the 0 case.
One could use twice to expand with zeros too.
Wonder if there's a neat solution.
 
1:26 PM
Ah, was confused given I'd just used ⍣2 ((⍉¯1∘↓⍪⊖)⍣2⊢∘.⌊⍨⍳)
 
Yeah, this is an IF.
Anyway, have we had our fun with this one?
 
The need for the ⍣(1∊⍵) seems to show that 0=⍵ is a special case: the shape of the result increases from 0 0 to 1 1 to 3 3 to 5 5 etc.
 
yes, but still did not succeed in making my last one tacit
 
Ah, right.
 
 ∘.⌊⍨⍳,⌽⍳(0⌈-∘1)
I know this is not right
 
1:31 PM
@rabbitgrowth negative-shaped arrays in dyalog when?
clearly what this implies is that ¯1x¯1 matrices should be a thing
 
@Richard {∘.⌊⍨(⍳⍵),⌽⍳(0⌈⍵-1)} has two s so we can write {∘.⌊⍨⍵,∘⌽⍥⍳(0⌈⍵-1)}
 
thanks! That's still difficult for me
 
∘.⌊⍨⊢,∘⌽⍥⍳0⌈-∘1
 
using ⍥ in that way
 
OK, see you next week for 2022-7: Just Golfing Around!
 
1:34 PM
Golf!
Oh, it has nothing to do with code golf.
 
@Adám could you explain why WHILE form of power scan (aplcart.info?q=power%20scan) needs two ⍺⍺?
Found playing last night that {⍵-(2e12÷64)}{r⊣⍺⍺{r,←⍺⍺ ⍵}⍣⍵⍵⊣r←⍵}{⍺≤2e12÷64}2e12 worked but {⍵-(2e12÷64)}{r⊣{r,←⍺⍺ ⍵}⍣⍵⍵⊣r←⍵}{⍺≤2e12÷64}2e12 WS FULLed
 
 
2 hours later…
3:13 PM
Power scan is a k-feature I wished APL had built in.
 
 
2 hours later…
4:56 PM
For those confused like me, TBT-ing the expression showed due to scoping, passing function to evaluate to both power and the powerscan D-op
 
@xpqz yeah my initial take on part 2 is also use regexp replace but didn't come up with an idea on the composite words
 

« first day (2501 days earlier)      last day (148 days later) »