« first day (2519 days earlier)      last day (353 days later) » 

09:34
@Matthew In case you haven’t found it, you may find xpqz.github.io/learnapl useful.
 
1 hour later…
11:49
Advent of Code Day 18 >> Spoilers <<

I'm somewhat proud that I managed to get a working solution to this at all - by all means poke holes in this and tell me how to do it better; this is a learning exercise for me and the tips here have been very insightful.

The problem involves finding the total number of tiles enclosed by the path provided as L, R, U, D and distances (e.g. R 6, D 5, ...). The [Shoelace formula](https://en.wikipedia.org/wiki/Shoelace_formula) is a nice way to achieve this.
My solution:
p←' '(≠⊆⊢)¨⊃⎕NGET'p18.txt' 1
dist←⍎¨⊣/↑1↓¨p
dirs←(1 0)(0 ¯1)(0 1)(¯1 0)['DLRU' ⍸ ⊃¨p]
pts←↓⍉↑+⍀dist×dirs
x←2,⌿⊃pts[1] ⋄ y←2,⌿⊃pts[2]
fill←2÷⍨|+/x{-/⍺×⌽⍵}¨y ⍝ or x{det↑⍺ ⍵}¨y with dfns.det
fill + (2÷⍨+/dist) + 1
@xpqz That is a fantastic resource; thank you so much for making it!
@JonathanCarroll If you had posted these paragraphs as separate messages, the markdown link would have worked.
I was prepared to split code by message, but I thought links might work - I'll split more forcefully in the future
 
3 hours later…
14:51
@JonathanCarroll Shoelace was a nice way to solve day10 (p2), too, avoiding the floodfill.
It’s getting too hard for me now though…
 
4 hours later…
18:47
thanks, that's it.

Does anyone have a good answer to aoc day 17? Mine takes hours to run, even with a heap.
 
1 hour later…
19:51
dijkstra's should work
 
1 hour later…
20:59
What's the inverse function of ?
@Fmbalbuena For the monadic function, it is a self-inverse, so just . For the dyadic function, you can only invert it if the left argument is a permutation vector, in which case you can just do X(⍉⍣¯1)Y or invert the permutation with (⍋X)⍉Y
21:21
@hyper-neutrino Provided the adjacency matrix describes states with position, direction, and steps_in_this_direction (with the relevant restrictions) then yes. For part 1, every "move" takes you between 1 and 3 spaces then definitely turns left or right.
 
2 hours later…
22:57
@hyper-neutrino huh, small world - I actually used your code to check mine. In pseudocode they're very similar, dijkstra with the 6-tuple for state, but I guess my attempt at a heap is horribly inefficient, because it's taking 8 hours to run vs a couple seconds.
23:11
@Lapwing482 interesting. are you sure you're not inserting duplicate cases?
@hyper-neutrino I don't think so - I checked how the queue size changes with each step and they're very similar, except mine runs a lot slower. Incidentally Aaron Hsu has since uploaded his APL answers and they're very quick, looks like I just need to write better code.

« first day (2519 days earlier)      last day (353 days later) »