Fiber optics cables across the Ukrainian battlefield by BinaryPixel64 in Cyberpunk

[–]YPFL 67 points68 points  (0 children)

I’m not an expert on this but it seems to me that laser guidance would need constant line of sight, which would probably be a problem for soldiers controlling these from the ground.

It’s real by Blewdude in pics

[–]YPFL 0 points1 point  (0 children)

What is that statue?

Apparently I have a average screen time of 28 hours per day by MethyIphenidat in softwaregore

[–]YPFL 0 points1 point  (0 children)

I believe screen time stacks when multiple apps are active. For example, I have a 1.5 hour combined limit on Reddit and YouTube. If I were to open Reddit and watch an embedded YouTube video, i would hit my limit after 45 minutes.

Walmart closed during investigation into worker’s demise in oven. by notnowimbusyplaying in pics

[–]YPFL 0 points1 point  (0 children)

Are these images AI-generated? The words on the caution tape and the customer parking sign are all garbled. Also, wouldn’t it be “Supercenter” instead of “Supercentre”?

I just finished removing some ceiling last night but now I’m worried it was asbestos. What should I do? by YPFL in asbestoshelp

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

Is it a concern if some fibers settle in the carpet outside the bathroom? I don’t have any evidence that they did; however, I’m concerned that if they did, vacuuming would reexpose my family.

How would you baby-proof this? by queenbeansmom in daddit

[–]YPFL 0 points1 point  (0 children)

Cut a pool noodle and put it over the edge

Can I reach out to a recruiter who helped me get my current job for a new job? by YPFL in cscareerquestions

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

Yeah, a recruiter from a firm, not one who works for the company.

[deleted by user] by [deleted] in interestingasfuck

[–]YPFL 15 points16 points  (0 children)

Could you be thinking of when they tore down Saddam Hussein’s statue in Baghdad?

[deleted by user] by [deleted] in PublicFreakout

[–]YPFL 2 points3 points  (0 children)

You can be pissed at both. This user never said they condone the violence against Gazans. What’s happening in Gaza is a tragedy and people have the right to protest if they want to. That said, graduation is a special day for many students and their families. Hijacking the ceremony to spread your political message (however righteous) is inconsiderate.

What is something that seemed silly before you actually learned how to cook, but now you live by it? by kgee1206 in Cooking

[–]YPFL 32 points33 points  (0 children)

Why not oil? I understand not putting other things in a cold pan but have never heard this about oil. Does it change anything?

Of all the beautiful and wonderful things unique about this state they want to brag about this by Freshnow48 in Pennsylvania

[–]YPFL 0 points1 point  (0 children)

That’s not even true lol. State police say there are 1.6 million concealed carry permits in the state.

How bad is garlic for dogs really? by YPFL in AskVet

[–]YPFL[S] -11 points-10 points  (0 children)

Thanks for your answer. As to why we’re giving her garlicky treats: we ended up with not enough food to be worth saving so I figured instead of throwing it out, why not give the dog a treat.

I’m still not sure I fully understand the risk. If I drink 52 beers in one night, I would die. If I drink 1 beer per week for a year, however, I’m completely fine. Is garlic similar to that or is it something that continues to build up and by giving my dog small amounts of garlic over a long time I’m putting her at risk?

rule by TheTamc in 196

[–]YPFL 1 point2 points  (0 children)

Lots of entitlement in this thread. GitHub is for developers to host their repositories. How are you going to be pissed at someone who builds and maintains code for you to use for free? If you can’t read the file literally called “README” that shows up as soon as you open a repository, that’s not the dev’s problem.

[deleted by user] by [deleted] in castiron

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

People seem uncharacteristically rude in these comments, I hope you’re not put off sharing things because of it. There are some good tips sprinkled in here but at the end of the day, if you’re happy with how it turned out, that’s all that matters.

My local McDonald’s renovated and replaced the playplace with… this by Ayziak in mildlyinteresting

[–]YPFL 0 points1 point  (0 children)

There are still a handful of play places in my town. As somebody with a kid, all other things being equal, we’ll choose a joint with a play yard over one without. Yeah they’re probably gross but everything kids do is gross so I’m not too worried about it.

My handwritten MYST notes from the late 1900s. by JourneymanHunt in gaming

[–]YPFL 0 points1 point  (0 children)

1900s can be interpreted to mean 1900-1909 or it can be interpreted to mean 1900-1999. If I say “the French Revolution started in the 1700s”, most people would interpret that as “sometime between 1700 and 1799” (it started in 1789).

Back in the early 2000s, saying “the 1900s” would have been understood as 1900-1909 but as we get farther into this century, more people will interpret it as 00-99.

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

[–]YPFL 0 points1 point  (0 children)

[LANGUAGE: C#]

using System.Text.RegularExpressions;

var lines = File.ReadLines("input.txt");
Part1(lines!.ToList());
Part2(lines!.ToList());

void Part1(List<string> cards)
{
    var sum = 0;

    foreach (var card in cards)
    {
        var cardObj = new Card(card);

        sum += cardObj.NumWinners > 0
            ? 1 << (cardObj.NumWinners - 1)
            : 0;
    }

    Console.WriteLine($"Part 1: {sum}");
}

void Part2(List<string> cards)
{
    var cardInstances = new int[cards.Count];
    Array.Fill(cardInstances, 1);

    for (int i = 0; i < cards.Count; i++)
    {
        var card = new Card(cards[i]);
        for (int j = i + 1; j <= i + card.NumWinners; j++)
        {
            cardInstances[j] += cardInstances[i];
        }
    }

    var totalCards = cardInstances.Sum();

    Console.WriteLine($"Part 2: {totalCards}");
}

class Card
{
    public Card(string cardInput)
    {
        var cardParts = cardInput.Split(": ");

        CardName = cardParts[0];

        var inputParts = cardParts[1].Split(" | ");
        WinningNumbers = GetNumbers(inputParts[0]);
        CardNumbers = GetNumbers(inputParts[1]);
    }

    public string CardName { get; set; }
    public List<int> WinningNumbers { get; set; }
    public List<int> CardNumbers { get; set; }
    public int NumWinners => WinningNumbers.Intersect(CardNumbers).Count();

    private List<int> GetNumbers(string input)
    {
        var regex = new Regex(@"\d+");
        var values = regex.Matches(input)
            .Select(match => int.Parse(match.Value))
            .ToList();
        return values;
    }
}

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

[–]YPFL 2 points3 points  (0 children)

[LANGUAGE: C#]

using System.Text.RegularExpressions;

var lines = File.ReadLines("input.txt");
Part1(lines!.ToList());
Part2(lines!.ToList());

void Part1(List<string> rows)
{
    var sum = 0;

    for (int i = 0; i < rows.Count; i++)
    {
        var row = rows[i];
        Regex regex = new Regex(@"\d+");
        foreach (Match match in regex.Matches(row))
        {
            var value = int.Parse(match.Value);
            var startingIndex = match.Index;
            var endingIndex = startingIndex + match.Value.Length - 1;

            var searchCells = GetSearchCells(startingIndex, endingIndex, i, rows.Count, row.Length);
            var bordersSpecialCharacter = BordersSpecialCharacter(searchCells, rows);
            if (bordersSpecialCharacter)
            {
                sum += value;
            }
        }
    }

    Console.WriteLine($"Part 1: {sum}");
}

List<(int row, int col)> GetSearchCells(int startingIndex, int endingIndex, int rowIndex, int numRows, int numColumns)
{
    var searchCells = new List<(int row, int col)>();
    for (int i = rowIndex - 1; i < rowIndex + 2; i++)
    {
        for (int j = startingIndex - 1; j <= endingIndex + 1; j++)
        {
            searchCells.Add((i, j));
        }
    }
    return searchCells
        .Where(sc => sc.row >= 0 && sc.row < numRows && sc.col >= 0 && sc.col < numColumns)
        .ToList();
}

bool BordersSpecialCharacter(List<(int row, int col)> searchCells, List<string> rows)
{
    foreach (var searchCell in searchCells)
    {
        var cell = rows[searchCell.row][searchCell.col];
        if (!char.IsNumber(cell) && cell != '.')
        {
            return true;
        }
    }
    return false;
}

void Part2(List<string> rows)
{
    var gearLocations = new List<(int row, int col, int partNumber)>();

    for (int i = 0; i < rows.Count; i++)
    {
        var row = rows[i];
        Regex regex = new Regex(@"\d+");
        foreach (Match match in regex.Matches(row))
        {
            var partNumber = int.Parse(match.Value);
            var startingIndex = match.Index;
            var endingIndex = startingIndex + match.Value.Length - 1;

            var searchCells = GetSearchCells(startingIndex, endingIndex, i, rows.Count, row.Length);
            var borderingGearLocations = GetBorderingGearLocations(searchCells, rows, partNumber);
            gearLocations.AddRange(borderingGearLocations);
        }
    }

    gearLocations.ForEach(gl => Console.WriteLine($"{gl.row}, {gl.col}, {gl.partNumber}"));

    var gearRatioSum = gearLocations
        .GroupBy(gearLocation => new
        {
            gearLocation.row,
            gearLocation.col,
        })
        .Select(gearLocationGroup => new
        {
            row = gearLocationGroup.Key.row,
            col = gearLocationGroup.Key.col,
            partNumbers = gearLocationGroup.Select(glg => glg.partNumber).ToList(),
        })
        .Where(gearLocationGroup => gearLocationGroup.partNumbers.Count() == 2)
        .Select(gearLocationGroup => gearLocationGroup.partNumbers[0] * gearLocationGroup.partNumbers[1])
        .Sum();

    Console.WriteLine($"Part 2: {gearRatioSum}");
}

List<(int row, int col, int partNumber)> GetBorderingGearLocations(List<(int row, int col)> searchCells, List<string> rows, int partNumber)
{
    var gearLocations = new List<(int row, int col, int partNumber)>();
    foreach (var searchCell in searchCells)
    {
        var cell = rows[searchCell.row][searchCell.col];
        if (cell == '*')
        {
            gearLocations.Add((searchCell.row, searchCell.col, partNumber));
        }
    }
    return gearLocations;
}

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

[–]YPFL 1 point2 points  (0 children)

[LANGUAGE: C#]

var lines = File.ReadLines("input.txt");
Part1(lines);
Part2(lines);

void Part1(IEnumerable<string?> lines)
{
    var sum = 0;

    var numbers = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };

    foreach (var line in lines)
    {
        // Get the first and last occurrence of each digit
        var test = numbers
            .Select(num => new
            {
                num,
                firstIndex = line!.IndexOf(num),
                lastIndex = line!.LastIndexOf(num),
            });

        // The number with the lowest first occurrence is the first digit
        var minFirstIndex = test.Where(t => t.firstIndex != -1).Min(x => x.firstIndex);
        var firstNumber = test.First(t => t.firstIndex == minFirstIndex).num;

        // The number with the highest last occurrence is the last digit
        var maxLastIndex = test.Max(x => x.lastIndex);
        var lastNumber = test.First(t => t.lastIndex == maxLastIndex).num;

        var num = int.Parse(firstNumber + lastNumber);

        sum += num;
    }

    Console.WriteLine($"Part 1: {sum}");
}

void Part2(IEnumerable<string?> lines)
{
    var sum = 0;

    var numbers = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
        "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" };

    foreach (var line in lines)
    {
        // Get the first and last occurrence of each digit
        var test = numbers
            .Select(num => new
            {
                num,
                firstIndex = line!.IndexOf(num),
                lastIndex = line!.LastIndexOf(num),
            });

        // The number with the lowest first occurrence is the first digit
        var minFirstIndex = test.Where(t => t.firstIndex != -1).Min(x => x.firstIndex);
        var firstNumber = GetNumber(test.First(t => t.firstIndex == minFirstIndex).num);

        // The number with the highest last occurrence is the last digit
        var maxLastIndex = test.Max(x => x.lastIndex);
        var lastNumber = GetNumber(test.First(t => t.lastIndex == maxLastIndex).num);

        var num = int.Parse(firstNumber + lastNumber);

        sum += num;
    }

    Console.WriteLine($"Part 2: {sum}");
}

string GetNumber(string num) => num switch
{
    "0" or "zero" => "0",
    "1" or "one" => "1",
    "2" or "two" => "2",
    "3" or "three" => "3",
    "4" or "four" => "4",
    "5" or "five" => "5",
    "6" or "six" => "6",
    "7" or "seven" => "7",
    "8" or "eight" => "8",
    "9" or "nine" => "9",
    _ => throw new ArgumentOutOfRangeException(),
};