imperialismus's recent activity

  1. Comment on Day 9: Movie Theater in ~comp.advent_of_code

    imperialismus
    Link Parent
    Thanks for the hint about Shapely. I wasn't able to solve yesterday, got encouraged by today's part 1 being trivial, then failed to solve part 2 after lots of effort. I was about ready to admit...

    Thanks for the hint about Shapely. I wasn't able to solve yesterday, got encouraged by today's part 1 being trivial, then failed to solve part 2 after lots of effort. I was about ready to admit that maybe I've reached the difficulty spike where I can't solve these things in a reasonable time, but after finding that library I was at least able to get a working solution. I'm writing this just as next day's puzzle goes live, so I'll at least give that one a look without being completely deflated!

    1 vote
  2. Comment on Day 7: Laboratories in ~comp.advent_of_code

    imperialismus
    Link
    I didn't come up with a clever single-pass solution, but I can confirm it's feasible to solve with recursion with memoization. Still runs in about 70ms on my machine, which is good enough for me....

    I didn't come up with a clever single-pass solution, but I can confirm it's feasible to solve with recursion with memoization. Still runs in about 70ms on my machine, which is good enough for me.

    Solution part 2 (Crystal)
    class Solver
        @line_len : Int32
        @num_rows : Int32
        @s : Array(String)
    
        def initialize(s : String)
            @s = s.split("\n")
            @line_len = @s[0].size
            @num_rows = @s.size
            @cache = {} of {Int32, Int32} => Int64
        end
    
        def solve
            start = @s[0].index("S").as(Int32)
            search(1, start)
        end
    
        def search_with_cache(row : Int32, col : Int32) : Int64
            if res = @cache[{row,col}]?
                res
            else
                @cache[{row,col}] = search(row, col)
            end
        end
    
        def search(row : Int32, col : Int32) : Int64
            unless col >= 0 && col < @line_len
                puts "out of bounds"
                return 1i64
            end
            count : Int64 = 0
            while row < @num_rows
                char = @s[row][col]
                if char == '^'
                    count += search_with_cache(row+1, col+1)
                    count += search_with_cache(row+1, col-1)
                    return count
                else
                    row += 1
                end
            end
            count+1
        end
    end
    
    input = File.read("./input.txt")[0..-2]
    solver = Solver.new(input)
    puts solver.solve
    
    1 vote
  3. Comment on Day 6: Trash Compactor in ~comp.advent_of_code

    imperialismus
    (edited )
    Link
    Yesterday was rough. After trying a long time, I gave up on solving the range merging and resorted to copying some code off Google (not specifically AoC code, so not technically cheating, but it...

    Yesterday was rough. After trying a long time, I gave up on solving the range merging and resorted to copying some code off Google (not specifically AoC code, so not technically cheating, but it felt like a moral loss). Today on the other hand was a big morale boost. I actually bought a physical notepad with grid paper to sketch things out, but in the end I didn't need it for this problem, although it might come in handy later!

    Part 2 solution (Python)
    from functools import reduce
    import operator
    
    def gen_problems(s):
        lines = s.split("\n")
        grid = [list(line) for line in lines]
        operands = []
        buf = []
        for col in range(len(grid[0])):
            digits = "".join([grid[row][col] for row in range(len(grid)-1)])
            if digits.isspace():
                operands.append(buf)
                buf = []
            else:
                buf.append(int(digits))
        operands.append(buf)
        operations = lines[-1].split()
        return operands, operations
    
    def compute_problems(operands, operations):
        total = 0
        for index, op in enumerate(operations):
            nums = operands[index]
            if op == "+":
                total += sum(nums)
            elif op == "*":
                total += reduce(operator.mul, nums)
        return total
    
    input = open("./input.txt").read()[0:-2]
    print(compute_problems(*gen_problems(input)))
    
    2 votes
  4. Comment on Day 6: Trash Compactor in ~comp.advent_of_code

    imperialismus
    Link Parent
    Yeah, it's supposed to be fun after all. I do wonder though, would it be cleaner to separate the parsing for part 1 and part 2? At least that's the approach I took.

    I'm not especially happy with my parsing logic, but it appears to do the job, and at this point I think I'm better off not messing with it any further.

    Yeah, it's supposed to be fun after all. I do wonder though, would it be cleaner to separate the parsing for part 1 and part 2? At least that's the approach I took.

  5. Comment on Inside the Reddit Thread That Blasts Big Meat for Hiring People to Take Down Veganism in ~tech

    imperialismus
    Link
    It's an "article" based entirely on summarizing one anonymous reddit poster. That's a big nothing burger. Even if I'm inclined to believe the premise, I could as easily imagine this post is...

    It's an "article" based entirely on summarizing one anonymous reddit poster. That's a big nothing burger. Even if I'm inclined to believe the premise, I could as easily imagine this post is actually a person paid to discedit the meat industry.

    14 votes
  6. Comment on IKEA finally arrives in New Zealand. Even the country's leader came out to celebrate. in ~finance

    imperialismus
    Link Parent
    Just build another actual garage for your car! /s But seriously, my uncle actually did this. His garage had become a permanently cluttered storage room attached to his house, and he was able to...

    Some looked pretty nice, but the problem with that is that the house no longer has a garage.

    Just build another actual garage for your car! /s

    But seriously, my uncle actually did this. His garage had become a permanently cluttered storage room attached to his house, and he was able to acquire an empty plot of land next to his property and built a detached garage. That's where he puts his car. Of course that isn't really feasible due to space and money constraints for most people, but I just wanted to chip in with a mildly funny anecdote.

    5 votes
  7. Comment on Advent of Compiler Optimisations, by Matt Godbolt in ~comp

    imperialismus
    Link
    Matt Godbolt, creator of the popular compiler explorer, is writing an advent calendar style series on various optimizations modern compilers do when they generate machine code. There's also an...

    Matt Godbolt, creator of the popular compiler explorer, is writing an advent calendar style series on various optimizations modern compilers do when they generate machine code. There's also an accompanying video series on youtube, but it covers the same material. Here's a link to the latest video as of today.

    3 votes
  8. Comment on Day 4: Printing Department in ~comp.advent_of_code

    imperialismus
    Link
    I sat there staring at part 1 for a while until I realized I'd made an incredibly obvious mistake, and after fixing that part 1 worked and part 2 was trivial. Thoughts The mistake was that I was...

    I sat there staring at part 1 for a while until I realized I'd made an incredibly obvious mistake, and after fixing that part 1 worked and part 2 was trivial.

    Thoughts

    The mistake was that I was counting all grid cells that had less than 4 paper roll neighbors, when I actually needed to count only the grid cells that contained a paper roll and had less than 4 neighbors. Here's my solution for part 2, in Python today:

    def get_pos(s, x, y, dim):
        if not x in range(dim) or not y in range(dim): return False
        return s[x][y] == "@"
    
    def count_adjacent(s, x, y, dim):
        count = 0
        MATRIX = [[-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1]]
        for (x2,y2) in MATRIX:
            if get_pos(s, x+x2, y+y2, dim):
                count += 1
        return count
    
    def count(s):
        dim = len(s)
        count = 0
        for x in range(0,dim):
            for y in range(0,dim):
                if s[x][y] == "@" and count_adjacent(s, x, y, dim)<4:
                    count += 1
                    s[x][y] = "."
        return count, s
    
    def count_recursive(s):
        s = [list(x) for x in s.split("\n")]
        total = 0
        while True:
            num, s = count(s)
            if num == 0: break
            total += num
        return total
    
    print(count_recursive(open("./input.txt").read()))
    

    I saw some comments on reddit saying that based on previous years, the difficulty should start ramping up soon, especially with only twelve days this year. For those of you who have done previous years, does it get progressively harder, and what do you think of this year's difficulty so far?

    1 vote
  9. Comment on Day 3: Lobby in ~comp.advent_of_code

    imperialismus
    Link
    I was able to solve days 1 and 2, but I wasn't satisfied at all with the quality of my solutions. Today's puzzle I think kind of forces you to come up with a relatively efficient solution, and I'm...

    I was able to solve days 1 and 2, but I wasn't satisfied at all with the quality of my solutions. Today's puzzle I think kind of forces you to come up with a relatively efficient solution, and I'm happy enough with it to post it. I'm just a hobby programmer and I haven't done a ton of leetcode or previous years of Advent of Code, so for a lot of these problems, I lack prebuilt intuitions on how to solve them (particularly the more generalized part 2 problems).

    Solution (Crystal)
    def max_jolt(bank : String, num_digits : Int32 = 12) : Int64
        digits = [] of Int32
        raise "error" if bank.size < num_digits
        i = 0
        num_digits.times do
            max = 0
            bank[0..bank.size - num_digits].each_char_with_index do |char, index|
                if char.to_i > max
                    i = index 
                    max = char.to_i 
                end 
            end
            digits << max
            num_digits -= 1
            bank = bank[i+1..-1] unless i>=bank.size
        end
        digits.map { |c| c.to_i }.join("").to_i64
    end
    
    sum : Int64 = 0
    File.read("input.txt").split("\n").each do |bank|
        sum += max_jolt(bank)
    end
    puts sum
    
    2 votes
  10. Comment on Study suggests that the Universe's expansion 'is now slowing, not speeding up' in ~space

    imperialismus
    Link Parent
    I looked into it, and it seems like this (the "firewall" thing) was first published in 2019. It's not a new discovery. I couldn't find any recent news published by NASA about this, but plenty from...
    • Exemplary

    The reporting on both seemed a little scant even after having searched for alternative articles.

    I looked into it, and it seems like this (the "firewall" thing) was first published in 2019. It's not a new discovery. I couldn't find any recent news published by NASA about this, but plenty from 2019. What appears to have happened is that someone, somewhere rediscovered this piece of news from 2019, posted about it as if it were a new discovery, and then that went somewhat viral and got amplified by numerous websites repeating the same information. You probably couldn't find anything that isn't just a rehash of the same information because they're all copying each other, copying old news from six years ago.

    Here's the original paper: https://www.nature.com/articles/s41550-019-0929-2

    NASA's own website has nothing I could find from this year relating to this particular discovery. The crossings of the Voyagers into interstellar space occurred in 2012 and 2018, respectively. In fact, the Voyager 2 plasma measurement instrument was recently turned off to conserve the dwindling power supply, and Voyager 1's similar instrument was turned off years ago. So it appears neither probe is actively collecting the sort of information that these studies were based on anymore.

    As for the reasons why these particles get so hot so far out: my layman's understanding is that it's theorized to be one or both of a) compression due to the meeting of the solar wind and the interstellar medium, and b) magnetic reconnection. When separate magnetic field lines meet up, they can convert magnetic energy into kinetic energy, heating up particles - it happens in the Earth's magnetosphere as well, and can even lead to a temporary reversal of the local solar wind, sending the particles back towards the Sun!

    7 votes
  11. Comment on Europa Universalis V review – even hardened grand strategy veterans may be startled by the intricacy of this historical simulation in ~games

    imperialismus
    Link Parent
    Pretty sure this is what Paradox has been saying about several of their games for years, including Victoria 3, and that exact phrase has certainly been circulating in the EU4 community for years...

    EUV specifies, at the beginning of the tutorial: you play as the “spirit of the nation.” Again, nation is an awkward word, but there’s none better. I admit, when I saw that, I laughed out loud because it was such a direct response – intended or not – to one of my critiques (particularly of Imperator, which shares its director, Johan Andersson with EUV).

    Pretty sure this is what Paradox has been saying about several of their games for years, including Victoria 3, and that exact phrase has certainly been circulating in the EU4 community for years (whether it was the developers or the community that first came up with it, I don't know). I like Bret's analysis because he analyzes historical games as history, that's kind of his whole thing, but on rare occasions I think he would do better if he analyzed games as a gamer.

    8 votes
  12. Comment on Microsoft's ambitious new Xbox: Your entire Xbox console library, the full power of Windows PC gaming, and no multiplayer paywall in ~games

    imperialismus
    Link
    "A premium experience" sounds a lot like "we're going to be pricing out half the console market and we don't care."

    "A premium experience" sounds a lot like "we're going to be pricing out half the console market and we don't care."

    10 votes
  13. Comment on Move over, Alan Turing: meet the working-class hero of Bletchley Park you didn’t see in the movies in ~comp

    imperialismus
    Link Parent
    I mean, the very next sentence says it's a great story but it couldn't be more wrong. The author is recounting the popular telling of the story. Later in the piece, he acknowledges what you said:

    I mean, the very next sentence says it's a great story but it couldn't be more wrong. The author is recounting the popular telling of the story. Later in the piece, he acknowledges what you said:

    In a lecture series in the 1930s, Newman had wondered if intractable maths problems could one day be automated away. He didn’t specify how this would be done, but one of his students – Turing – did, in what is now one of the most famous academic papers ever written, On Computable Numbers. This is the actual reason Turing is “the father of computing”.

    15 votes
  14. Comment on Grandmaster, popular commentator Daniel Naroditsky tragically passes away at 29 in ~games.tabletop

    imperialismus
    (edited )
    Link
    I'm usually not strongly affected by celebrity deaths; even if I admire and like a person, if I don't know them in person, there's limits to how strongly their passing can affect me. But I saw...

    I'm usually not strongly affected by celebrity deaths; even if I admire and like a person, if I don't know them in person, there's limits to how strongly their passing can affect me. But I saw some clips from Danya's last stream, just a couple of days ago. He was clearly not well and a friend had to show up at his house and convince him to turn off the stream. That reminded me of myself in some of my darkest, worst moments. Then he was found dead, possibly not even 48 hours later. After a year-long harrassment campaign by his own childhood idol, Vladmir Kramnik, who baselessly accused him of cheating. That really hit hard.

    I don't think I'll forget those brief clips. Especially with hindsight, it was genuinely haunting, but it was concerning even at the time. Everyone, take care of yourselves.

    Let me share one video of how Danya would probably like to be remembered: here's his recap of how he beat Fabiano Caruana with black in the US Championship.

    18 votes
  15. Comment on Indecision: Get a camera despite having a phone in ~tech

    imperialismus
    Link
    I'm a fairly serious photographer, and very fond of dedicated cameras, but: No. I wouldn't recommend a dedicated camera just to preserve memories, if you don't have at least a moderate interest in...

    I'm a fairly serious photographer, and very fond of dedicated cameras, but: No. I wouldn't recommend a dedicated camera just to preserve memories, if you don't have at least a moderate interest in photography for the sake of photography. Phone cameras these days are good enough to preserve most memories. There's an old adage among photographers, "f/8 and be there", meaning, technical details are unimportant compared to simply being in the right place at the right time and pushing down the shutter button. A phone is a lot more likely to be with you at the right moment. I'd rather invest in a newer phone with a better camera system, if the intent wasn't to take on photography as a serious hobby for the sake of photography, but rather, mostly to preserve moments and memories.

    5 votes
  16. Comment on Indecision: Get a camera despite having a phone in ~tech

    imperialismus
    Link Parent
    I would strongly recommend not listening to Ken Rockwell. The guy is extremely opinionated, and his opinions are frequently controversial among serious and professional photographers. For good...

    Don't shoot RAW. It's pointless and will just add hours to your workflow.

    I would strongly recommend not listening to Ken Rockwell. The guy is extremely opinionated, and his opinions are frequently controversial among serious and professional photographers. For good reason. This is one of them.

    RAW isn't going to add hours to your workflow, unless your workflow is very inefficent to begin with. You don't batch process hundreds of photos, you pick the best ones, make any necessary adjustments, and then convert those few RAWs into JPGs or TIFFs or whatever other format. Would you print 200 photos from a single photo session? Send your family a folder of 200 images of the same event? Probably not, at least if you're a semi-serious photographer. Processing a single RAW image into JPG or TIFF takes just a few seconds on my mid range PC. It was manageable even on a 2010 Macbook (not even a pro). Unless you save up months' worth of photos before processing them, it's unlikely you'll add more than 5-10 minutes at most.

    JPGs have less dynamic range than old school negative film. There are scenes that literally can't be accurately captured in JPG, but can in RAW. You could trust your camera's JPEG algorithm, but then again, you could trust your phone's computational photography too. If you're serious enough to own a dedicated interchangeable-lens camera in the year2025, you probably care enough to want the extra flexibility.

    You say:

    I like the restrictions it places on me, same as a prime lens does - when I'm taking pictures it makes me spend time thinking about composition rather than post-processing and composition is everything.

    But that's the opposite of what RAW does! RAW gives you more slack when it comes to technical choices like exposure and color balance, which means you can focus more on artistic choices like composition. If you want to override your JPG's default settings, you will suffer a loss in image quality. A RAW file is way more flexible. It allows you to focus on the things that you must get right in the moment, like the exact camera angle and the exact moment of pressing the shutter, while things like color balance and exposure have more leeway to be modified in post. Meanwhile, you can also just let Photoshop or Lightroom do their thing and not worry about it, for the cost of 5-10 seconds extra processing time per image.

    Post-processing isn't something you should be thinking about in the moment of taking a photo, unless it's a very special scenario in which you plan to use certain post processing techniques to achieve a certain effect that can't otherwise be achieved (e.g. multi-shot panorama or HDR). And contrary to what you said, RAW actually allows you to think less about post processing in the moment of making the photo, because you have more freedom to change things (or not change things) in post, versus "locking in" a JPG.

    Another benefit is time: modern software can do amazing things with old RAW files that neither camera hardware at the time of capture, nor modern software operating on old JPGs can.

    I'm not the kind of photographer to frequently make extensive edits in post. I prefer to do most things that can be done in camera, in camera, and have a lot of experience with analog photography. But I still shoot RAW all the time.

    5 votes
  17. Comment on ‘Taylor Swift: Showgirl’ at $33m an awesome anomaly for album pic launch; Dwayne Johnson sees lowest opening ever with ‘The Smashing Machine’ at $6m in ~movies

    imperialismus
    Link Parent
    I can't get over how unlike himself Dwayne Johnson looks in that movie. I'm a big fan of old school MMA, so I'll watch this film, but probably not until it's streaming somewhere. I think that's a...

    I can't get over how unlike himself Dwayne Johnson looks in that movie.

    I'm a big fan of old school MMA, so I'll watch this film, but probably not until it's streaming somewhere. I think that's a fairly narrow demographic though. MMA didn't really explode in popularity (outside Japan) until like 10 years after Mark Kerr's prime. It's the reason he went to Japan in the first place. Wonder what they think about the movie over there.

    7 votes
  18. Comment on Elon Musk plans to take on Wikipedia with 'Grokipedia' in ~tech

    imperialismus
    Link Parent
    Wikipedia articles are licensed under the CC BY-SA license, which (not a lawyer) appears to be compatible with what he's suggesting to do, provided there is a link to the original page, a clear...

    Wikipedia articles are licensed under the CC BY-SA license, which (not a lawyer) appears to be compatible with what he's suggesting to do, provided there is a link to the original page, a clear indication that the original has been modified, and that the content is re-licensed under the same conditions as the original.

    The license wasn't made with generative AI in mind, but the idea of basing a competing encyclopedia on modified versions of Wikipedia articles isn't inherently against the spirit of the project nor the letter of the license, provided it's done in the right way. In fact, Wikimedia Enterprise offers for-pay APIs to make it easier for corporations to re-use their content, but the for pay bit is explicitly not about paying for the right to reuse the content. It's for accessing specific APIs to make it easier to extract, work with and keep up with changes in Wikimedia content, as well as customer support for those APIs and services. The content itself is free, and Wikipedia explicitly tells corporate users not to ask them for permission to reproduce content, as that right is not Wikipedia's (it's covered by the license and the content belongs to the individual contributors, from a copyright standpoint Wikimedia owns almost none of its own content).

    5 votes
  19. Comment on Am I the only who finds raw photography souless? in ~arts

    imperialismus
    Link
    I think you framed the question a bit confusingly, and people get stuck on debating "RAW" which is standard for most professional photographers, when what I think you're trying to say is that you...

    I think you framed the question a bit confusingly, and people get stuck on debating "RAW" which is standard for most professional photographers, when what I think you're trying to say is that you dislike a certain "perfect" aesthetic, which is reminiscent of commercials. I think most people would be happy if their baby photos came out looking "like a Pampers commercial" because that's a metaphorically (and often literally) airbrushed version of reality. They don't want real, they want something that looks perfect in the way that parents view their children as perfect angels. But if you don't want that, there are surely photographers that could accomodate that, but as others have mentioned, that needs to be communicated.

    Most people don't know what they want or can't express it, so any sort of "art made on demand" like commercial portraiture involves a lot of guesswork. But to a certain extent I can see what you're getting at. For example, modern lenses are ultra sharp, to the point of sometimes being too revealing when used for things like portraiture. They're made that way because (presumably, I'm not an optics designer) it's easier and cheaper to make high quality optics now, and also, they need to keep up with ever increasing resolution. But I know there's been a trend of people using things like "black mist" filters on modern lenses, which create a softer look. And of course, even in the past, people were using tricks like shooting through semi-transparent gauze or applying vaseline to a filter in front of the lens to create the effect of smoothing out skin in a time before Photoshop and digital editing made all that easy to do in post.

    I can sort of understand what you're getting at, but I think if you want "less perfect" photos, you need to give your photographer references. Portrait photographers know what most people want, and know that most people aren't capable of verbalizing it, so they develop a style that satisfies most clients. But there are definitely ones out there that have more unique and less "lifestyle advertisement" like styles, they might just not be your average commercial portrait photographer. And I'm sure even an average commercial photographer could at least partially accomodate your requests if you actually give references and examples of what it is you want.

    11 votes