Avicenna

joined 1 month ago
[–] Avicenna@programming.dev 6 points 1 week ago

I myself prefer unholy capitalism in lieu of pure capitalism

[–] Avicenna@programming.dev 4 points 1 week ago

is this relatively good vs relatively bad?

[–] Avicenna@programming.dev 11 points 1 week ago (1 children)

10 hitpoints seem kinda high for that car. I would expect more like 5

[–] Avicenna@programming.dev 6 points 1 week ago (1 children)

the cat: "wake up and feed me instead of strangling me"

[–] Avicenna@programming.dev 2 points 1 week ago* (last edited 1 week ago)

After reading multiple papers on stuff like polyomino and coverings etc over the weekend, I sat down to formulate an ILP approach. All the way through I had at the back of my mind "surely he would not expect people to solve something which requires reading research papers, there must be some angle to this which makes it easier". I don't think I have ever been more right in my life and I am really glad I made the obvious fail and succeed checks based on areas lol.

import numpy as np
import itertools as it
from pathlib import Path
from time import time

cwd = Path(__file__).parent.resolve()

def timing(f):
  def wrap(*args, **kw):
    ts = time()
    result = f(*args, **kw)
    te = time()
    print(f"func{f.__name__} args: {args} took: {te-ts:.4f} sec")

    return result
  return wrap

def parse_input(file_path):
  with file_path.open("r") as fp:
    data = list(map(str.strip, fp.readlines()))

  objects = []
  for i in range(6):
    i0 = data.index(f"{i}:")
    obj = np.array(list(map(list, data[i0+1:i0+4])))
    obj[obj=='#']=1
    obj[obj=='.']=0
    objects.append(obj.astype(int))

  i0 = data.index("5:")+5
  placements = []

  for line in data[i0:]:
    dims = list(map(int, line.split(':')[0].split('x')))
    nobjs = list(map(int, line.split(': ')[-1].split(' ')))
    placements.append((dims, nobjs))

  return objects, placements

@timing
def solve_problem(file_name):

  ref_objects, placements = parse_input(Path(cwd, file_name))
  areas = [np.count_nonzero(obj==1) for obj in ref_objects]

  counter_succesful = 0

  for grid_shape, nobjs in placements:
    obj_area = np.sum(np.array(nobjs)*areas)
    grid_area = np.prod(grid_shape)
    worse_area =  np.sum(np.array(nobjs)*9)

    if worse_area<=grid_area:
      counter_succesful += 1
      continue

    if obj_area>grid_area:
      continue

  return counter_succesful

if __name__ == "__main__":

  assert solve_problem("input") == 583
[–] Avicenna@programming.dev 3 points 1 week ago* (last edited 1 week ago)

oh man my mind directly went for that. Is this what a mind virus is?

[–] Avicenna@programming.dev 38 points 1 week ago (1 children)

that will quickly turn into "continuously monitor your users' screens for what they are doing so you can detect nudity" where the real aim will ofcourse be surveillance and selling highly personal data. I don't know about Apple but google will be all over it.

[–] Avicenna@programming.dev 20 points 1 week ago (2 children)

That would be R'lyeh

[–] Avicenna@programming.dev 2 points 1 week ago* (last edited 1 week ago)

who does? FULU?

[–] Avicenna@programming.dev 6 points 1 week ago

to increase their nightmarish quality

[–] Avicenna@programming.dev 5 points 1 week ago (2 children)

Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn

[–] Avicenna@programming.dev 10 points 2 weeks ago

pumpkin spice kitty

view more: ‹ prev next ›