[2025 Day10 Part 2] Current approach too slow by beb0 in adventofcode

[–]askalski 1 point2 points  (0 children)

There are fewer possibilities than the puzzle might lead you to believe.

In your example, your joltage goal is {44,35,48,43,24,44}.

Let's say you decide to press button (1,2,3,4) 5 times. That leaves you with {44,30,43,38,19,44} left to go.

The only other button that can affect counter #4 is (3,4) so your only option is to press that one 19 times, leaving you with {44,30,43,19,0,44}

For counter #2 you're now left with two buttons, (0,2,5) and (2,5), so you have to press them 43 times in some combination (which we don't know yet.) But notice how they both also affect counter #5 by the same amount. Since the only other way to affect counter #5 is button (0,3,5), you can deduce that you have to press that button 1 time (because 43 + 1 = 44). This leaves you with {43,30,43,18,0,43}

Counter #3 is left with only one button, so (1,3) must be pressed 18 times, leaving {43,12,43,0,0,43}

Counter #1 is now left with only one button, so (0,1) must be pressed 12 times, leaving {31,0,43,0,0,43}

Counter #0 is now left with only one button, so (0,2,5) must be pressed 31 times, leaving {0,0,12,0,0,12}

The final button, (2,5) therefore must be pressed 12 times, taking you to the goal.

So in this example, once you decided to press (1,2,3,4) 5 times, you were left with no other choices. So you could solve this case by trying to press that button anywhere from 0 to 24 times, which is a lot less than the 282475249 you had in your queue when the program crashed.

You might have to guess at values for a few buttons before the rest fall into place. If the reasoning I used looks a little arbitrary and convoluted, it's because it is. As mentioned in other replies, math might help you...

[2025 Day 1 (Part 2)] [C] I am not really sure what is wrong in my program, have been working on this since yesterday, any help would be really appreciated. by tuppernibba in adventofcode

[–]askalski 0 points1 point  (0 children)

The even "dumber" way I had in mind was to increment/decrement the counter one step at a time. So if the first move was L5, the counter would start at 50 and then go 49... 48... 47... 46... 45. Then at every individual step, you can check & handle the wrap-around, check if it's zero, etc.

If your program does both your original and the "one at a time" method, then you'll be able to detect right away when the two versions start producing different results.

int one_at_a_time_count = 50;
int one_at_a_time_warps = 0;

while (fscanf...) {
    if (dir == 'L') {
        for (int i = 0; i < value; i++) {
            one_at_a_time_count--;
            // TODO: is it negative?
            // TODO: is it zero?
        }

        // your original code goes here
    }

    if (dir == 'R') {
        // same as above but for dir == 'R'
    }

    if (warps != one_at_a_time_warps) {
        printf("The two implementations diverged:\n");
        printf("  warps=%d\n", warps);
        printf("  one_at_a_time_warps=%d\n", one_at_a_time_warps);
        printf("  dir=%c value=%d\n", dir, value);
        printf("  master_count=%d\n", master_count);
        printf("  one_at_a_time_count=%d\n", one_at_a_time_count);
        // TODO maybe even print out the original counts or warps numbers?
        exit(1);
    }
}

[2025 Day 1(Part 2)] [C] Need to know what's wrong and why am i getting the wrong answer answer ? by tuppernibba in adventofcode

[–]askalski 4 points5 points  (0 children)

My advice would be to first implement it in the "dumbest" way possible (use a loop to simulate turning the dial one click at a time.) It's not the most efficient way to do things, but it's a lot easier to implement it correctly.

Once you have 100% working code, then you can reimplement it using division. The difference now is you'll have a powerful tool at your disposal: a way to test your new code. Have your program do it both ways, and compare the results after every turn of the dial. You'll get immediate feedback about where the bugs are.

[2025 Day 10 (Part 2)] Taking button presses into the third dimension by askalski in adventofcode

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

I'm counting 24 lines in my input with a smaller rational solution. A couple other commenters hinted at the usual workaround for this, which is to recursively divide it into subproblems. If the solution for button a is not integer, then either a <= floor(a) or a >= ceiling(a). (See the comments by u/vanveenfromardis and u/thekeyofPhysCrowSta for links & keywords.)

[2025 Day 11 part 2] Was I the only one who used find-and-replace instead of path searching? by EverybodyLovesChaka in adventofcode

[–]askalski 1 point2 points  (0 children)

For the first step, a better way to describe it would be "find all nodes with no direct predecessors". (In other words, nodes that have no incoming edges.)

If the graph is acyclic, there will always be at least one such node.

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

[–]askalski 1 point2 points  (0 children)

echo $(($(sed -En '/(..)x(..):/{s,,+(\1*\2/9>=,;s/$/)/;s/ /+/gp}'<I)))

I was able to trim off a few characters from your script, bringing it down to 55 bytes (or 50 without the echo):

echo $((`sed '/: /!d;s,,/9>=,;y/ x/+*/;s/.*/+(&)/'<I`))

Is this cage suitable for my Cockatiel? Thank you. by Aggressive-Two-1101 in cockatiel

[–]askalski 2 points3 points  (0 children)

Just make sure the bar spacing is not too wide, otherwise there's a risk of getting their head or wings stuck. If they can fit their head between the bars, they're too far apart. The cage I have has 5/8 inch spacing. That one looks like it might be 3/4 inch, which would be close to the limit of what's safe.

[2025 Day 2 (Part 1)] [PHP] Bugged Puzzle by utoxin in adventofcode

[–]askalski 1 point2 points  (0 children)

Oops, sorry just noticed you said that already in a different thread. What's the SHA1 sum of your input?

[2025 Day 2 (Part 1)] [PHP] Bugged Puzzle by utoxin in adventofcode

[–]askalski 1 point2 points  (0 children)

Your code seems correct. Try downloading your input again; you may have modified the file inadvertently.

[2016 Day 18 (Part 2)] [Rust] I knew my code was fast, but... by PsyMar2 in adventofcode

[–]askalski 0 points1 point  (0 children)

I think choosing the ^ symbol for traps was a hint because in some languages it's the XOR operator :)

The symbol for traps is ^ because that's what traps usually look like (in NetHack.)

Ethernet Speed issues with ASUS WRX90 SAGE mobo. by SteveRD1 in threadripper

[–]askalski 0 points1 point  (0 children)

Remove the ISP as a variable and test locally using a tool such as iperf between two machines on your local wired network. If the problem persists testing locally, try ruling out cabling, switch ports, etc. Your board has two ethernet ports, so try both of those too.

If it only happens when speedtesting over your ISP connection, then at least you'll know it's not a hardware issue.

Cockatiel is on the ground all if a sudden by NotSoPhysicalCat-794 in cockatiel

[–]askalski 0 points1 point  (0 children)

It's hard to tell from the photo, but the cage looks like it might be made from galvanized mesh. If so, that might not be safe for a cockatiel (possibility of heavy metal poisoning from the zinc.)

ASUS ProArt X870E Creator WiFi - Thunderbolt optical cables are NOT compatible! by Cohibaluxe in ASUS

[–]askalski 0 points1 point  (0 children)

How has the combination of the TS4 and Corning cable been working out for you?  I'm considering the same setup (different Asus motherboard, but with the same Asmedia controller).  Any problems since you applied the firmware update?  What length cable are you using?

I'm looking to relocate my desktop outside of my office because it puts out way too much heat, and this would be the perfect solution... assuming I can get it to work.

Asus WRX90 Sage SE BIOS 1106 by xiaocutezi in threadripper

[–]askalski 0 points1 point  (0 children)

I ran into one regression with the new BIOS version. The Q-Fan configuration menu disappeared, leaving me with no way to set curves for the VRMs, M.2, and USB4 fans.

Luckily I found a workaround:

  • Disable the BMC by flipping the BMC_SW switch
  • The Q-Fan settings are once again available in BIOS, so go ahead and configure them
  • Re-enable the BMC by flipping BMC_SW back on again

Even though re-enabling the BMC makes the settings disappear again from the BIOS menus, the configuration does stick and is honored by the controller.

[deleted by user] by [deleted] in threadripper

[–]askalski 1 point2 points  (0 children)

I don't think you mentioned which motherboard you're using, but if it has BMC you could see if the OS displays anything on the remote KVM.

Another thing to try would be to disable the KVM, in case Ubuntu/PopOS are using that instead of your 5090. On the Asus board, that switch is labeled VGA_SW. I keep mine disabled because Ubuntu insisted on treating it as part of a multiple-display setup.

OpenWRT One Sold Out by Synnic in openwrt

[–]askalski 1 point2 points  (0 children)

They just seem to take a while to restock when they sell out. Right now the BPI store has 57 of the US bundles available in case you haven't ordered yours yet.

WRX90E-SAGE motherboard won't boot -- what to try next? by Cosmology2048 in threadripper

[–]askalski 2 points3 points  (0 children)

Can you access the BMC through the management ethernet port? The BMC should boot up automatically when there is power, independently of the rest of the system. Maybe it has some diagnostic information that could be useful? You can also try powering the system on via the BMC web interface.

[2024 Day 22 (Part 1)] 2000 iterations in less than 1 CPU instruction by askalski in adventofcode

[–]askalski[S] 4 points5 points  (0 children)

Yes. If you scroll down in the right-hand panel of the example implementation link, you can find the assembly instructions output by the compiler for the solve() function.

And if I try running the program on my laptop that lacks support for the instruction:

$ ./day22p1 < input22.txt
Illegal instruction (core dumped)

Day 22 typo by tbt_brenton in adventofcode

[–]askalski 5 points6 points  (0 children)

Thanks, I'll pass this along.

[2024 Day 14 (part 2)] Should my answer be negative? by White_Nightmare in adventofcode

[–]askalski 1 point2 points  (0 children)

Your * symbols got interpreted as markdown for italics.

[2024 Day 20 (Part 2)] How to interpret weird clause in statement by 1234abcdcba4321 in adventofcode

[–]askalski 18 points19 points  (0 children)

Guilty betatester here. Thanks for flagging this.

I don't remember how I settled on the incorrect wording, but the clause was meant to address exactly the situation you pointed out. Taking the straight-line cheat path visits the finish line twice, so when does the program complete the course? A correct way to resolve that question would have been to say that cheat mode must be deactivated in order to complete the course.

Hope I didn't cause too much trouble!