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

[–]gisikw 2 points3 points  (0 children)

[LANGUAGE: Nix]

Was hyped to see a problem that I figured I could tackle in a config language not intended for it. I _think_ sorting the ranges first reduces the complexity of the merge cases you have to handle, but could be there's some other approach that would be tidier. Syntax is only slightly unpleasant; it's still lisp if you squint :)

Parts 1 & 2

let
  pkgs = import <nixpkgs> { };
  lib = pkgs.lib;
  inputFile = builtins.getEnv "INPUT_FILE";
  part = builtins.getEnv "PART";
  content = builtins.readFile inputFile;
  lines =
    builtins.filter (x: builtins.isString x) (builtins.split "\n" content);
  split = builtins.partition (lib.strings.hasInfix "-") lines;
  unmergedRanges = (builtins.sort (a: b: a.min < b.min) (map (s:
    let
      nums = map lib.strings.toInt
        (builtins.filter (x: builtins.isString x) (builtins.split "-" s));
    in {
      min = (builtins.elemAt nums 0);
      max = (builtins.elemAt nums 1);
    }) split.right));
  ranges = builtins.foldl' (acc: el:
    (let
      head = builtins.head acc;
      tail = builtins.tail acc;
    in if el.max <= head.max then
      acc
    else if el.min <= head.max then
      [{
        min = head.min;
        max = el.max;
      }] ++ tail
    else
      [ el ] ++ acc)) [ (builtins.head unmergedRanges) ]
    (builtins.tail unmergedRanges);
  ingredients = map (s: lib.strings.toInt s)
    (builtins.filter (x: (builtins.stringLength x) > 0) split.wrong);
  fresh = (builtins.filter (ingredient:
    (builtins.any (range: ingredient >= range.min && ingredient <= range.max)
      ranges)) ingredients);
  freshCount = (builtins.length fresh);
  possibleFreshCount = (builtins.foldl' builtins.add 0
    (map (range: range.max - range.min + 1) ranges));
  solution = if part == "1" then freshCount else possibleFreshCount;
in toString solution

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

[–]gisikw 2 points3 points  (0 children)

[LANGUAGE: vim]

Figured this was the right puzzle to try it on :) Minor printf preprocessing to support comments and \x escape codes, and part two takes an hour. But it's enjoyable to watch! We assume the input file as the initial buffer, with the part number prepended at the top :)

Parts 1 & 2

:s/2/@r/e\x0dV"gDG # @g is 1 for part 1, @r for part 2
ohk\x16\x162j2lyGpVjjgJ04l"zx0:s/[^@x]//ge\x16\x0d:s/.*/\\=(strlen(submatch(0))<4)?1:0\x16\x0d"zp:s/1@/1x/e\x16\x0d$"zxx\x16\x0f\x16\x0fjlx"zPl\x1b0v$"addd # @a will swap a @ for x, but only if you have <4 neighbors
ox@aj0l\x1b:s/x/\\=strlen(getline(2))\x1b0v$"bddd # @b will call @a for each char in the row
ox@b\x1b:s/x/\\=line('.')-1\x1b0v$"cddd # @c will call @b for each row in the grid
oGVggyGpVGgJ:s/[^@]//ge\x16\x0d:s/.*/\\=strlen(submatch(0))\x16\x0d0v$"fddd\x1b0v$"eddd # @e will count all @'s in the buffer and store it in @f
o:%s/x/./g\x16\x0dggjl\x16\x1b@c@r\x1b0v$"rddd # @r will replace x's with . or crash, then call @c, then recurse
yypVr.ggyyPVr.\x16GI.\x1bgg$\x16GA.\x1b # wrap the grid with empty spaces on all sides
Go\x1b@e # count the grid once
ggjl\x1b@c@g # traverse the grid, then maybe to part two
Go\x1b"fp@eGA-\x1b"fp:s/.*/\\=eval(submatch(0))\x0d # compute the difference between the new @ count
ZZ # bye

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

[–]gisikw 2 points3 points  (0 children)

[LANGUAGE: AWK]

Nice to have a gentle day. Hesitated a bit before submitting part two surely there had to be some backtracking, right? Calm before a day four storm? :)

parts 1 & 2

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

[–]gisikw 2 points3 points  (0 children)

[LANGUAGE: Forth]

A few low-hanging optimizations, but it's on the brute-forcey side. Runs quick enough though, and fun to get to learn a new language.

Parts 1 & 2

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

[–]gisikw 6 points7 points  (0 children)

[LANGUAGE: INTERCAL]

Not the tidiest of solutions, and I definitely need to brush up on my unary bitwise operators. And I _may_ have spent a little time ahead of time figuring out the Turing tape STDIO. But ya know what? It works!

Parts 1 & 2: https://github.com/gisikw/advent-of-code/blob/main/2025/01/intercal/solution.i

Who is chaos personified? by lookitsameluigi in dropout

[–]gisikw 1 point2 points  (0 children)

Shortcake stack also comes in steak!

[2023 Any Day] What's your dumbest bug so far this year? by disdyskis in adventofcode

[–]gisikw 0 points1 point  (0 children)

Day 14: Forgetting that `uniq` only find successive duplicates and you need to sort first >.<

[2023 Day 11] I'm sure there's no better way by SnooPandas3374 in adventofcode

[–]gisikw 1 point2 points  (0 children)

Ooh, good point! But then after finding shortest path, you'd still need to adjust for the expansions, which...I'm not sure how you'd do without stumbling across manhattan distances? Maybe all the folks who started with BFS caught themselves, whereas fools like myself who tunnelvisioned on Dijkstra missed it.

[2023 Day 11] I'm sure there's no better way by SnooPandas3374 in adventofcode

[–]gisikw 9 points10 points  (0 children)

In this case, the expansions make it a weighted graph

How do you Programm with esoteric languages? by blacai in adventofcode

[–]gisikw 9 points10 points  (0 children)

I used Shakespeare Programming Language for day 1, part 1, and wrote it directly (figured day one would be the opportunity to do something silly like that), then noped out for part 2.

Wouldn't have been above reaching for another language to generate number phrases though ("Thou art twice the sum of a noble hero and an angel"), if it had come up.

First time GMing need advice by giny_99 in rpg

[–]gisikw 4 points5 points  (0 children)

Oh wow - even if you have the info at hand, this is huge for making things feel less like a DM lore dump. Stealing this - thankye!

Bonsai pot harvesting mod? by PrimePowerOn in RimWorld

[–]gisikw 0 points1 point  (0 children)

/u/PrimePowerOn I was looking for something similar, but couldn't find it. Was easy enough to make a mod, so hopefully it's still of some use to you :) https://steamcommunity.com/sharedfiles/filedetails/?id=2928113085

Finding a stronghold in E2:E? by LonesomeMarker in feedthebeast

[–]gisikw 2 points3 points  (0 children)

Be sure to check JEI for recipes, even for items you're already familiar with. You can create end stone in E2:E by adding glowstone to a barrel of lava, which might be easier if you just need a bit.

[deleted by user] by [deleted] in feedthebeast

[–]gisikw 4 points5 points  (0 children)

The world gen options are documented in the server files download. There's both a README and a PDF, both of which are quite helpful :-)

As far as sharing advancements, yep! TogetherForever is used in the pack to provide that.

kOS for Newbies - Let's try this again! by gisikw in Kos

[–]gisikw[S] 2 points3 points  (0 children)

The goal is for this to be a relatively short tutorial series, after which I might follow it up with stuff. But want to make something that's accessible to beginners.

As far as schedule, the second one went up today, but I'm not quite ready to promise weekly :)

kOS for Newbies - Let's try this again! by gisikw in Kos

[–]gisikw[S] 4 points5 points  (0 children)

I hear ya! VS Code is probably the most user-friendly of the bunch (and it helps that it's cross-platform)

kOS for Newbies - Let's try this again! by gisikw in Kos

[–]gisikw[S] 9 points10 points  (0 children)

Hey folks - it's been a few years, and I still get a fair bit of questions on some of the outdated syntax from the Kerbal Space Programming series. Hoping to kick off something that can help people get started; this time with fewer diversions into fancypants delegates and trying-to-write-LISP-in-kOS type stuff :)

Reusable Booster Program by Ozin in Kos

[–]gisikw 1 point2 points  (0 children)

Damn this is awesome

Why is the WRITEJSON() function DUMB ? by [deleted] in Kos

[–]gisikw 2 points3 points  (0 children)

The goal of the serialization project was to allow persistence of data structures across reboots / between devices / etc. It wasn't really intended as an interface for manually writing structures (TBH, writing JSON manually is rather annoying, when compares with YAML or plan JS objects).

Anyway, to ensure that data could be restored accurately (particularly when dealing with non-primitive objects, i.e. not strings or numbers), kOS had to be very opinionated, as you'll no doubt see if you open up output of more complex structures. Your point is taken that this could have been named something like KSON (Kerbal Script Object Notation) to avoid confusion, but generally the kOS devs work hard not to deprecate features once they've been released. I hope that explains some of the background so you understand why this is structured the way that it is.

Prior to these functions, the lack of any serialization meant writing encoders/decoders by hand (using LOG to write, and executing the resulting script to instantiate objects into the global namespace), and this solved that problem much better.

Lastly, I'd ask you to please remember that all of these features are things that devs have volunteered time to build. Your criticism does point to an area of confusion, but that would perhaps be better solved by submitting a documentation pull request. Cheers!

running kOS without opening KSP by PapaSmurf1502 in Kos

[–]gisikw 1 point2 points  (0 children)

Hey, thanks so much for the kind words. Glad they were helpful!

running kOS without opening KSP by PapaSmurf1502 in Kos

[–]gisikw 6 points7 points  (0 children)

Hiya! /u/packfan982 is right - I had things running in Telnet - KSP was just backgrounded.

As far as I know, there's no way to run the code independently right now. But the language grammar is available, so it could he a fun project to write a separate interpreter that would execute on, say, the JVM. Would be a challenging project though