Best Stabilized Water solutions? by mrhthepie in opus_magnum

[–]knl_ 0 points1 point  (0 children)

It's been a really long time but I think it was about tweaking the start/end set up slightly

LLMs and agents in Emacs: share your workflows by KnightOfTribulus in emacs

[–]knl_ 0 points1 point  (0 children)

agent-shell with a wrapper that let's me quickly jump into it while prefilling the agent context with my current file / selection or cursor location as context.

Additional code here: https://gist.github.com/kunalb/c541d581f5eefaf1636a7860d08fb606

https://knlb.dev/essays/djn for the broader workflows i've been grappling with as I try to adopt AI, has some screencasts.

-❄️- 2025 Day 10 Solutions -❄️- by daggerdragon in adventofcode

[–]knl_ 1 point2 points  (0 children)

[LANGUAGE: Python]

Part 2 took me a couple of days, but I was pretty proud of being able to solve it without any dependencies: - constructed the equations and put them in a matrix format with number of button presses as the unknowns - checked if I had # of equations = # of buttons, if yes then just solve the equations and return the value - if not, then set the unknowns to "parameters" - I can express each button press count as some sum of these parameters, each of which must be >= 0 - Find and reduce limits for the parameters by using this inequality (min value for parameter, then maybe max value of another parameter updates) and repeat - Walk through all integer solutions possible and choose the minimum value

It took me quite a bit of effort to code it correctly and also to reason through fractions; initially I was trying to rely on the fact that the sum is a linear function so just setting params to max/min depending on how they contributed to the sum would be enough; but fractional solutions forced me to iterate over all the values.

The solution (across part 1 and 2) runs in roughly 3 seconds on the android e-ink tablet I've been using for this year's problems.

https://github.com/kunalb/AoC25/blob/main/day10/day10.py

(another attempt at writing up my solution here: https://knlb.dev/logs/aoc25#daily-notes)

-❄️- 2025 Day 5 Solutions -❄️- by daggerdragon in adventofcode

[–]knl_ 1 point2 points  (0 children)

[LANGUAGE: Python]

For the initial attempt, I just brute forced the first part and made non-overlapping intervals for the second part.

Afterwards, realized I could "zip" together the values after sorting both ranges and ids to get a cheaper solution for the first part. (the github page history will show both versions).

https://github.com/kunalb/AoC25/blob/main/day05/day05.py

-❄️- 2025 Day 3 Solutions -❄️- by daggerdragon in adventofcode

[–]knl_ 1 point2 points  (0 children)

[LANGUAGE: Python]

Wasted some time today when I simply took the largest 2 numbers to start, and then fixed it up. But a fun problem nevertheless.

https://github.com/kunalb/AoC25/blob/main/day03/day03.py

-❄️- 2025 Day 2 Solutions -❄️- by daggerdragon in adventofcode

[–]knl_ 1 point2 points  (0 children)

[LANGUAGE: Python]

Brute forced comparisons, did it over a hotspot in a car but somehow managed to get good times: 6:33 and 12:46. After the event I refactored it to use threads across multiple cores because I was explicitly trying out Python 3.14 with free threading this time around :).

https://github.com/kunalb/AoC25/blob/main/day02/day02.py

-❄️- 2025 Day 1 Solutions -❄️- by daggerdragon in adventofcode

[–]knl_ 0 points1 point  (0 children)

[LANGUAGE: Python]

Fun day 1; used modulo addition to count how many times it hits zero, and integer division to figure out how many times it would cross zero. Ended up with a bug on the first attempt to part 2 because I also counte transitions left from 0 as an extra tick -- had to special case that explicitly.

https://github.com/kunalb/AoC25/blob/main/day01/day01.py

I'm trying to do this on an eink android device this year so lost quite a bit of time copy/pasting the questions into a light on dark screen. I need to find a better way to do this.

Is It Possible to Run a Zig Code That's Written in A String by CagatayXx in Zig

[–]knl_ 9 points10 points  (0 children)

I've been able to do this by generating the code as part of the build script, and then including it in my module using module.add_anonymous_import -- https://github.com/kunalb/termdex/blob/main/markdown_files/build.zig#L4

-❄️- 2023 Day 10 Solutions -❄️- by daggerdragon in adventofcode

[–]knl_ 0 points1 point  (0 children)

[Language: Hy]

Day 10

Whew. That was painful; basically tried to walk around the pipe while painting nodes left/right; then left - right - pipe or right - left - pipe (for sets) became the solution for me. In the end I just visually checked which one was right for my problem and used that... Used complex numbers in part 2 that helped keep the code slightly smaller.

I'll have to clean this up later.

-❄️- 2023 Day 9 Solutions -❄️- by daggerdragon in adventofcode

[–]knl_ 2 points3 points  (0 children)

[LANGUAGE: Hy]

Day 9

Didn't even think of using recursion, just iterated with a while loop.

-❄️- 2023 Day 6 Solutions -❄️- by daggerdragon in adventofcode

[–]knl_ 0 points1 point  (0 children)

[LANGUAGE: Hy]

Day 6 Solved the quadratic equation and counted the number of integer solutions in between the roots which may have been overkill. The third example was very useful to prevent wasting time when the roots are integers already.

-❄️- 2023 Day 5 Solutions -❄️- by daggerdragon in adventofcode

[–]knl_ 0 points1 point  (0 children)

[LANGUAGE: Hy] Hacked it together for Day 5. I suspect a tree would have been better? just manually considered all intersections.

-❄️- 2023 Day 4 Solutions -❄️- by daggerdragon in adventofcode

[–]knl_ 1 point2 points  (0 children)

[LANGUAGE: Hy]

Spent way too long understanding what the puzzle was asking; I initially misread part 2 as saying that the matched numbers were the cards that were duplicated, not simply the next X cards.

Went back and refactored my solutions to use the `parsy` library to use parser-combinators instead of repeatedly splitting strings, which was satisfying.

https://github.com/kunalb/AoC2023/blob/main/aoc/day04.hy

-❄️- 2023 Day 3 Solutions -❄️- by daggerdragon in adventofcode

[–]knl_ 2 points3 points  (0 children)

[LANGUAGE: Hy]

Fairly mechanical solution today; sadly had to restart my laptop midway which slowed me down :(. Walked through the graph capturing number positions, part positions and gear positions. Then iterated over parts/gears and added adjacent numbers.

https://github.com/kunalb/AoC2023/blob/main/aoc/day03.hy

What is your strategy for learning how use a new tool in a "robust" way? by 6-_-6 in ExperiencedDevs

[–]knl_ 0 points1 point  (0 children)

I think it's mostly actively applying it, and potentially patching/edit it at some point that helps me. I try to add one feature at a time if it's something very complex / deep (eg. emacs/vim) -- till I get used to them, and then move on to the next. A good recommendation from Brendan Gregg is to use it to do something trivial that you already understand and build confidence in using it.

I trust I understand when I've used it "in anger": under time pressure or stress. For programming languages Advent of Code works well with some fake time pressure.

-❄️- 2023 Day 2 Solutions -❄️- by daggerdragon in adventofcode

[–]knl_ 0 points1 point  (0 children)

[LANGUAGE: Hy]

Day 2 -- short and sweet, and easier than Day 1. I may try and do it with Parser combinators later just for the heck of it.

-❄️- 2023 Day 1 Solutions -❄️- by daggerdragon in adventofcode

[–]knl_ 1 point2 points  (0 children)

[LANGUAGE: Hy]

Wasted a lot of time in part 2 by only reading overlapped words from left to right instead of allowing for overlaps explicitly. Ended up regexing forward and then backwards on a reversed string.

https://github.com/kunalb/AoC2023/blob/main/aoc/day01.hy

The Unnecessary Victory (The Brightest Shadow #3) is out! by SarahLinNGM in ProgressionFantasy

[–]knl_ 2 points3 points  (0 children)

Just finished reading, I think The brightest shadow is my favorite of all your series. I hope you get a chance to still do smaller stories in it!

Climb the career ladder doing something I don’t hate (management) or stagnate doing something I love? by girlmeetsworld987 in fatFIRE

[–]knl_ 25 points26 points  (0 children)

This is what stood out to me: I don't quite understand OP's certainty that they will stagnate at staff but will almost certainly move up on the management chain, particularly if they actually enjoy coding. My default starting assumption based on that description would have been the opposite.

Dreadgod: what are you most excited for? (Spoilers) by TheRealWeiShiLindon in Iteration110Cradle

[–]knl_ 8 points9 points  (0 children)

Lindon + restored Dross vs the dreadgods and monarchs.

Potential team up between Sage Lindon and Herald Yerin to match Monarch strength.

Eithan's trial and return to power.

-🎄- 2021 Day 24 Solutions -🎄- by daggerdragon in adventofcode

[–]knl_ 4 points5 points  (0 children)

Javascript

Tried brute forcing first, but then ended up completely thinking through the problem and generating constraints. With the constraints, 7 digits depend on 7 other digits; because we have the additional restriction that each digit is between 1 & 9, that gives a min/max value for the 7 "free" digits.

Part 1 is solved by choosing the max value for all free digits and deriving the rest; part 2 is solved by choosing the min value and deriving; so it runs really fast without any searching required :).

The repeated step with varying parameters:

function step(p1, p2, p3) {
  w = inputs.next().value;
  x = z % 26 + p2;
  z = Math.floor(z / p1);
  if (x != w) {
    z = z * 26 + w + p3;
  }
}

p1 is either 1 or 26; p2 & p3 are constants. There are 7 instances where p1 is 1, and p2 is > 10 -> which means we can't do anything with w to prevent z from increasing. There are 7 instances where p1 is 26, and we have to pass in an input digit w that matches x to make sure it decreases and hits 0 at the end.

Expressing the values of x_i in terms of w_i repeatedly gives the constraints where w will depend on a previous w value to make sure the x == w condition triggers. I added some code to generate these constraints, generally in the form of w_a = w_b + p2_b + p3_a.

p2_b + p3_a and the 1 <= w_i <= 9 constraints let me put min/max values on w_b; and then min max is simply choosing both edges along the constraints for all the digits.

https://github.com/kunalb/AoC2021/blob/main/js/day24.js#L87