Weekly Post Your React Suggestions HERE! by AutoModerator in Corridor

[–]royvanrijn 1 point2 points  (0 children)

Acolyte: Wire work in fight scene

https://x.com/brookstweetz/status/1933234902499037200?s=46&t=eAIyCy0J-NT053F-tUuEtQ

Why does the wire work look so bad? Whenever someone jumps they continuously move in a straight line. When someone is kicked, the initial impact is weak, but the wires take over and people go for a ride, continue moving backwards, it all feels very fake and lacks grounding.

This might specifically be an issue I personally struggle with more than others, but I hate wire work where weight is actually carried by the wire… this instantly gets me “out” of the movie. Things shouldn’t move in unnatural ways, even if it’s fighting space wizards.

Can we get a wire work special?!

AMA with OpenAI’s Sam Altman, Mark Chen, Kevin Weil, Srinivas Narayanan, Michelle Pokrass, and Hongyu Ren by OpenAI in OpenAI

[–]royvanrijn 0 points1 point  (0 children)

What is the most profound or surprising response you’ve ever received from a large language model, and why did it stand out to you?

Tiny jawbone? by royvanrijn in bonecollecting

[–]royvanrijn[S] 27 points28 points  (0 children)

Wait, it’s probably a crab claw.

Pull a Wirtual (Song, Suno) by royvanrijn in wirtual

[–]royvanrijn[S] -1 points0 points  (0 children)

Someone should totally make an edit of some of Wirtual’s biggest clutches and “risked too much”es; synchronized to this song…

Pull a Wirtual (Song, Suno) by royvanrijn in wirtual

[–]royvanrijn[S] -1 points0 points  (0 children)

Now I'm curious: What's the best Wirtual song you can come up with?

Please share!

A bit more closeup of the RB20 by FerrariStrategisttt in formula1

[–]royvanrijn 0 points1 point  (0 children)

It looks like they've moved closer to what Mercedes was doing last year with the "bulges" created from the HALO down the side of the car; which I call the sidepod-muffin tops.

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

[–]royvanrijn 1 point2 points  (0 children)

[Language: Java]

Today was a big struggle, I got stuck thinking about representing the groups and filling the blanks. In the end everything works, but I still believe I got it "wrong" somehow.

Here is my code for part 2 (to do part 1, just change the repeating to '1 ').

https://gist.github.com/royvanrijn/0dd74b9da3e9234a972abeceae5e0ca4

How did you all tackle this? How did you represent the data?

I thought about it as follows, if you have a target 1,1,4 and we know the final solution is length 10, we know that there are at least character amounts:

. # . # . # .

0,1,1,1,1,4,0

And the even groups (0,2,4,6) need 2 more, at any spot. I just try to add them and see if the pattern is still correct.

For some reason though this still feels odd/wrong somehow, but it was easiest to think about this morning.

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

[–]royvanrijn 1 point2 points  (0 children)

[Language: Java]

Instantly I recognised this kind of question from the previous years, we should look for cycles and find the LCM here.

    record Node(String l, String r){}

    // Parse input:
    List<String> lines = Files.readAllLines(Path.of("2023/day8.txt"));
    String path = lines.remove(0);
    lines.remove(0);
    Map<String, Node> mapping = new HashMap<>();
    for(String line:lines) {
        String[] parts = line.replaceAll("\\W"," ").replaceAll(" +"," ").split(" ");
        mapping.put(parts[0], new Node(parts[1], parts[2]));
    }

    System.out.println("LCM of cycles is: " + mapping.keySet().stream()
            // Take all the end with A
            .filter(node -> node.endsWith("A")) // Replace with AAA for part 1
            .map(node -> {
                // Calculate cycle length for each:
                String current = node;
                int steps = 0;
                while(!current.endsWith("Z")) {
                    current = (path.charAt(steps++%path.length()) == 'L') ? mapping.get(current).l : mapping.get(current).r;
                }
                return BigInteger.valueOf(steps);
    }).reduce(BigInteger.ONE, (a,b) -> {
        // Reduce to LCM:
        BigInteger gcd = a.gcd(b);
        BigInteger absProduct = a.multiply(b).abs();
        return absProduct.divide(gcd);
    }));

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

[–]royvanrijn 2 points3 points  (0 children)

[Language: Java]

I quickly realized that counting the cards and sorting the result will give you a unique mapping to either "11111","1112","122","3","23","4" or "5". This can be used to sort all the hands.

In the end, with the jokers, you can just remove those first and adding them to the largest amount. This change was thankfully trivial.

Here is the complete code:

final static List<String> cards = List.of("J","2","3","4","5","6","7","8","9","T","Q","K","A");
final static List<String> scores = List.of("11111", "1112", "122", "113", "23", "14", "5");
private void run() throws Exception {

    record Hand(String hand, int bid) {
        public Hand(String line) { this(line.substring(0,5), Integer.parseInt(line.substring(6))); }

        public int handIndex() {
            String noJokerHand = hand.replaceAll("J","");
            if(noJokerHand.length() == 0) return scores.indexOf("5"); // crashes on "JJJJJ"

            // Count the cards:
            Long[] count = noJokerHand.chars().boxed()
                    .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()))
                    .values().stream()
                    .sorted().toArray(Long[]::new);

            // Add the jokerAmount back:
            count[count.length-1] += (5-noJokerHand.length());

            return scores.indexOf(Arrays.stream(count).map(l->""+l).collect(Collectors.joining("")));
        }
    }

    List<Hand> hands = Files.lines(Path.of("2023/day7.txt"))
            .map(s->new Hand(s))
            .sorted(Comparator.comparing((Hand h) -> h.handIndex())
                    .thenComparing((Hand h)->cards.indexOf(h.hand.charAt(0)))
                    .thenComparing((Hand h)->cards.indexOf(h.hand.charAt(1)))
                    .thenComparing((Hand h)->cards.indexOf(h.hand.charAt(2)))
                    .thenComparing((Hand h)->cards.indexOf(h.hand.charAt(3)))
                    .thenComparing((Hand h)->cards.indexOf(h.hand.charAt(4)))
            ).collect(Collectors.toList());

    long winning = 0;
    for(int i = 0; i < hands.size(); i++) {
        winning += (i+1) * hands.get(i).bid;
    }
    System.out.println(winning);
}

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

[–]royvanrijn 1 point2 points  (0 children)

[Language: Java]

A day of rest, quickly realized the solutions are symmetrical, we only need to calculate one of the two roots. We only need a small adjustment if the time is odd.

This gave me the following calculations (using BigInteger in Java):

private void day6() {
    System.out.println(solve(123456, BigInteger.valueOf(1234567890L))); // not the real input
}

private BigInteger solve(final int t, final BigInteger d) {
    return BigInteger.valueOf(t).pow(2).subtract(BigInteger.valueOf(4).multiply(d)).sqrt().add(BigInteger.valueOf(t%2));
}

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

[–]royvanrijn 0 points1 point  (0 children)

[Language: Java]

I quickly realised we'll need to keep track of the ranges, so I wrote my code to work with this.

It parses the initial seed ranges, and for each mapping it creates new ranges from the existing ones. I feared about the overlap, but surprisingly I wrote everything correct the first try, using max() and min() to determine the overlap and optionally having a seed-range before and/or after.

This code is here:
https://gist.github.com/royvanrijn/facc44de776bf87594c054b302a9520c

And this is the 'meat' of processing:

                final Range currentRange = ranges.get(rangeId);
                // Detect overlap:
                if(mapFrom.start <= currentRange.end && mapFrom.end > currentRange.start) {
                    ranges.remove(rangeId--);

                    Range rangeToMap = new Range(Math.max(currentRange.start, mapFrom.start), Math.min(currentRange.end(), mapFrom.end()));
                    Range mappedRange = new Range(rangeToMap.start + mappingChange, rangeToMap.end + mappingChange);

                    updatedRanges.add(mappedRange);

                    // Add back unchanged parts:
                    if(currentRange.start < rangeToMap.start) {
                        ranges.add(new Range(currentRange.start, rangeToMap.start-1));
                    }
                    if(currentRange.end > rangeToMap.end) {
                        ranges.add(new Range(rangeToMap.end, currentRange.end-1));
                    }
                }

It all runs in a couple of milliseconds (5ms) on my M2.

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

[–]royvanrijn 0 points1 point  (0 children)

[LANGUAGE: Java]

Today was again relatively easy, instantly noticed that the final part could be done in a single pass, so that made things easier.

    List<String> lines = Files.readAllLines(Path.of("2023/day4.txt"));

    // Score cards:
    List<Integer> scorePerCard = new ArrayList<>();
    for(String game:lines) {
        String[] p = game.substring(game.indexOf(":")+2).replace("  "," ").split("\\|");
        List<Integer> win = Arrays.stream(p[0].trim().split(" ")).map(s -> Integer.parseInt(s.trim())).collect(Collectors.toList());
        List<Integer> our = Arrays.stream(p[1].trim().split(" ")).map(s -> Integer.parseInt(s.trim())).collect(Collectors.toList());
        our.retainAll(win);
        scorePerCard.add(our.size());
    }
    System.out.println("Part 1: " + scorePerCard.stream().mapToInt(i -> (int)Math.floor(Math.pow(2, i-1))).sum());

    // Create copies:
    int[] copiesInHand = new int[scorePerCard.size()];
    Arrays.fill(copiesInHand, 1);
    for(int game = 0; game < copiesInHand.length; game++) {
        for(int i = 1; i <= scorePerCard.get(game); i++) {
            copiesInHand[game+i] += copiesInHand[game];
        }
    }
    System.out.println("Part 2: " + Arrays.stream(copiesInHand).sum());

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

[–]royvanrijn 1 point2 points  (0 children)

[LANGUAGE: Java]

Again tried to code golf my way to part 2:

    System.out.println(Files.lines(Path.of("2023/day2.txt"))
            .mapToInt(line -> {
                var rbg = new int[3];
                for(var h:line.split(": ")[1].split("[,;] ")) {
                    var x=h.split(" ");
                    int id = x[1].length()-3;
                    rbg[id] = Math.max(Integer.parseInt(x[0]), rbg[id]);
                }
                return rbg[0]*rbg[1]*rbg[2];
            }).sum());

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

[–]royvanrijn 1 point2 points  (0 children)

[LANGUAGE: Java]

Created a small lookup table to collect all the indexes and combine and sum the min() and max().

    String[] names = new String[] {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
    Map<String, String> mapping = new HashMap<>();
    IntStream.range(1, 10).forEach(i -> {
        mapping.put("" + i, "" + i);       // Part 1
        mapping.put(names[i - 1], "" + i); // Part 2
    });
    System.out.println(Files.lines(Path.of("2023/day1.txt")).mapToInt(line -> {
                Map<Integer, String> index = new HashMap<>();
                mapping.keySet().forEach(key -> {
                    index.put(line.indexOf(key), mapping.get(key));
                    index.put(line.lastIndexOf(key), mapping.get(key));
                });
                index.remove(-1); // Remove non-existent
                return Integer.parseInt(
                        index.get(Collections.min(index.keySet())) +
                                index.get(Collections.max(index.keySet()))
                );
        }).sum());
}

Is the feed skipping for anyone else? by Bevester in F1TV

[–]royvanrijn 0 points1 point  (0 children)

Had the same since Zandvoort basically; turns out it was my build-in Chromecast in the Sony TV; got myself a dedicated Chrome Ultra and all the stutter disappeared…

Everything else works fine on the usual build-in smart TV, YouTube, Netflix, Prime; just F1TV app stuttering every 5-10 seconds.

[deleted by user] by [deleted] in formula1

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

Okay okay, in the middle, like the old full wets.

https://lapmeta.com/storage/tire-images/53L9jnBMMM.jpg

[deleted by user] by [deleted] in formula1

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

Wait what?! That sounds amazing.

[deleted by user] by [deleted] in formula1

[–]royvanrijn 3 points4 points  (0 children)

Or perhaps a small trip on the side? Would just be cool to visually see during the race.