« first day (2503 days earlier)      last day (168 days later) » 

6:34 AM
I did today's using stencil
 
 
3 hours later…
 
5 hours later…
2:31 PM
-1
Q: Filter a list of list based on data

Yannick GuernI'm pretty new in APL(Dyalog), I'm trying it for the Advent of Code, so I've 1 day of experience ^^ I've this data x ← ((1 'data1') (0 'data2') (0 'data3') (1 'data4') ) x ┌─────────┬─────────┬─────────┬─────────┐ │┌─┬─────┐│┌─┬─────┐│┌─┬─────┐│┌─┬─────┐│ ││1│data1│││0│data2│││0│data3...

 
Ven
3:02 PM
@LdBeth Ah, I was considering stencil too, but I need to figure out how to select the numbers first...
 
3:28 PM
@YannickGuern Welcome. Feel free to introduce yourself or just lurk. We're a friendly bunch here.
 
3:52 PM
Spent way too long trying to solve today's puzzle without remembering exists
 
Hello everyone ^^
My name is Yannick, I'm a french guy who love to try new concepts languages and so on
I'm actually doing the Advent of Code in Dyalog-APL, just to try ^^
As the first question ask for parsing. I'm building righ now a parser combinator to help me to beat the first day :D
 
0
Q: Apply a list of functions on the same right operand

Yannick GuernI have 3 functions which return parse_apple 1 'bpple4578' ┌─┬─────────┐ │0│bpple4578│ └─┴─────────┘ parse_bpple 1 'bpple4578' ┌─┬────┐ │1│4578│ └─┴────┘ parse_45 1 'bpple4578' ┌─┬─────────┐ │0│bpple4578│ └─┴─────────┘ I would like to apply this list of functions on 'bpple4578' And return as so...

 
Ven
4:35 PM
There are easier ways to go at it :)
@xpqz I started with your solution, ended up with a better solution using , though without the parsing step of the string
 
5:05 PM
 
Well I'm pretty happy of parser combinator
I just need to do the "map" feature
https://x.com/_Akanoa_/status/1731358784482607353?s=20
 
@Akanoa how do you parse zoneighteen and get 18?
oops I spoiled part two
@Ven Hint: a stencil window size of 1 5 to get numbers, and 3 3 to handle symbols, then 1 3 to filter our excessive numbers
 
Ven
@LdBeth That's just specialcasing the input, right?
there's nothing that says a number has to be 3 chars at most
 
@Ven You can used a iterative flooding of 1 3 window to get the numbers, whiteout assuming the max number length
*without
 
Ven
Dunno how to do that
 
5:16 PM
@l
 
@Ven Start with each location holds its single digit, each iteration, get the number of the two nearby cells, update as necessary, until the map stabilized. Assume max size of 3 would be much efficient than this, of course, and this can be verified easily using regexp search.
 
minor spoiler on day1 part2




@LdBeth if i've parse the term "eighteen" I can remap it as 18 integer
but as I see, the number in letters or not range between 1 to 9
'7pqrstsixteen', "sixteen" is a fake news because the last number is a 6 not 16 :p

so my parser only need to range "one", "two", .... "nine"
and "1", "2", ..., "9"
 
Ven
eighteen is a trap
 
5:33 PM
Hello,
I'm new to Code Golf, what is APL Orchard, how can I prepare for it and how to find information about it?
 
Ven
5:53 PM
I don't understand stencil. {⊂≢⍵}⌺ or {⊂⊃⍵}⌺ don't give me the results I expect at all
 
@LuckyChouhan Welcome! This chat room is the APL Orchard. See apl.wiki/APL_Orchard
@Ven What is the right operand?
 
Ven
My day3 advent input, split on space, mixed. 10 10≡⍴
 
I don't follow, neither what you are saying, nor AoC, but the right operand to should be the windows size and optionally the movement.
 
Ven
oh no I mean, I called is as {⊂≢⍵}⌺1 5⊢data
that wasn't clear, sorry
 
Then ≢⍵ is always 1.
in the left operand is simply the current window.
 
Ven
6:10 PM
I'll just 1⌷ then
 
Or ,
@Ven How wide is data?
 
Ven
⍴data is 10 10
 
Ah.
 
Ven
↑' '(≠⊆⊢)'467..114.. ...*...... ..35..633. ......#... 617*...... .....+.58. ..592..... ......755. ...$.*.... .664.598..'
Basically, this, and the task is to find the numbers there, but only when there's a non-dot symbol around it. So I was trying to figure out how to do that.
 
Numbers or digits?
 
Ven
6:24 PM
numbers, digits would be easy
I'd stencil 3 3, check if it's a digit in the middle, and check the rest
 
Ah, around it like that.
So why 1 5?
 
Ven
@LdBeth ^
I considered doing a 3 5 stencil at first.
and 2↓¯1⌽
 
6:49 PM
 numbermap←{
     parsn←{
         l←,⍵
         ~l[3]∊⎕D:0
         ~∨/l[2 4]∊⎕D:⍎(,⍵)[3]
         s←' .%#*$/-&+@='split l
         3=≢s:⍎2⊃s
         2=≢s:⍎s⊃⍨1+</≢¨s
         1=≢s:⍎⊃s
         0
     }
     parsn⌺1 5⊢⍵
 }
The 3=≢s:⍎2⊃s case won't happen though
 
Ven
OK, I got {⊂2↓¯1⌽2⌷⍵}⌺, now I need to parse either 2 or 3 digits from what's left there
 
@Adám Because the number is assumed to be at most 3 digits wide, so a window of width 5 can do the thing in one pass.
 
Ven
7:04 PM
I do 2↓¯1⌽ on and on 2⌷⍵, figure out if any of these is a symbol
 
@LdBeth Ah.
 
@Ven this is just {2 2⌷⍵}⌺3 3 isn't it, also you are getting a vector instead of scalar.
 
Ven
I guess I can actually just check ,⍵, check if there's anything's besides '.',⎕D
@LdBeth hm?
That only selects an element
 
Why would you want windows to be 3 5?
 
Ven
because I can see all the characters around
 
7:16 PM
...+. ..+..
123.. 23...
..... .....
Now you have these two windows next to each other, how do you determine what number is next to the +?
...+. ..+..
.23.. 23...
..... .....
And differentiate the case above with this one?
 
7:31 PM
Welp turns out that is quite feasible
 
Very funny ^^
@LdBeth my mapping is ready, now I need to move my parsing cursor and accumulate
but tomorrow :p
https://x.com/_Akanoa_/status/1731395652637106672?s=20
 
 
3 hours later…
Ven
11:01 PM
I got to this, but it's too slow to run in TryAPL:

+/+/{⊂(~×/(,⍵)∊' .',⎕D)×(~(2 1⌷⍵)∊⎕D)×((2 2⌷⍵)∊⎕D)×⍎(v∊⎕D)/v←'0',2↓¯1⌽2⌷⍵}⌺3 5⊢↑' '(≠⊆⊢)input
Mh, that doesn't seem correct, unsure why :(
It works fine with the simpler example...
 

« first day (2503 days earlier)      last day (168 days later) »