Skip Navigation

Posts
9
Comments
182
Joined
2 yr. ago

  • Maybe I should have written a longer comment to elaborate on what I meant. What I meant to say is that if your primary concern is sound quality rather than the experience physical media gives you, I would assume a flac file would be a more popular option due to its convenience.

  • There's way more to a game's look than textures though. Arguably ray tracing will have a greater impact than textures. Not to mention, for retro games, you could just generate the textures beforehand, no need to do it in real time.

  • If you're going for quality, you'd just buy the flac file though

  • Nobody would ever say "Asian" when referring to the south east Asians powers though. Call it European colonial powers or something. It gets tiresome being lumped in with destruction caused by Britain, France, etc... when your own nation was nothing but potato farmers at the time.

  • Appreciate the offer, but we want to try to avoid another situation with reports not being seen by mods for weeks.

  • Added as a moderator, we will likely add at least one more if there are more volunteers showing up.

  • programming.dev will migrate over to (lemmy compatible) Sublinks once it's ready, which will feature a different set of mod features. For that reason we will need new moderators to have an active programming.dev account. If you're willing keep an active user account on our instance let me know. We would prefer people we know will actively use their mod account to make sure reports are handled in a timely manner.

  • I'm pretty sure it's generating racially diverse nazis due to companies tinkering with the prompts under the hood to counterweight biases in the training data. A naive implementation of generative AI wouldn't output black or Asian nazis.

    it doesn't have EQ or sociological knowledge.

    It sort of does (in a poor way), but they call it bias and tries to dampen it.

  • The team is fairly unison in wanting to avoid defederation as much as possible and leave it users to filter out content they personally don't enjoy. Programming is a big and diverse field, and we want to make it as open as possible to everyone. Unless the instance breaks our own rules as described in the sidebar under "federation rules", I feel like it would be an overreach by us to defederate an instance due to personal opinion.

  • Too scarred from puzzle 5 to do the naïve approach anymore.

  • A nice change of pace from the previous puzzles, more maths and less parsing :::spoiler Python

     
        
    import math
    import re
    
    
    def create_table(filename: str) -> list[tuple[int, int]]:
        with open('day6.txt', 'r', encoding='utf-8') as file:
            times: list[str] = re.findall(r'\d+', file.readline())
            distances: list[str] = re.findall(r'\d+', file.readline())
        table: list[tuple[int, int]] = []
        for t, d in zip(times, distances):
            table.append((int(t), int(d)))
        return table
    
    
    def get_possible_times_num(table_entry: tuple[int, int]) -> int:
        t, d = table_entry
        l_border: int = math.ceil(0.5 * (t - math.sqrt(t**2 -4 * d)) + 0.0000000000001)  # Add small num to ensure you round up on whole numbers
        r_border: int = math.floor(0.5*(math.sqrt(t**2 - 4 * d) + t) - 0.0000000000001)  # Subtract small num to ensure you round down on whole numbers
        return r_border - l_border + 1
    
    
    def puzzle1() -> int:
        table: list[tuple[int, int]] = create_table('day6.txt')
        possibilities: int = 1
        for e in table:
            possibilities *= get_possible_times_num(e)
        return possibilities
    
    
    def create_table_2(filename: str) -> tuple[int, int]:
        with open('day6.txt', 'r', encoding='utf-8') as file:
            t: str = re.search(r'\d+', file.readline().replace(' ', '')).group(0)
            d: str = re.search(r'\d+', file.readline().replace(' ', '')).group(0)
        return int(t), int(d)
    
    
    def puzzle2() -> int:
        t, d = create_table_2('day6.txt')
        return get_possible_times_num((t, d))
    
    
    if __name__ == '__main__':
        print(puzzle1())
        print(puzzle2())
    
      
  • Personally I would recommend to use regex instead for parsing, which would also allow you to more easily test your expressions. You could then get the list as

     
        
    import re
    result = re.findall(r'[\w_]+|\S',  yourstring)  # This will preserve ULLONG_MAX as a single word if that's what you want
    
      

    As for what's wrong with your expressions:

    First expression: Once you hit (, OneOrMore(Char(printables)) will take over and continue matching every printable char. Instead you should use OR (|) with the alphanumerical first for priority OneOrMore(word | Char(printables))

    Second expression. You're running into the same issue with your use of +. Once string.punctuation takes over, it will continue matching until it encounters a char that is not a punctuation and then stop the matching. Instead you can write:

     
        
    parser = OneOrMore(Word(alphanums) | Word(string.punctuation))
    result = parser.parseString(yourstring)
    
    
      

    Do note that underscore is considered a punctutation so ULLONG_MAX will be split, not sure if that's what you want or not.

  • Photoshop (if it does?) and any other believable face swap apps use some sort of neural networks, which is exactly the problematic tech we are talking about.

  • Lower skill ceiling. One option can be done by pretty much anyone at a high volume output, the other would require a lot training and are not available for your average basement dweller.

    Good luck trying to regulate it though, Pandora's box is opened and you won't be able to stop the FOSS community from working on the tech.

  • I personally would prefer the if check and return 0 in most instances just because it's clearer and more readable. But the two previous functions were one-liners so it just looked better if get_winnings() also was.

  • Feels like the challenges are getting easier than harder currently. Fairly straightforward when doing it the lazy way with python. ::: spoiler Python

     
        
    import re
    
    winning_number_pattern: re.Pattern = re.compile(r' +([\d ]*?) +\|')
    lottery_number_pattern: re.Pattern = re.compile(r'\| +([\d ]*)')
    
    
    def get_winning_numbers(line: str) -> set[str]:
        return set(winning_number_pattern.search(line).group(1).split())
    
    
    def get_lottery_numbers(line: str) -> set[str]:
        return set(lottery_number_pattern.search(line).group(1).split())
    
    
    def get_winnings(winning_numbers: set[str], lottery_numbers: set[str]) -> int:
        return int(2 ** (len(winning_numbers.intersection(lottery_numbers)) - 1))
    
    
    def puzzle_1() -> int:
        points: int = 0
        with open('day4_scratchcards.txt', 'r', encoding='utf-8') as file:
            for line in file:
                points += get_winnings(get_winning_numbers(line), get_lottery_numbers(line))
        return points
    
    
    class ScratchCard:
        def __init__(self, line: str):
            self.amount: int = 1
            self.winnings: int = len(get_winning_numbers(line).intersection(get_lottery_numbers(line)))
    
        def update(self, extra: int) -> None:
            self.amount = self.amount + extra
    
        def __radd__(self, other):
            return self.amount + other
    
    
    def puzzle_2() -> int:
        scratch_card_list: list[ScratchCard] = []
        with open('day4_scratchcards.txt', 'r', encoding='utf-8') as file:
            for line in file:
                scratch_card_list.append(ScratchCard(line))
    
        for i, scratch_card in enumerate(scratch_card_list):
            for j in range(1, scratch_card.winnings + 1):
                try:
                    scratch_card_list[i + j].update(scratch_card.amount)
                except IndexError:
                    pass
        return sum(scratch_card_list)
    
    
    if __name__ == '__main__':
        print(puzzle_1())
        print(puzzle_2())