[-] purplemonkeymad@programming.dev 3 points 7 months ago

They have precidet! The UK already went with the latter.

[-] purplemonkeymad@programming.dev 3 points 7 months ago

Well those would have included the update checker. So if you installed from a package manager, then let it update when prompted for the new version, you could still have been at risk.

[-] purplemonkeymad@programming.dev 3 points 8 months ago

Yea it was really annoying that you couldn't just limit it to your uploads. Any search or change of filters would just end up adding results from the rest of yt music. In then end I've moved over to jellyfin with finamp.

[-] purplemonkeymad@programming.dev 3 points 8 months ago

Yea I do find that often there is no bandcamp page, or it's 5 years old with no new albums. In those cases my next check is qobiz as they tend to have more large artists.

[-] purplemonkeymad@programming.dev 3 points 8 months ago

Which is meant to be the same as a rejection. If they have correctly implemented it is another thing.

Has 9 videos and 0.5M subs, I feel they might be worth looking at!

Fences don't always work, I saw one go up and soon had a hole in it. Turns out deer are pretty persistent and willing to break them. Paths are not just used by people.

The point of having a high entropy password is to protect against hackers brute forcing a leaked database of hashes.

I don't think you need to worry about that in this case, the special character restriction suggests to me that they don't hash it.

There was no plan, just a nationalist agenda that didn't like the EU. They didn't think about post Brexit at all, other than to come up with some good sounding fantasies for the campaign.

That is just more propaganda. In the netflix program about it they show that they can't tell the difference.

The whole natural diamond thing is they want to control the volume of diamonds on the market. If you can make them, then there will be such a high production the prices will plummet. The only reason the price is high, is that they keep production low.

[-] purplemonkeymad@programming.dev 3 points 2 years ago* (last edited 2 years ago)

This felt ... too simple. I think the hardest part of part two for me was reading comprehension. My errors were typically me not reading exactly was there.

Pythonimport re import math import argparse import itertools

def int_hash(string:str) -> int:
    hash = 0
    for c in [*string]:
        hash += ord(c)
        hash *= 17
        hash = hash % 256
    return hash

class Instruction:
    def __init__(self,string:str) -> None:
        label,action,strength = re.split('([-=])',string)
        self.label = label
        self.action = action
        if not strength:
            strength = 0
        self.strength = int(strength)
    
    def __repr__(self) -> str:
        return f"Instruction(l={self.label}, a={self.action}, s={self.strength})"
    
    def __str__(self) -> str:
        stren = str(self.strength if self.strength > 0 else '')
        return f"{self.label}{self.action}{stren}"


class Lens:
    def __init__(self,label:str,focal_length:int) -> None:
        self.label:str = label
        self.focal_length:int = focal_length

    def __repr__(self) -> str:
        return f"Lens(label:{self.label},focal_length:{self.focal_length})"
    
    def __str__(self) -> str:
        return f"[{self.label} {self.focal_length}]"

def main(line_list:str,part:int):
    init_sequence = line_list.splitlines(keepends=False)[0].split(',')
    sum = 0
    focal_array = dict[int,list[Lens]]()
    for i in range(0,256):
        focal_array[i] = list[Lens]()
    for s in init_sequence:
        hash_value = int_hash(s)
        sum += hash_value

        # part 2 stuff
        action = Instruction(s)
        position = int_hash(action.label)
        current_list = focal_array[position]
        existing_lens = list(filter(lambda x:x.label == action.label,current_list))
        if len(existing_lens) > 1:
            raise Exception("multiple of same lens in box, what do?")
        match action.action:
            case '-':
                if len(existing_lens) == 1:
                    current_list.remove(existing_lens[0])
            case '=':
                if len(existing_lens) == 0:
                    current_list.append(Lens(action.label,action.strength))
                if len(existing_lens) == 1:
                    existing_lens[0].focal_length = action.strength
            case _:
                raise Exception("unknown action")

    print(f"Part1: {sum}")
    #print(focal_array)

    sum2 = 0
    for i,focal_box in focal_array.items():
        for l,lens in enumerate(focal_box):
            sum2 += ( (i+1) * (l+1) * lens.focal_length )

    print(f"Part2: {sum2}")


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="template for aoc solver")
    parser.add_argument("-input",type=str)
    parser.add_argument("-part",type=int)
    args = parser.parse_args()
    filename = args.input
    if filename == None:
        parser.print_help()
        exit(1)
    part = args.part
    file = open(filename,'r')
    main(file.read(),part)
    file.close()

[-] purplemonkeymad@programming.dev 3 points 2 years ago* (last edited 2 years ago)

I saw that coming, but decided to do it the naive way for part 1, then fixed that up for part 2. Thanks to AoC I can also recognise a Manhattan distance written in a complex manner.

Pythonfrom future import annotations

import re
import math
import argparse
import itertools

def print_sky(sky:list):
    for r in sky:
        print("".join(r))

class Point:
    def __init__(self,x:int,y:int) -> None:
        self.x = x
        self.y = y

    def __repr__(self) -> str:
        return f"Point({self.x},{self.y})"

    def distance(self,point:Point):
        # Manhattan dist
        x = abs(self.x - point.x)
        y = abs(self.y - point.y)
        return x + y

def expand_galaxies(galaxies:list,position:int,amount:int,index:str):
    for g in galaxies:
        if getattr(g,index) > position:
            c = getattr(g,index)
            setattr(g,index, c + amount)

def main(line_list:list,part:int):
    ## list of lists is the plan for init idea

    expand_value = 2 -1
    if part == 2:
        expand_value = 1e6 -1
    if part > 2:
        expand_value = part -1

    sky = list()
    for l in line_list:
        row_data = [*l]
        sky.append(row_data)
    
    print_sky(sky)
    
    # get galaxies
    gal_list = list()
    for r in range(0,len(sky)):
        for c in range(0,len(sky[r])):
            if sky[r][c] == '#':
                gal_list.append(Point(r,c))

    print(gal_list)

    col_indexes = list(reversed(range(0,len(sky))))
    # expand rows
    for i in col_indexes:
        if not '#' in sky[i]:
            expand_galaxies(gal_list,i,expand_value,'x')

    # check for expanding columns
    for i in reversed( range(0, len( sky[0] )) ):
        col = [sky[x][i] for x in col_indexes]
        if not '#' in col:
            expand_galaxies(gal_list,i,expand_value,'y')

    print(gal_list)

    # find all unique pair distance sum, part 1
    sum = 0
    for i in range(0,len(gal_list)):
        for j in range(i+1,len(gal_list)):
            sum += gal_list[i].distance(gal_list[j])

    print(f"Sum distances: {sum}")

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="template for aoc solver")
    parser.add_argument("-input",type=str)
    parser.add_argument("-part",type=int)
    args = parser.parse_args()
    filename = args.input
    if filename == None:
        parser.print_help()
        exit(1)
    part = args.part
    file = open(filename,'r')
    main([line.rstrip('\n') for line in file.readlines()],part)
    file.close()

view more: ‹ prev next ›

purplemonkeymad

0 post score
0 comment score
joined 3 years ago