hades

joined 1 year ago
[–] hades@lemm.ee 152 points 9 months ago (6 children)

[...] Sundar Pichai defended the layoffs and claimed that workers sometimes reach out to express gratitude for the cuts.

"It appeared that there had even been demonstrations to thank Big Brother for raising the chocolate ration to twenty grams a week."

[–] hades@lemm.ee -2 points 10 months ago (2 children)

From my own standpoint I can understand how a certain amount of responsibility lies on him too. If I were handed something that looks like a gun or a knife, I would probably check to make sure it isn't a real gun myself.

Especially in the US, where tragic accidental gun-related deaths and injuries happen every day.

[–] hades@lemm.ee 9 points 10 months ago (1 children)

OP, next time I have this, I'll remember this meme, start laughing while choking, suffocate to death and it will be your fault.

[–] hades@lemm.ee 2 points 10 months ago

Came here looking for these comments

[–] hades@lemm.ee 4 points 10 months ago

My personal favourite is "blithering idiot".

[–] hades@lemm.ee 2 points 10 months ago

Fantastic, thanks!

[–] hades@lemm.ee 4 points 10 months ago (2 children)

Very nice! Could you tweak the colours a bit so they work in dark mode?

[–] hades@lemm.ee 1 points 10 months ago

Probably not. But life is full of minor inconveniences like that, and they do add up.

[–] hades@lemm.ee 12 points 10 months ago

Plastic wrapping that's easy to open.

[–] hades@lemm.ee 27 points 10 months ago* (last edited 10 months ago) (5 children)

Bathroom mirrors that don't steam up after taking a shower.

Vending machines that are competent at accepting cash. Everywhere else that I've been to, you have to smoothen the bill and make sure it has no wrinkles or bended corners, and even then the machine would sometimes give you a hard time. In Japan, you just insert a stack (!) of bills, and the machine will count them within seconds, and also give you change in bills, and not a gazillion of coins.

Gates at the train stations are also better than everywhere else. You don't have to wait for the person in front of you to pass the gate, you just insert your ticket and go. You also don't need to look for arrows or notches or whatever on the ticket to insert it correctly.

Electric kettles that are very quiet and keep the water hot for a very long time.

Trains where all seats face the front, so you don't have to sit against the direction of travel.

[–] hades@lemm.ee 1 points 10 months ago

Python

import networkx as nx

from .solver import Solver


class Day25(Solver):

  def __init__(self):
    super().__init__(25)

  def presolve(self, input: str):
    self.graph = nx.Graph()
    for line in input.splitlines():
      from_, to_line = line.split(': ')
      for to in to_line.split(' '):
        self.graph.add_edge(from_, to)

  def solve_first_star(self) -> int | str:
    cut_value, partition = nx.algorithms.stoer_wagner(self.graph)
    return len(partition[0]) * len(partition[1])
[–] hades@lemm.ee 1 points 10 months ago

Python

import numpy as np
import z3

from aoc23.util import assert_full_match
from .solver import Solver

class Day24(Solver):

  def __init__(self):
    super().__init__(24)
    self.test_area = [200000000000000, 400000000000000]
  
  def presolve(self, input: str):
    self.stones = []
    for line in input.splitlines():
      (x, y, z, vx, vy, vz) = assert_full_match(
        r'([0-9-]+), +([0-9-]+), +([0-9-]+) +@ +([0-9-]+), +([0-9-]+), +([0-9-]+)', line).groups()
      self.stones.append((int(x), int(y), int(z), int(vx), int(vy), int(vz)))

  def solve_first_star(self) -> int | str:
    count = 0
    for i, stone_a in enumerate(self.stones):
      for stone_b in self.stones[i+1:]:
        matrix = np.array([[stone_a[3], -stone_b[3]],
                          [stone_a[4], -stone_b[4]],])
        rhs = np.array([[stone_b[0] - stone_a[0]], [stone_b[1] - stone_a[1]]])
        try:
          x = np.linalg.solve(matrix, rhs)
          if not (x > 0).all():
            continue
          intersection_x = stone_a[0] + stone_a[3] * x[0, 0]
          intersection_y = stone_a[1] + stone_a[4] * x[0, 0]
          if (self.test_area[0] <= intersection_x <= self.test_area[1]
              and self.test_area[0] <= intersection_y <= self.test_area[1]):
            count += 1
        except np.linalg.LinAlgError:
          continue
    return count

  def solve_second_star(self) -> int | str:
    x0 = z3.Int('x0')
    y0 = z3.Int('y0')
    z0 = z3.Int('z0')
    vx0 = z3.Int('vx0')
    vy0 = z3.Int('vy0')
    vz0 = z3.Int('vz0')
    t1 = z3.Int('t1')
    t2 = z3.Int('t2')
    t3 = z3.Int('t3')
    solver = z3.Solver()
    solver.add(x0 + vx0 * t1 == self.stones[0][0] + self.stones[0][3] * t1)
    solver.add(y0 + vy0 * t1 == self.stones[0][1] + self.stones[0][4] * t1)
    solver.add(z0 + vz0 * t1 == self.stones[0][2] + self.stones[0][5] * t1)
    solver.add(x0 + vx0 * t2 == self.stones[1][0] + self.stones[1][3] * t2)
    solver.add(y0 + vy0 * t2 == self.stones[1][1] + self.stones[1][4] * t2)
    solver.add(z0 + vz0 * t2 == self.stones[1][2] + self.stones[1][5] * t2)
    solver.add(x0 + vx0 * t3 == self.stones[2][0] + self.stones[2][3] * t3)
    solver.add(y0 + vy0 * t3 == self.stones[2][1] + self.stones[2][4] * t3)
    solver.add(z0 + vz0 * t3 == self.stones[2][2] + self.stones[2][5] * t3)
    assert solver.check() == z3.sat
    model = solver.model()
    return sum([model[x0].as_long(), model[y0].as_long(), model[z0].as_long()])
view more: ‹ prev next ›