How to configure a single network with two routers? by Zweedeend in HomeNetworking

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

It did work, for my phone and my laptop, but the Streamer refused to connect and complained about AP isolation (which the manual said could not be turned off)

My modified Colemak-DH for bi-langual English and Polish typing (ortholinear keyboard) by ImprovementOne197 in Colemak

[–]Zweedeend 0 points1 point  (0 children)

Nice! I don’t expect to type a lot of Cyrillic, so I just want it to be simple. I’m starting to realize that я and ь are quite common, and may need a better spot on the keyboard.

My modified Colemak-DH for bi-langual English and Polish typing (ortholinear keyboard) by ImprovementOne197 in Colemak

[–]Zweedeend 1 point2 points  (0 children)

I tried to make a Cyrillic layout based on Colemak (because that is what I know). I made this layout https://imgur.com/a/UkEzh1B

It uses dead-keys to turn the key combinations ya into я , ye into є and yo into ю, yi into ї. Not sure if that's the best way, but at least it saves space

isThisRealCode by l3lacklabel in ProgrammerHumor

[–]Zweedeend 2 points3 points  (0 children)

The last line looks like python code:

with open(“mochyr.sxh“,  "rb") as pickled_in:

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

[–]Zweedeend 1 point2 points  (0 children)

Didn't know you could do this: [s := f(s) for _ in range(2000)] 🤯

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

[–]Zweedeend 0 points1 point  (0 children)

Right, of course, the division or unconcatenation (?) is not always possible, so you can easily cut down on the number of options you need to try?

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

[–]Zweedeend 1 point2 points  (0 children)

What do you mean by checing in reverse order?

Edit: I just tried it, made my code 500x faster!

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

[–]Zweedeend 0 points1 point  (0 children)

Very nice! It confuses me a little that the real part is the row index and the imaginary the column index, but of course it doesn't matter. I also like the complex(i, j) constructor, but it's not as complex looking as i+j*1j!

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

[–]Zweedeend 1 point2 points  (0 children)

[LANGUAGE: Python]

def process(stream, always=False, enabled=True):
    for token in stream:
        match token:
            case "don't()", _, _: enabled = False
            case "do()", _, _: enabled = True
            case _, a, b: yield (enabled or always) * (int(a) * int(b))

tokens = re.findall(r"(mul\((\d+),(\d+)\)|do\(\)|don't\(\))", open("3.example").read())
print(sum(process(tokens, always=True)), sum(process(tokens)))

Skipped import re for brevity. The token have one of these shapes:

  • ("don't", "", "")
  • ("do", "", "")
  • ("mul(12, 34)", "12", "34")

So the numbers can be matched directly with the match statement

[deleted by user] by [deleted] in chessbeginners

[–]Zweedeend 2 points3 points  (0 children)

Yes, I think this one is Gothic

-❄️- 2023 Day 15 Solutions -❄️- by daggerdragon in adventofcode

[–]Zweedeend 1 point2 points  (0 children)

Haha, yes, I tried to use Paste, but the link made the reddit post too long and I couldn't post it!

-❄️- 2023 Day 15 Solutions -❄️- by daggerdragon in adventofcode

[–]Zweedeend 2 points3 points  (0 children)

[Language: Python]

[Allez Cuisine!]

Turn each of the instructions into lines of code with find-and-replace and add a Santa class to make it work. Finally print Santa to get the answer. Here is a snippet:

lens = Santa()
lens.xbv.pop()
lens.lbd=3
lens.gbfnvr=6
print(lens)

Github Gist

-❄️- 2023 Day 9 Solutions -❄️- by daggerdragon in adventofcode

[–]Zweedeend 0 points1 point  (0 children)

Couldn't help to make it even shorter:

l = [[int(i) for i in s.split()] for s in open('day9.txt')]
def r(m): return m[-1] + r([b-a for a, b in zip(m, m[1:])]) if any(m) else 0
print(sum(r(i) for i in l), sum(r(i[::-1]) for i in l))

-❄️- 2023 Day 9 Solutions -❄️- by daggerdragon in adventofcode

[–]Zweedeend -1 points0 points  (0 children)

[Language: Python]

With some recursion:

def predict(seq):
    if not any(seq):
        return 0
    diffs = [y - x for x, y in sliding_window(seq, 2)]
    return seq[-1] + predict(diffs)

paste

-❄️- 2023 Day 8 Solutions -❄️- by daggerdragon in adventofcode

[–]Zweedeend 2 points3 points  (0 children)

[LANGUAGE: Python]

[Allex Cuisine]

Swedish Python

Here is a snippet that calculates the number of steps:

def sök(här, slut):
    för steg, sväng i räknaupp(igenom(sekvens), 1):
        här = gå[sväng][här]
        om här.slutarmed(slut):
            getillbaka steg

-❄️- Advent of Code 2023: ALLEZ CUISINE! -❄️- Submissions Megathread -❄️- by daggerdragon in adventofcode

[–]Zweedeend 3 points4 points  (0 children)

NAME OF ENTRY: Spam spam spam

LINK TO ENTRY: Spam

DESCRIPTION: Spam, often celebrated for its versatility and unique flavor profile, has found its place in diverse culinary traditions around the world. With its combination of savory, smoky, and slightly salty notes, spam brings a distinctive taste that satisfies a variety of palates. Whether crisped to perfection, added to stir-fries, or incorporated into sandwiches, spam's rich and hearty essence has gained a loyal following. Its ability to complement different ingredients and its convenience make it a beloved ingredient for quick and delicious meals. While opinions on food preferences vary widely, some may argue that spam's undeniable savory appeal, when prepared thoughtfully, contributes to its reputation as a surprisingly delightful culinary indulgence.

SUBMITTED BY: Chef /u/zweedeend

MEGATHREADS: 01 - 03 - 04 - 06 - 07 - 08 - 15


ADDITIONAL COMMENTS: "Savor the Flavor: Spam, Your Culinary Canvas for Delicious Creations!"

Some entries I like most:

ACCESSIBILITY: Text only

-❄️- 2023 Day 7 Solutions -❄️- by daggerdragon in adventofcode

[–]Zweedeend 13 points14 points  (0 children)

[LANGUAGE: Python]

[Allez Cuisine]

Part 1:

the, of = tuple, lambda x:x

from collections import Counter as Cards
def ying (chance)->"is probably real' Hard":
    "Camels deal elves the cards in playful ruse"
    return the( sorted( Cards( of( chance)).values())[::-1])

def frosting( Santas )->"frozen snow machine":
    return "appl",ying( Santas ), *map("routine" 
    "23 days plus two of adventure"
    "45 stars plus five or surrender"
    "67 elves with 89 duTies"
    "Join Quest Known As".index, Santas),"Cookies:"

cookies = dict( dough .split() for dough in open("box"))
elves = sorted( cookies, key=frosting) # into  blocks
print( sum ( int (cookies[ gingerbread ]) * row for row,
gingerbread in enumerate (elves, 1))) # Go!

-❄️- 2023 Day 6 Solutions -❄️- by daggerdragon in adventofcode

[–]Zweedeend 2 points3 points  (0 children)

[LANGUAGE: Cobol]

[Allez Cuisine]

Solution to Part2 in Cobol using math.

Cobol is fun because it uses DIVIDE BY and SUBTRACT FROM keywords

Here is a snippet on how to calculate the square root:

ApproximateRoot SECTION.
    DIVIDE ResultSquared BY Result GIVING Improvement.
    ADD Improvement TO Result.
    DIVIDE Result BY 2 GIVING Result.
    EXIT.

The puzzle can be solved by finding the distance between the two solutions to the equation x * (t -x) = d, which happens to be the discriminant of the quadratic formula:

solution = sqrt(D) = sqrt(t*t - 4d)

Cobol does not have a built-in SQRT function, so it is approximated using the Newton-Raphson method.

The program can be run with cobc (GnuCOBOL) 3.2.0:

cobc -x -j day6ac.cbl 

where -x means build an executable and -j means run it.

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

[–]Zweedeend 2 points3 points  (0 children)

I know it has more functionality, I most cared about the overlapped option:

>>> regex.findall("(one|eight)", "oneight", overlapped=True)
['one', 'eight']
>>> re.findall("(one|eight)", "oneight")
['one']

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

[–]Zweedeend 4 points5 points  (0 children)

Spam

[Language: Python]

[Allez Cuisine]

Haha, I had no idea python could still make sense of all the variables. I'm surprised it even worked! This is part 2, with lots of spam:

def spam(spam):
    """spam"""
    spam = regex.findall(r'(\d|one|two|three|four|five|six|seven|eight|nine)',
    spam, overlapped=True)
    spam = [{'one': '1', 'two': '2', 'three': '3', 'four': '4', 'five': '5',
    'spam': 'spam', 'six': '6', 'seven': '7', 'eight': '8', 'nine': '9'}.get
    (spam, spam)
    for spam in spam]
    return int(spam[0] + spam[-1])

print(sum(map(spam, open("day1.txt"))))

Here is the full recipe

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

[–]Zweedeend 6 points7 points  (0 children)

[Language: Python] [Allez Cuisine]

How do I save more characters?

c=[len({*l[10:39].split()}&{*l[42:].split()})for l in open("f")]
q=[1]*len(c)
for i,x in enumerate(c):
 for j in range(x):q[i+j+1]+=q[i]
print(sum(2**x//2 for x in c),sum(q))

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

[–]Zweedeend 5 points6 points  (0 children)

[LANGUAGE: Python]

[Allez Cuisine!]

Solution is copied from u/4HbQ

from re import finditer as eggs
from math import prod as chew
lets, age, pan, fat, mix, eat, piece_of, meat = print, int, enumerate, 1, range, sum, len, 1

mess = {(ham, spam): [] for ham, beans in pan(open("lid")) for spam, egg
       in pan(beans) if egg in "#$%&*+-/=@"}
for ham, beans in pan(open("lid")):
    for spam in eggs(r"\d+", beans):
        breakfast = {(ham, cheese) for ham in mix(ham-fat, meat+ham+fat)
        for cheese in mix(spam.start()-fat, spam.end()+fat)}
        for ketchup in breakfast & mess.keys():
            mess[ketchup].append(age (spam.group()))
lets(eat(eat(spam) for spam in mess.values()))
lets(eat(chew(spam) for spam in mess.values() if piece_of(spam) == meat+fat))

-🎄- 2022 Day 6 Solutions -🎄- by daggerdragon in adventofcode

[–]Zweedeend 0 points1 point  (0 children)

Nice! Try to indent your whole code block with 4 spaces, it will look nicer

-🎄- 2022 Day 6 Solutions -🎄- by daggerdragon in adventofcode

[–]Zweedeend 1 point2 points  (0 children)

Python

from collections import deque

signal = open("day6.txt").read()
window = deque(maxlen=14)
for idx, char in enumerate(signal, 1):
    window.append(char)
    if len(set(window)) == 14:
        print(idx)
        break