Show newer

still suuuper behind on advent of code, but it's fun how basically every challenge so far (up to day 7) can be summed up as "use clojure's loop, but with one other function also"

saw the grinch just casually walking their dog down the road

learning to frame complaints as "i personally didn't enjoy X" instead of "X is absolute shitgarbage objectively and everyone around me needs to deal with my emotions about it" is actually a really important social skill that's a lot less common than it really should be

Show thread

cosplaying someone who gets up at a reasonable hour

(well, a few days ago, at least!)

i played on a console last time with someone who pretty much speedran the game to a five star island before i could even really start to appreciate new horizons' vibes, and this time i'm hoping to just kinda slow down and do that..!

Show thread

also, have i ever mentioned it's both super-neat to be able to do this, and also a pretty nifty way to casually absorb how accessible different things really are?

because it is, in fact, both of those things

Show thread

glad i learned how to use a screen reader

was using my phone while it was in my mitten, with said mitten being in my pocket

because guess what

advent of code day 4 

gist.github.com/Archenoth/4256

loop continues to put in some work

i deffed both inputs in a let form since def isn't lexixal

also, reading in the data was the same number of lines of code that actually solving the problem took

this day is the first time i've broken out the extremely neat threading macros to make things more readable (the ->> and as-> calls)

part 2 was a cakewalk since i already had all the tools written for part 1

the most interesting part in this one was using destructuring results as a predicate for checking if any sheets remained, and returning the last one if they didn't

i'm probably not going to continue putting in the actual code into posts like this, but for the first three it seemed okay enough~

Show thread

re: advent of code, day 3 

gist.github.com/Archenoth/4256

day 3 part 1 was easy peasy, i could just use the clojure frequencies function on each column, and sort them by that to make my destructuring consistent!

(loop [[more? & rem] (first input)
col 0
gamma ""
epsilon ""]
(if-not more?
(* (Integer/parseInt gamma 2) (Integer/parseInt epsilon 2))
(let [[[e] [g]] (sort-by second (frequencies (map #(nth % col) input)))]
(recur rem (+ 1 col) (str gamma g) (str epsilon e)))))

in part 2 was harder to understand what to do, and i had to break the column generalization into a separate function that i didn't know what to call (so i just called it "magic", hee)

the idea here is that the function will extract the most and least common bit, and their counts, then based on the default, do the right thing for the oxygen and carbon values

i could do both at the same time since the function should never reduce the values below one row

(defn magic [col values default]
(let [colvals (map #(nth % col) values)
[[lc lcc] [mc mcc]] (sort-by second (frequencies colvals))
look-for (if (= lcc mcc) default (if (= default 1) mc lc))]
(filter #(= look-for (nth % col)) values)))

(loop [col 0
omatches input
cmatches input]
(if (and (= 1 (count omatches)) (= 1 (count cmatches)))
(let [oxygen (apply str (first omatches))
coscrub (apply str (first cmatches))]
(* (Integer/parseInt oxygen 2) (Integer/parseInt coscrub 2)))
(recur (+ 1 col) (magic col omatches 1) (magic col cmatches 0))))
Show thread
Show older
Awoo Space

Awoo.space is a Mastodon instance where members can rely on a team of moderators to help resolve conflict, and limits federation with other instances using a specific access list to minimize abuse.

While mature content is allowed here, we strongly believe in being able to choose to engage with content on your own terms, so please make sure to put mature and potentially sensitive content behind the CW feature with enough description that people know what it's about.

Before signing up, please read our community guidelines. While it's a very broad swath of topics it covers, please do your best! We believe that as long as you're putting forth genuine effort to limit harm you might cause – even if you haven't read the document – you'll be okay!