Terrence · @tpr
3 followers · 16 posts · Server tech.lgbt

```
data =: > ". each ,. > > ('-'&cut) L:0 (','&cut) each LF cut freads '04.txt'

lte =: > +. =
gte =: < +. =
test =: ((0&{ gte 2&{) *. (1&{ lte 3&{)) +. ((0&{ lte 2&{) *. (1&{ gte 3&{))
solution =: +/ test"1 data

first =: 0&{ + [: i. [: >: 1&{ - 0&{
second =: 2&{ + [: i. [: >: 3&{ - 2&{
test2 =: first ([ -. -.) second
solution2 =: +/ 0&< >./"1 test2"1 data
```

#jsoftware #aoc2022 #j

Last updated 3 years ago

Terrence · @tpr
3 followers · 13 posts · Server tech.lgbt

Day 3 solution.

```
data =: LF cut freads '03.txt'

lines =: - @: -: @: # [\ ]
intersection =: ~. @: ([ -. -.)/
doubled =: intersection/ @: lines

priority_lookup =: (26 {. 'a' dropto a.) , (26 {. 'A' dropto a.)
priority =: 1 + (priority_lookup&i.)

answer =: +/ > (priority @: doubled) each data

common =: (intersection @: >)"1
answer2 =: +/ , priority common _3 [\ data
```

#jsoftware #aoc2022

Last updated 3 years ago

Terrence · @tpr
3 followers · 13 posts · Server tech.lgbt

Day 3 solution.

```
data =: LF cut freads '03.txt'

lines =: - @: -: @: # [\ ]
intersection =: ~. @: ([ -. -.)/
doubled =: intersection/ @: lines

priority_lookup =: (26 {. 'a' dropto a.) , (26 {. 'A' dropto a.)
priority =: 1 + (priority_lookup&i.)

answer =: +/ > (priority @: doubled) each data

common =: (intersection @: >)"1
answer2 =: +/ , priority common _3 [\ data
```

#jsoftware #aoc2022

Last updated 3 years ago

Terrence · @tpr
3 followers · 12 posts · Server tech.lgbt

Day 2 solution.

```
data =: freads '02.txt'
parse =: {{ ". each LF&cut rplc&('A';'0';'B';'1';'C';'2';'X';'0';'Y';'1';'Z';'2') y }}
data =: parse data

ind =: {: @: [ { ({. @:[ { ])

s =: 3 3 $ 3 6 0 0 3 6 6 0 3
score =: > ind&s each data
pscore =: > >:@:{: each data
answer =: +/ pscore , score

p =: 3 3 $ 3 1 2 1 2 3 2 3 1
pscore2 =: > ind&p each data
score2 =: > 3&*@:{: each data
answer2 =: +/ score2 , pscore2
```

#jsoftware #aoc2022

Last updated 3 years ago

kirjoittaessani · @kirjoittaessani
2 followers · 17 posts · Server norden.social

So, Tag 1 des ist fertig -- die erste Hälfte in Ada (eigentlich sollte es werden, aber da habe ich mich in der I/O verheddert), und dann nochmal beide Teile schön kompakt in :sweat_smile: adventofcode.com/2022/day/1

#adventofcode #sparkada #jsoftware

Last updated 3 years ago

Terrence · @tpr
3 followers · 11 posts · Server tech.lgbt

Day 1 solution. Parsing text in is painful.

```
parse =: (". @: ((LF,' ')&charsub)) each @: (([: 2&= (1&|. + [) @: (LF&=)) <;.2 ])
calories =: +/"1 > parse data
highest =: >. / calories
sum_three_heighest =: +/ 3 {. |. (/: { ]) calories
```

#j #jsoftware #aoc2022

Last updated 3 years ago

💻 okflo 🤸 · @okflo
46 followers · 217 posts · Server mastodon.sdf.org

in

input =: 1!:1 <'aoc01.txt'
input =: ".;._2 input
echo >./ +/;._2 input , 0
input =: +/;._2 input , 0
echo +/ 0 1 2 { input \: input

J, that concise, it fits easily into a toot. :)

#aoc #j #jsoftware

Last updated 3 years ago

Alex Strick van Linschoten · @strickvl
216 followers · 70 posts · Server mathstodon.xyz

@okflo @ldbeth is the hashtag to use to find other J developers / users? or is it ? or just ?

#j #jlang #jsoftware

Last updated 3 years ago

💻 okflo 🤸 · @okflo
46 followers · 216 posts · Server mastodon.sdf.org

@ldbeth since I switched to J, I miss the "hieroglyphs"!

#jsoftware #apl

Last updated 3 years ago