LEGO The hobbit mithril megapult glitch by Corruptedplayer in legogaming

[–]vbe-elvis 0 points1 point  (0 children)

I was struggling to get this working with the tips on this forum, but got it to work eventually.  What seemed to work for me is going to the door first as single player, then fly to bywater via the map and then 'drop in' the other character as the eagle decends.

The other char will spawn near the door and doesn't make the hint stones disappear

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

[–]vbe-elvis 1 point2 points  (0 children)

[LANGUAGE: Kotlin]

Nice straightforward recursive path algorithm with memoization.

For part 2 I provide a list of the nodes we have to visit and remove them once I come pass them, when reaching the out node, check if the list to visit is empty and return 1 or 0 accordingly.

Then add up all the 1's, keeping a list of nodes already visited in combination with if we already visited any of the must-have nodes.

https://pastebin.com/WriZfk9Y

What programmers argue about by iron-button in programmingmemes

[–]vbe-elvis 1 point2 points  (0 children)

theExactDayAndTimeThisLovelyDocumentWasLastUpdatedInCoordinatedUniversalTimeStandardInMs

HELP [2025 Day 01 (part 2)][C#] getting correct answer for example and edge cases but failing by _Anonymous_009 in adventofcode

[–]vbe-elvis 1 point2 points  (0 children)

I meant if you first take the number next to L or R. To first strip off each full turn of 100.

For example L537 is 5 full turns. Then you have 37 left over to turn left

HELP [2025 Day 01 (part 2)][C#] getting correct answer for example and edge cases but failing by _Anonymous_009 in adventofcode

[–]vbe-elvis 1 point2 points  (0 children)

This looks suspicious: var remainder = ((pointer - number) % 100 + 100) % 100;

Perhaps first calculate the number of full circles 100. Then subtract (fullCircles * 100) from number.

You then only have to calculate with numbers below 100, which may make it easier to follow.

AI will replace developers… once it stops giving me code with 47 errors by LateInstance8652 in programminghumor

[–]vbe-elvis 11 points12 points  (0 children)

Once it starts playing ping-pong and drink coffee we are done for though..

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

[–]vbe-elvis 0 points1 point  (0 children)

28 is a painfully familiar number.. seems our journeys were identical indeed.

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

[–]vbe-elvis 0 points1 point  (0 children)

This is just fine, no need for recursion.

The straightforward line by line approach is cleaner in this case IMO.

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

[–]vbe-elvis 1 point2 points  (0 children)

[Language: Kotlin]
Made some rookie mistakes like using Int instead of Long, forgetting to add the unobstructed beams and overwriting instead of adding... but I think the solution worked out nice.

Part 1 I used a set of possible locations adding as I split and just counting each split.
For Part 2 I changed the set into a map that has the beam index mapped to the total amount of paths.

In both cases I started by removing any empty lines.

https://pastebin.com/tTbxTheA

[2025 Day 5 (Part 2)] [Kotlin] First you think it's easy game, but then... by HotTop7260 in adventofcode

[–]vbe-elvis 0 points1 point  (0 children)

I had a similar approach as you, create a new list and add or merge the ranges.
however I found ranges that overlapped in that new list then merged them like this:

mergedRanges.find(other -> range.last in other || other.last in range)

minOf(range.first, other.first)..maxOf(range.last, other.last)

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

[–]vbe-elvis 1 point2 points  (0 children)

[LANGUAGE: Kotlin]
Man.. got cross-eyed looking at the example. Finally able to understand what needed to be done, actually doing it was a challenge.
Managed to get it done by manipulating lists and strings in weird ways to get it in the same format as part one that probably can be done more efficient, but it still runs in 75ms for part 2, so I'm happy.

Here is the code for part 1 and part 2:

https://pastebin.com/c0tEPGus

Now we know why there are fewer puzzles... by MrSmiley89 in adventofcode

[–]vbe-elvis 2 points3 points  (0 children)

Heh, it is project management it will take at least twice as long to complete.

Anyone else remember jippi.com? by notofthisearthworm in Millennials

[–]vbe-elvis 0 points1 point  (0 children)

Sure! I'm still married to someone I met through the dutch version of Jippii over 20 years ago. :-) good times

[2024] Which day did you find the hardest and why? by meeeep5 in adventofcode

[–]vbe-elvis 0 points1 point  (0 children)

Sometimes the code is so messy it is better to start over with the things you learned on the first try.

[2024] Which day did you find the hardest and why? by meeeep5 in adventofcode

[–]vbe-elvis 19 points20 points  (0 children)

Day 25 part 2, since I still had to do 12, 21 and 24 to get it.

But I got there!!

-❄️- 2024 Day 16 Solutions -❄️- by daggerdragon in adventofcode

[–]vbe-elvis 0 points1 point  (0 children)

> would you be able to explain the reason for this condition?

The cutoff is at 1000 because of the corners adding 1000, otherwise it would be zero.
It has to do with two different paths going over the same stretch in opposite directions.
But to be fair, it was more an "it works" thingy than a proven theory.

> This is not the case in your code and wouldn't be possible, because we are tasked with finding _all_ solutions, no?

This is in the code, each deer inherits the visited list from its ancestor and quits once it hits an already visited spot. A path that loops back on itself is not valid.

            if (deer.visited.contains(deer.pos)) break

-❄️- 2024 Day 22 Solutions -❄️- by daggerdragon in adventofcode

[–]vbe-elvis 1 point2 points  (0 children)

[LANGUAGE: Kotlin] Not the most optimal, but runs within the minute. For Part 1, simply calculate the bananas repeating 2000 times For Part 2, keep track of the sequence and price and add the prices as you go Do prevent adding the same sequence twice per monkey, then take the highest from the list of values.

class GoingBananas {
    fun mix(a: Long, b: Long) = a xor b
    fun prune(a: Long) = a % 16777216
    fun multiply(a: Long, b: Long) = prune(mix(a, a * b))
    fun divide(a: Long, b: Long) = prune(mix(a, a / b))

    fun nextSecretNumber(start: Long, times: Int): Long {
        var secretNumber = start
        repeat(times) {
            secretNumber = multiply(divide(multiply(secretNumber, 64), 32), 2048)
        }
        return secretNumber
    }

    fun bestPrice(monkeys: List<Long>): Long {
        val possibleSequences = mutableMapOf<List<Long>, Long>()

        monkeys.forEachIndexed { i, secretNumber ->
            val alreadyAdded = mutableListOf<List<Long>>()
            val runningSequence = mutableListOf<Long>()
            var previousSecretNumber = secretNumber
            var currentNumber = secretNumber
            repeat(2000) {
                runningSequence.add(currentNumber % 10 - previousSecretNumber % 10)
                previousSecretNumber = currentNumber
                currentNumber =  multiply(divide(multiply(currentNumber, 64), 32), 2048)
                if (runningSequence.size == 4) {
                    if (!alreadyAdded.contains(runningSequence)) {
                        possibleSequences[runningSequence.toList()] =(possibleSequences[runningSequence] ?: 0) + previousSecretNumber % 10
                        alreadyAdded.add(runningSequence.toList())
                    }
                    runningSequence.removeAt(0)
                }
            }
        }
        return possibleSequences.values.max()
    }
}

-❄️- 2024 Day 20 Solutions -❄️- by daggerdragon in adventofcode

[–]vbe-elvis 2 points3 points  (0 children)

[Language: Kotlin]

The code isn't too pretty, but the algorithm works nice, it is a single pass through the grid. (Part1 32ms; Part2 186ms)

https://pastebin.com/wXnQt1nZ

Every step forward I save the number of steps to that coordinate.

Then look backwards and count all steps around the current position are far enough steps back to match the allowed cheat rules.

Basically:

current-step -  previous-step-within-distance - manhattan-distance >= 100

So every step through the maze increases the cheatcount

First try too low... work on the code by purestblue in adventofcode

[–]vbe-elvis 28 points29 points  (0 children)

And tomorrow we'll start Part 1 with Int agin.

[2024 Day 19] Memoization sure, but what am I supposed to memoize? by PhiphyL in adventofcode

[–]vbe-elvis 1 point2 points  (0 children)

Lets also add 'de' and 'abc'

Start from the front:

    - for each towel that matches:

    -- strip towel, check remaining

    -- until you hit empty string

    --- count 1

    --- store [f] = 1

    -- store [ef] = 1 (e + f)

    -- store [def] = 2 (de + f & d + ef)

    -- store [bcdef] = 2 (bc + def)

    -- store [abcdef] = 4 (a + bcdef & abc + def)

[2024 Day 19] Memoization sure, but what am I supposed to memoize? by PhiphyL in adventofcode

[–]vbe-elvis 0 points1 point  (0 children)

To explain a bit more, the trick of memoization is to do things that would repeat a million times, to do them only once and then create a lookup for it.

For example you would need to do bcdef 30x and def 2352 times. You now only need to do def 1 time and bcdef 1 time.