Fish Finger · @fishfinger
8 followers · 122 posts · Server kinky.business

Given up with GNU on ‘cos I miss trains and Dyalog isn’t available but Dzaima APL seems to work nicely… :-D

…I should really just learn

#apl #openbsd #bqn

Last updated 1 year ago

Scio · @Scio
20 followers · 189 posts · Server mastodon.social

I'm learning BQN, trying to refactor my solution for the first Project Euler problem into a single tacit binary function: 3‿5 𝔽 100

+´ ×⟜(∨´ 0 = 3‿5 | ⊢)¨ ↕100

But BQN has no combinators like this: 𝕩 𝔽 (𝕨 𝔾 𝕩)

And I don't know what it's usually called either. Could implement if ofc, but I want to stay point-free all the way :[

#bqn #programming #functionalprogramming

Last updated 2 years ago

badtuple · @badtuple
517 followers · 1286 posts · Server mastodon.social

Absolute kudos to for making an accessible tutorial for an array programming language! mlochbaum.github.io/BQN/doc/qu

Yes, it requires concentration...but it's incredibly clear. And you don't build factorial, game of life, or fizzbuzz!

#bqn

Last updated 2 years ago

srasu · @srasu
28 followers · 90 posts · Server parens.social

Finished up day 13 of in today!

This was kinda interesting. The semantic of BQN's sort *almost* matches the sort required. Unlike some others I didn't get lucky and get an input that didn't exercise the edge cases where it doesn't, so I had to implement my own merge sort with a custom comparator.

#adventofcode #bqn

Last updated 2 years ago

srasu · @srasu
27 followers · 89 posts · Server parens.social

Aaand, here's my day 12 solution to in

This time I'm using an interesting algorithm that I've not seen much outside of circles focused on games, a Dijkstra Map!

It's a way of precomputing paths to points of interest from any point in the map by performing something close to a flood-fill starting from points of interest.

#adventofcode #bqn #gamedev #roguelike

Last updated 2 years ago

srasu · @srasu
27 followers · 88 posts · Server parens.social

Well it's taken me a couple days to catch back up, but I'm back on with

Here's my solution to day 11, which I feel pretty gross about.

I'm normally not a fan of OOP, but it ended up being the only way I could determine to solve this in a reasonable amount of code, so I used the mutable namespaces of BQN to solve the problem.

#adventofcode #bqn

Last updated 2 years ago

srasu · @srasu
27 followers · 87 posts · Server parens.social

Yesterday I didn't do the day 10, but I finished it this morning with

It ended up pretty fun! I used continuation passing style, and this is the first time that's seemed useful to me.

#adventofcode #bqn

Last updated 2 years ago

· @Serpent7776
8 followers · 86 posts · Server mastodon.social

Joining non-empty strings with a separator in and

#cplusplus #bqn

Last updated 2 years ago

srasu · @srasu
27 followers · 84 posts · Server parens.social

Today's solution got back into the realm of too large for a toot, but I'm still going strong with in !

This one was pretty fun because it used the same code for both segments, I just had to adjust my first solution for part 2 very slightly to use a scan.

#adventofcode #bqn

Last updated 2 years ago

srasu · @srasu
27 followers · 82 posts · Server parens.social

Today my solution in for is small enough to fit in a toot again!

Part1 ⇐ {
d ← > '0'-˜𝕩
+´ ⥊ ⊑ ∨˝ {(∊⌈`)˘⌾(⍉∘⌽⍟𝕩)d}¨ ↕4
}

Score ⇐ {
x‿y 𝕊 𝕩:
h ← (⌽𝕨) ⊑ 𝕩
row ← 𝕩⊏˜y
col ← (⍉𝕩)⊏˜x
up ← ⌽y↑col
down ← col↓˜1+y
left ← ⌽x↑row
right ← row↓˜1+x
×´ { ((1∘⊑⟜𝕩)⎊0)⊸+ ⊑ (0⊐˜h>𝕩) }¨ up‿down‿left‿right
}

Part2 ⇐ {
d ← > '0'-˜𝕩
is ← ⌽¨ ⥊ ↕≢d
⌈´ Score⟜d¨ is
}

#bqn #adventofcode

Last updated 2 years ago

srasu · @srasu
27 followers · 80 posts · Server parens.social

Today's almost beat me, but I managed to best it with !

Working with trees is pretty hard, and I almost gave up after I forgot to take into account files that are stored in the root of the filesystem.

#adventofcode #bqn

Last updated 2 years ago

srasu · @srasu
26 followers · 78 posts · Server parens.social

Did day 6 of in , this solution is probably a little longer than it needs to be, but I'm satisfied enough with it.

Marker ← {
⊑ 𝕨 + 1 ⊐˜ 𝕨 = (≠·(1=+´˘)⊸/=⌜˜)˘ 𝕨↕ ⊑ 𝕩
}

Part1 ⇐ 4⊸Marker

Part2 ⇐ 14⊸Marker

#adventofcode #bqn

Last updated 2 years ago

srasu · @srasu
26 followers · 76 posts · Server parens.social

Unfortunately today is the first day that my solution to in doesn't fit in a toot, so today I share a screenshot!

This clocks in at 527 characters, just too large.

#adventofcode #bqn

Last updated 2 years ago

srasu · @srasu
26 followers · 74 posts · Server parens.social

And now to day 4 of in

Today I feel a little less good about the solution here, I feel there should be more that I can do to shorten it, but I didn't think it worth the effort.

ParseLine ← common.ParseNumber¨·>'-'common.SplitAt¨','common.SplitAt⊢

Contains ← {a‿b 𝕊 x‿y: (a ≤ x) ∧ b ≥ y}

Part1 ⇐ +´ ((Contains˜∨Contains)˝ ParseLine)¨

Overlap ← {a‿b 𝕊 x‿y: ((a⊸≤∧b⊸≥) x)∨((a⊸≤∧b⊸≥) y)∨(x‿y Contains a‿b)}

Part2 ⇐ +´ (Overlap˝ ParseLine)¨

#adventofcode #bqn

Last updated 2 years ago

srasu · @srasu
26 followers · 73 posts · Server parens.social

I missed posting it yesterday, so I'll probably post twice today: in day 3:

Priority ← 'a'‿('z'+1)⊸common.InRange◶(27+'A'-˜⊢)‿(1+'a'-˜⊢)

Part1 ⇐ +´ {
⌈´ ⌈˝(=◶0‿priority)⌜˝ 2‿∘⥊ 𝕩

Part2 ⇐ {
⊑ +˝ Priority¨ { (⍷⊢/˜⊐<·≠⊣)˝ > (⊢⥊˜¨⌈´∘(≠¨)) ⍷¨ 𝕩 }˘ ∘‿3⥊ 𝕩
}

#adventofcode #bqn

Last updated 2 years ago

srasu · @srasu
25 followers · 71 posts · Server parens.social

I finished my day 2 solution for in

Like last time there's a little bit of library code, and I've left off the import this time.

GenerateOffsets ← 'A'‿'X'-˜¨·>' 'c.SplitAt⊢

Part1 ⇐ +´∘(⊑¨) {
((⊑1⊏⊢)+3×3|(⊣-˜1⊸+)˝) 1 + GenerateOffsets 𝕩

Part2 ⇐ +´∘(⊑¨) {
1 + ((3×·⊑1⊏⊢)+(3|⊣-1-⊢)˝) GenerateOffsets 𝕩

#adventofcode #bqn

Last updated 2 years ago

srasu · @srasu
24 followers · 62 posts · Server parens.social

I finished up the day 1 problem for advent of code in

There's a little bit of library code I have from my other years, but they're pretty obvious in meaning here.

c ← ⟨⟩ •Import "../common.bqn"

Calories ← +´¨·(c.ParseNumber⚇1)⟨⟩⊸c.SplitAt

Part1 ⇐ ⌈´Calories

Part2 ⇐ +´3⊸↑∘∨∘Calories

#bqn

Last updated 2 years ago

srasu · @srasu
15 followers · 14 posts · Server parens.social

I'm getting super excited for this year, just brushing up on my knowledge and tooling. It'll be really cool to have an family language as my language of choice for it this year.

What languages are you looking to use, if you plan to participate?

#adventofcode #bqn #apl

Last updated 2 years ago