Samir Talwar

@SamirTalwar
1 Followers
164 Following
115 Posts

I make computers go beep boop.

Writing code, making coffee, and posting shit in Zürich, Switzerland.

pronounshe/him; they/them
locationZürich, Switzerland
bloghttps://monospacedmonologues.com
twitterhttps://twitter.com/SamirTalwar

Wrote some more J as a warmup for #adventofcode. This is AOC 2021, day 3, part 1.

Screenshot attached, code's also at https://gist.github.com/SamirTalwar/a0dddc670bda4a5cc757574bdeb5abde#file-aoc_03_1-ijs.

I think I'm done warming up now. Looking forward to the real deal.

Solutions for Advent of Code 2021, in J. This is a warmup for 2022.

Solutions for Advent of Code 2021, in J. This is a warmup for 2022. - AOC_01_1.ijs

Gist

I made my first J adverb! It takes a dyadic verb (a verb with two parameters, to its left and right), and makes the right parameter a list, which it folds over.

I feel very smug. Better go to bed before this gets out of hand.

Code here (AOC_02_2.ijs): https://gist.github.com/SamirTalwar/a0dddc670bda4a5cc757574bdeb5abde

Solutions for Advent of Code 2021, in J. This is a warmup for 2022.

Solutions for Advent of Code 2021, in J. This is a warmup for 2022. - AOC_01_1.ijs

Gist

Advent of Code 2021, day 2, in J.

I do not like this solution. It relies a lot on mutation and just pretending the input is J (`".` is basically `eval`).

I need to find a way to fold over my input better. Tried looking into state machines but it made my brain bleed. (https://www.jsoftware.com/help/dictionary/d332.htm)

If you need alt text, you're probably better off viewing the code at https://gist.github.com/SamirTalwar/a0dddc670bda4a5cc757574bdeb5abde.

;: Words - Sequential Machine

Finally figured out how to write a sliding window function in J.

Code's now at https://gist.github.com/SamirTalwar/a0dddc670bda4a5cc757574bdeb5abde. I'm not uploading it to my main repo because it's not really set up to handle more than one language for the same year.

Solutions for Advent of Code 2021, in J. This is a warmup for 2022.

Solutions for Advent of Code 2021, in J. This is a warmup for 2022. - AOC_01_1.ijs

Gist

Can't sleep. So here's last year's Advent of Code, day 1, in 3 lines of J.

Simple, right?

Alright, not so simple. I have annotated it in the second picture.

I'm sure you can do this even more tersely, but I'm very much a newbie to J.

Looking forward to trying it on this year's problems. 😄