[-] TunaCowboy@lemmy.world 1 points 2 hours ago* (last edited 1 hour ago)

python

solution

def setup():
    lines = aoc.get_lines(8, stripped=True)
    ll = len(lines)
    fm = {f: [(x, y) for y, r in enumerate(lines)
              for x, z in enumerate(r) if z == f]
          for f in {z for r in lines for z in r if z != '.'}}
    return ll, fm

def fa(fm, ll, rh=False):
    ans = set()
    for cd in fm.values():
        l = len(cd)
        for i in range(l):
            x1, y1 = cd[i]
            for j in range(i + 1, l):
                x2, y2 = cd[j]
                dx, dy = x2 - x1, y2 - y1
                g = gcd(dx, dy)
                gdx, gdy = dx // g, dy // g
                if rh:
                    for k in range(-ll, ll):
                        x, y = x1 + k * gdx, y1 + k * gdy
                        if 0 <= x < ll and 0 <= y < ll:
                            ans.add((x, y))
                else:
                    x3, y3, x4, y4 = x1 - gdx, y1 - gdy, x2 + gdx, y2 + gdy
                    if 0 <= x3 < ll and 0 <= y3 < ll:
                        ans.add((x3, y3))
                    if 0 <= x4 < ll and 0 <= y4 < ll:
                        ans.add((x4, y4))
    return len(ans)

def one():
    ll, fm = setup()
    print(fa(fm, ll))

def two():
    ll, fm = setup()
    print(fa(fm, ll, rh=True))

one()
two()

[-] TunaCowboy@lemmy.world 12 points 13 hours ago

Schotts actually provides TLCL for free, and last updated it a month ago:

https://www.linuxcommand.org/tlcl.php

[-] TunaCowboy@lemmy.world 23 points 13 hours ago

Schotts provides a free 'internet edition' .pdf of TLCL, last updated 11/1/2024:

https://www.linuxcommand.org/tlcl.php

[-] TunaCowboy@lemmy.world 6 points 13 hours ago* (last edited 13 hours ago)

I get the joke, but this guy's answer to this is celibacy. I'm only pointing it out cause it makes the whole thing even crazier IMO.

[-] TunaCowboy@lemmy.world 1 points 14 hours ago* (last edited 14 hours ago)

It's not a long lived project, it's a puzzle, and once solved never needs to run again. My objective here is to get the correct answer, not win a style contest.

Can you provide a link to your solution? I'd like to check it out.

[-] TunaCowboy@lemmy.world 2 points 1 day ago* (last edited 1 day ago)

python

45s on my machine for first shot, trying to break my will to brute force ๐Ÿ˜…. I'll try improving on it in a bit after I smoke another bowl and grab another drink.

solution

import itertools
import re
import aoc

def ltr(e):
    r = int(e[0])
    for i in range(1, len(e), 2):
        o = e[i]
        n = int(e[i + 1])
        if o == '+':
            r += n
        elif o == '*':
            r *= n
        elif o == '||':
            r = int(f"{r}{n}")
    return r

def pl(l, os):
    d = [int(x) for x in re.findall(r'\d+', l)]
    t, ns = d[0], d[1:]
    ops = list(itertools.product(os, repeat=len(ns) - 1))
    for o in ops:
        e = str(ns[0])
        for i, op in enumerate(o):
            e += f" {op} {ns[i + 1]}"
        r = ltr(e.split())
        if r == t:
            return r
    return 0

def one():
    lines = aoc.get_lines(7)
    acc = 0
    for l in lines:
        acc += pl(l, ['+', '*'])
    print(acc)

def two():
    lines = aoc.get_lines(7)
    acc = 0
    for l in lines:
        acc += pl(l, ['+', '*', '||'])
    print(acc)

one()
two()

[-] TunaCowboy@lemmy.world 6 points 1 day ago

I'm not making any judgement in regard to your opinion, or even disagreeing, I thought friends was lame as fuck. I'm merely pointing out that friends is overwhelmingly considered a comedic success, and that our opinion is by definition the unpopular one.

[-] TunaCowboy@lemmy.world 10 points 1 day ago

Although you're just being intentionally dense at this point I'll give you another quantifiable fact, the word 'comedy' appears 160 times on this page:

https://en.m.wikipedia.org/wiki/List_of_awards_and_nominations_received_by_Friends

Clearly plenty of people found the series funny, even if you don't.

[-] TunaCowboy@lemmy.world 37 points 1 day ago* (last edited 1 day ago)
  • 10 seasons,

  • Cast collectively bargains for $1,000,000.00 per episode per cast member for seasons 9 (24 episodes) and 10 (17 episodes).

  • Cast each paid $2,500,000.00 for reunion episode 17 years after finale (2021)

  • Total award wins: 65

  • Total award nominations: 256

  • Spinoff

Unpopular defined ๐Ÿ‘

[-] TunaCowboy@lemmy.world 16 points 1 day ago

I'm still waiting for my lake city quiet pills.

[-] TunaCowboy@lemmy.world 12 points 1 day ago

annoy

๐Ÿค”

[-] TunaCowboy@lemmy.world 17 points 1 day ago

In general, hard conservative media is free to consume, light conservative (aka 'liberal') media is locked behind a paywall.

view more: next โ€บ

TunaCowboy

joined 2 years ago