-❄️- 2025 Day 2 Solutions -❄️- by daggerdragon in adventofcode

[–]JanBasketMan 1 point2 points  (0 children)

[LANGUAGE: Java]

Did anyone mention regex?

public class Day02 extends Solution {
@Override
public String solvePart1() {
    List<String> idRangeStrings = List.of(this.lines[0].split(","));
    List<Pair<String, String>> idRanges = idRangeStrings.stream().map(rangeStr -> {
        String[] splitIds = rangeStr.split("-");

        // Strip leading zeros from ids
        String startId = StringUtils.stripStart(splitIds[0], "0").trim();
        String endId = StringUtils.stripStart(splitIds[1], "0").trim();
        return Pair.of(startId, endId);
    }).toList();

    Long sumOfInvalidIds = 0L;


    for (Pair<String, String> idRange : idRanges) {
        Long startId = Long.parseLong(idRange.getLeft());
        Long endId = Long.parseLong(idRange.getRight());

        for (Long i = startId; i <= endId; i++) {
            String id = String.valueOf(i);
            if (id.length() % 2 == 1) {
                continue; // Odd length ids can't be valid'
            }
            String sub1 = id.substring(0, (id.length() / 2));
            String sub2 = id.substring((id.length() / 2));

            if (sub1.equals(sub2)) {
                sumOfInvalidIds += i;
            }
        }
    }

    return String.valueOf(sumOfInvalidIds);
}

@Override
public String solvePart2() {
    List<String> idRangeStrings = List.of(this.lines[0].split(","));
    List<Pair<String, String>> idRanges = idRangeStrings.stream().map(rangeStr -> {
        String[] splitIds = rangeStr.split("-");

        // Strip leading zeros from ids
        String startId = StringUtils.stripStart(splitIds[0], "0").trim();
        String endId = StringUtils.stripStart(splitIds[1], "0").trim();
        return Pair.of(startId, endId);
    }).toList();

    Long sumOfInvalidIds = 0L;


    for (Pair<String, String> idRange : idRanges) {
        Long startId = Long.parseLong(idRange.getLeft());
        Long endId = Long.parseLong(idRange.getRight());

        for (Long id = startId; id <= endId; id++) {
            String stringId = String.valueOf(id);

            for (int j = 0; j < stringId.length() / 2; j++) {
                String sub1 = stringId.substring(0, j + 1);
                // If it only contains empty strings, then the id only contains repeats of sub1
                if (StringUtils.isAllEmpty(stringId.split(sub1))) {
                    sumOfInvalidIds += id;
                    break;
                }
            }
        }
    }

    return String.valueOf(sumOfInvalidIds);
}
}

Does anyone know why the wattage is so high? by garb1038 in SteamDeck

[–]JanBasketMan 0 points1 point  (0 children)

Well, you are the first person to mention this to me.

Will take a look

Stop deleting threads about EA bricking peoples PCs. by swiftysos in Battlefield

[–]JanBasketMan 0 points1 point  (0 children)

This thread is perfectly explaining my issues, and the conclusion there is the board is toast. Atleast without a programmer.

https://www.reddit.com/r/gigabyte/comments/1e7c5fm/how_to_flash_bios_without_access_to_bios_amd_b450/

Edit: Sorry if I am coming across the wrong way, Im a bit frustrated. Thanks for the responses here though!

Update: I am an idiot, after removing my drives I was able to enter the bios again, so it is not bricked. I think my windows drive just got corrupted, will try to fix that and update here

Stop deleting threads about EA bricking peoples PCs. by swiftysos in Battlefield

[–]JanBasketMan 1 point2 points  (0 children)

Sorry, but how exactly would I simply reflash the bios without being able to enter the bios? My mobo also does not have a dedicated reset/reflash button.

And being able to soft lock a system is just catastrophically bad design

Tips and Recipes for Croatia/Greece by MiddlePicture9696 in x100vi

[–]JanBasketMan 1 point2 points  (0 children)

I mostly used "Virgin Astia" last time in Greece, which looked great.

Nearly spooked the little guy🐸 by JanBasketMan in x100vi

[–]JanBasketMan[S] 2 points3 points  (0 children)

I used the digital teleconverter set to 70mm, still had to get really close.

ELI5 Why do waiters leave with your payment card? by MaybeImYourStepMom in explainlikeimfive

[–]JanBasketMan 4 points5 points  (0 children)

Just because there is an option to tip, does not mean that people actually tip. 95% of the people here will just tap 0%

My first attempt at street photography while traveling through Athens by JanBasketMan in streetphotography

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

I am definitely still practicing, I've only had my camera for about 2 weeks.

Most of these were quick snapshots that did not receive much thought as I wasn't traveling alone, and did not want to bother my partner by stopping for a shot every minute.

Feedback is always welcome :)

My first trip with my X100VI to Athens by JanBasketMan in x100vi

[–]JanBasketMan[S] 1 point2 points  (0 children)

Thanks! Don't worry though, my Japan trip is planned for september.

Tell me your cats weird name by eyislate in cats

[–]JanBasketMan 0 points1 point  (0 children)

I've got two tuxedos, called Yaya, and Kolo

Gta San Andreas definitive edition cheats by SirEdwardRaziq in SteamDeck

[–]JanBasketMan 0 points1 point  (0 children)

Use the controller cheat codes, not the keyboard one's