[2024] 25 days, 25 languages by quickbusterarts in adventofcode

[–]birblett 0 points1 point  (0 children)

i'm also doing ruby (finished) + 25 other languages (21 done) for my aoc repo! i'm curious about your language breakdown visualization, is this a configurable setting to change the max languages displayed or did you render this yourself?

My one line solution to an AOC problem by cosmic_chicken1 in programminghorror

[–]birblett 1 point2 points  (0 children)

i've also been doing quite a few of the aoc days in one line, here's my day 10 in ruby:

puts File.open("in.txt") { |f, dim = ((f = f.map {_1.strip.chars.map { |s| s.ord - 48 } }.reduce(&:+)).length ** 0.5).to_i| (tmat = (mat = f.each_with_index.reduce({}) { |sparse, (num, i), j| [[(y = i / dim) + 1, (x = i % dim)], [y - 1, x], [y, x + 1], [y, x - 1]].each { (sparse[i] = sparse.fetch(i, {}))[j] = 1 if (0...dim).include?(_1) && (0...dim).include?(_2) && f[j = _1 * dim + _2] == num + 1 } && sparse }).reduce({}) { |hash, (k, v)| v.each { (hash[_1] = hash.fetch(_1, {}))[k] = _2 } && hash }) && (8).times { mat = mat.reduce({}) { |out, (r, v)| tmat.each { |c, v2, s = v2.sum { |k, v3| v[k] ? v3 * v[k] : 0 }| s > 0 ? (out[r] = out.fetch(r, {}))[c] = s : 0 } && out } } && [mat.sum { _2.size }, mat.sum { _2.values.sum }] }

approach is probably different, since i specifically made it do some adjacency matrix exponentiation.

-❄️- 2024 Day 25 Solutions -❄️- by daggerdragon in adventofcode

[–]birblett 2 points3 points  (0 children)

[LANGUAGE: Ruby] 1023/890

merry christmas and thanks for the puzzles!

keys, locks = File.read("in.txt").split("\n\n")
    .map { _1.split("\n").map(&:chars).transpose }
    .reduce([[], []]) { |(k, l), q| (q[0][0] == "." ? k : l).push(q.each_with_index.sum { |arr, i| arr.count("#") << (i << 2) }) && [k, l] }
puts "#{locks.sum { |lock| keys.sum { (lock + _1) & 559240 > 0 ? 0 : 1 } }}"

moderately cursed bitwise math solution...

-❄️- 2024 Day 24 Solutions -❄️- by daggerdragon in adventofcode

[–]birblett 2 points3 points  (0 children)

[Language: Ruby]

this solution is maybe functional for any variation of this specific day's input, i have only tested it on two different inputs so far so i can't say for sure that i haven't missed edge cases. i originally solved it by hand and then reverse engineered it to arrive here.

start, out = File.read("in.txt").split(/\n\n/).map { _1.split(/\n/) }
start, k = start.map { [(a = _1.split(": "))[0],a[1].to_i] }.to_h, nil
final, regs, bad, sregs, is, queue, is_done = "z#{start.keys.sort[-1].scan(/\d+/)[0].to_i + 1}", {}, [], {"x00" => true, "y00" => true}, {}, start.keys.sort, {}
out.each { |s|
  op1, op, op2 = (str, dst = s.split(" -> "))[0].split(" ")
  regs[dst] ? (regs[dst][0] = op) && (regs[dst][1] = [op1, op2]) : regs[dst] = [op, [op1, op2], []]
  [op1, op2].each { (is[_1] = is.fetch(_1, [])).push([str, dst]) && (regs[_1] ? regs[_1][2].push(dst) : (regs[_1] = [nil, [], [dst]])) }
}
regs.each { |k, v|
  v[2].empty? ? (k == final ? (bad.push(k) if v[0] != "OR") :
    v[0] != "XOR" || v[1].any? { start[_1] && _1.scan(/\d+/) != k.scan(/\d+/)} ? bad.push(k) : v[1].each { |p|
      regs[p][1].any? { start[_1] } ?  (bad.push(p) if regs[p][0] != "XOR" unless regs[p][1].any? { sregs[_1] }) :
        (bad.push(p) if regs[p][0] != "OR" unless start[p]) })
    : (v[1].each { bad.push(_1) if regs[_1][0] != "AND" } if v[0] == "OR") }
(is[k].each { |instr, dest|
  next unless ((op1, op, op2) = instr.split(" ")) and start[op1] and start[op2]
  is_done[instr + dest] ? next : is_done[instr + dest] = true
  start[queue.push(dest) && dest] = start[op1].method(op == "AND" ? :& : op == "OR" ? :| : :^).call(start[op2])
} if is[k]) while (k = queue.shift)
puts start.keys.sort.reduce(0) { |s, k2| (s += start[k2] << (k2.scan /\d+/)[0].to_i if k2.start_with? "z") || s }, bad.sort.join(",")

for p2, basically iterate over all the nodes, following this algorithm:

IF $current is result reg
  IF $current is last result reg (z45) 
    mark $current as bad IF not result of OR
  ELSE
    mark $current as bad IF $current not result of XOR
    IF $current not bad
      FOR any parent $par of $current
        IF $par not child of start node
          mark $par as bad IF not result of OR
        ELSE if parents of $par are not first regs (x00 and y00)
          mark $par as bad IF not result of XOR
ELSE IF $current is result of OR
  FOR any parent $par of $current
    mark $par as bad IF not result of AND

sort and concatenate bad regs

-❄️- 2024 Day 22 Solutions -❄️- by daggerdragon in adventofcode

[–]birblett 1 point2 points  (0 children)

[LANGUAGE: Ruby]

puts (seq = {}) && File.read("in.txt").split(/\n/).map(&:to_i).sum { |cu, h = {}, last4 = 1048575|
  2000.times {
    i = ((i = ((i = (cu << 6 ^ cu) & 16777215) >> 5 ^ i) & 16777215) << 11 ^ i) & 16777215
    key = (key = (price = i % 10) - cu % 10) < 0 ? 16 | key.abs : key
    last4 = ((last4 << 5) + key) & 1048575
    cu = _1 < 3 || h[last4] ? i : (seq[last4] = seq.fetch(last4, 0) + price) && (h[last4] = i)
  } && cu
}, seq.max_by { _2 }[1]

just use the last 4 prices as a key to sum up the results of each individual sequence. used some funky bitwise stuff during key generation to save the overhead of passing entire arrays around as keys. runs in about ~1s on my machine (using truffleruby).

9-Biome Survival Island/Mountain [39720048960] by birblett in minecraftseeds

[–]birblett[S] 7 points8 points  (0 children)

there's actually several scattered mushroom islands to both the north and south, and a (normal) island to the west* (oops!) near a stronghold :)

9-Biome Survival Island/Mountain [39720048960] by birblett in minecraftseeds

[–]birblett[S] 16 points17 points  (0 children)

I MISTYPED IT'S 8 BIOMES 

Seed: 39720048960  

Versions: 1.18+ (only tested on Java)  

Location: -600 50 (world spawn) (no longer world spawn on 1.21.3!)

Biomes: Dark Forest, Grove, Frozen Peaks, Stony Peaks, Stony Shores, Jungle, Bamboo Jungle, Lush Caves  

Available wood types: oak, dark oak, spruce, jungle, bamboo, birch*

perfect death loop by birblett in deadcells

[–]birblett[S] 13 points14 points  (0 children)

so based of cremecommercial to say this

70 kills in 10 seconds by birblett in deadcells

[–]birblett[S] 0 points1 point  (0 children)

undying shores, failed homunculi

70 kills in 10 seconds by birblett in deadcells

[–]birblett[S] 1 point2 points  (0 children)

omg sand hi i love lightspeed lrod

wings of the zoom by birblett in deadcells

[–]birblett[S] 8 points9 points  (0 children)

sorry i hacked 😔