Ancestors

Written by Russ Cox on 2024-12-02 at 15:34

Ivy remains a good choice for

[#]AdventOfCode.

Day 1:

sample = transp read "sample.txt"

op sort x = x[up x]

op solve x = +/abs (sort x[1]) - sort x[2]

solve sample

op solve2 x = +/x[1] * +/x[1] o.== x[2]

solve2 sample

https://adventofcode.com

(Ivy in 2021: https://www.youtube.com/playlist?list=PLrwpzH1_9ufMLOB6BAdzO08Qx-9jHGfGg)

=> More informations about this toot | More toots from rsc@hachyderm.io

Written by Russ Cox on 2024-12-02 at 15:35

Day 2:

sample = read "sample.txt"

op delta x = (1 drop x) - -1 drop x

op safeInc x = &/ (delta x) in 1 2 3

op safeDec x = &/ (delta x) in -1 -2 -3

op safe x = (safeInc x) | safeDec x

op solve x = +/ safe@ x

solve sample

op i delete x = (i != iota rho x) sel x

op safe2 x = |/ safe@ (iota rho x) @delete x

op solve2 x = +/ safe2@ x

solve sample

(Using the non-standard map operator-modifier '@' that I added to my copy in 2021. https://github.com/rsc/ivy)

=> More informations about this toot | More toots from rsc@hachyderm.io

Toot

Written by Özgür Kesim on 2024-12-02 at 19:36

@rsc

Edit -1, x/solve/a/2

=> More informations about this toot | More toots from oec@mathstodon.xyz

Descendants

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113584911270285002
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
254.69968 milliseconds
Gemini-to-HTML Time
0.733551 milliseconds

This content has been proxied by September (3851b).