AoC 2023 D2P2: Reusing List of Lists of Lists Extraction

December 2nd, 2023 by Keith Neufeld

In day 2 part 2, rather than verify whether each game / bag has no more than the specified number of cubes of each color, we’re to determine the number (maximum) cubes of each color that we see in across any pull from each game / bag.

my %max = ( red => 12, green => 13, blue => 14);

We no longer need to set the maximum permissible count.

my %max = ( red => 0, green => 0, blue => 0);

Instead, within each row of input, accumulate the maximum count of each color seen on any pull of this game.

Perl doesn’t require initializing hashes that will be used to accumulate information and it’s idiomatic not to; but with strict/warnings, my later comparisons will fail against uninitialized hash buckets; and it’s easier to initialize them than to add logic to check whether they’re already defined.

$max{$color} = $count if $count > $max{$color};

Then in the innermost loop when processing each color, set the new max for this game / bag to that count if the count exceeds the previously-seen maximum.

$sum += $max{red} * $max{green} * $max{blue};

Finally, we’re to sum the product of RGB counts from each line (rather than the game ID as in p1).

Read the rest of this entry »

AoC 2023 D2P1: List of Lists of Lists Extraction

December 2nd, 2023 by Keith Neufeld

Day 2′s problem 1 requires parsing this format:

Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green
Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue
Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red
Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red
Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green

to determine which rows have no more than 12 red, 13 green, and 14 blue cubes in the bag, then summing the game ID of those rows. In other words, interpreting lists of colors from lists of pulls from a list of games.

Read the rest of this entry »

AoC 2023 D1P2: Convert Words to Digits

December 1st, 2023 by Keith Neufeld

I can’t link to part two of today’s problem because you have to solve part 1 to unlock the second half of the web page; but I’m sure it’s been countlessly reposted by now and I’ll summarize it:

Oops, some of the digits that we want to add up have been written as English words instead of numerals. Recognize the words one, two, three, four, five, six, seven, eight, and nine as digits also. And we have new sample input:

two1nine
eightwothree
abcone2threexyz
xtwone3four
4nineeightseven2
zoneight234
7pqrstsixteen

Which yields 29 + 83 + 13 + 14 + 42 + 14 + 76 = 281.

Read the rest of this entry »

AoC 2023 D1P1: Extract Digits from Text

December 1st, 2023 by Keith Neufeld

As with most Advent of Code problems, today’s first problem has a lot of cute story and some ambiguity in the phrasing that needs to be teased out and disambiguated.

It works out to: Extract the first and last digits on each line of text, use them to construct a two-digit number, and sum those numbers. Unstated but visible in the example is that if a line has a single digit in it, you use that for both digits of that line’s contribution.

Read the rest of this entry »

Advent of Code 2023 Starts Friday

November 27th, 2023 by Keith Neufeld

My day job doesn’t (normally) involve programming; (as is obvious) I don’t have as much time these days for hobby electronics and programming as I used to; and I really miss it.

So I was delighted when Kip introduced me to Advent of Code a few years ago. It’s a programming contest that releases a new puzzle each midnight (US eastern time; 23:00 my time) on the night that becomes December 1 through the night that becomes December 25. You work the puzzles at your own pace in whatever programming language you want (a few years ago, I did one puzzle’s heavy lifting in software and evaluated the dozen remaining results by eye) and the site checks your answers for correctness and shows you stats about your ranking within the global participants and within personal leaderboards of which you’re a member.

The puzzles are cute word problems and come with examples of input, logic, and output. Each participant is given a randomly- or algorithmically-generated input file, therefore a different correct output from other participants. (The algorithmic and programming expertise of the AoC creator/maintainer is hard to overstate.) When you upload a correct output to the first part of the puzzle, you’re given the problem for the second part of the puzzle to run on the same input — which often as not causes a rewrite if you used inadvisable programming shortcuts in your solution to the first part.

As always, I’ll be doing this year’s puzzles in Perl. I’m reasonably fluent in it; and of the languages in which I’m reasonably fluent, Perl is very, very good at processing input in the kinds of formats used in these puzzles. (But so is _____ ! Yes, but I’m not fluent in _____ !)

And I’ll be posting them here, discussing both the algorithmic approach I take to the puzzle and the Perl code that accomplishes it.

You might find the puzzles interesting. You might find my algorithms interesting. You might want to learn more Perl (although I doubt it). You might want to trash-talk Perl (and I just won’t approve your comments). You might want to elevate my Perl programming by showing me more concise, more idiomatic, faster, or more elegant ways of writing the same code (and I’ll be thrilled).

See you Friday evening or Saturday morning, when I have time to post Friday’s code.

Voron 2.4 Heated Build Platform, Part 3A: Temperature Accuracy (As Built)

August 20th, 2023 by Keith Neufeld

After knowing that the Voron 2.4′s Z limit switch and Z probe produce repeatable results, we’re almost ready to begin calibrating the heated build platform for optimal first layers. But since the goal is to achieve the right temperature for different filaments (at the very least, radically different temperature for ABS vs PLA, and quite likely somewhat different from brand to brand and even color to color), I’d like to know that the printer is setting the surface of the build platform to the temperature I’ve asked it to.

One could — and I will — empirically test the best temperature setting for different filaments. But done without knowing how accurately the printer is achieving the temperature that has been set, the results will be unique to that printer. I’d like to tune my filament temperature settings to work reliably across all my printers (for a given build surface).

IR camera of Voron 2.4 heated build platform

Apparently this will require some compromise, as the steady-state temperature between the center and edge of the build platform varied by 6°C when the setpoint was 100°C, a considerable amount given that first layers are often printed with the platform 10°C hotter than remaining layers and this 10°C is believed to make a difference.

Let’s see how the platform temperature behaves with a Fysetc kit in factory configuration.

Read the rest of this entry »

Voron 2.4 Heated Build Platform, Part 2: Z Probe Repeatability

July 15th, 2023 by Keith Neufeld

I regard the next step in the foundation of consistent first-layer behavior as the repeatability of the Z probe.

The Z limit switch is used to set the height of the nozzle above the center of the build platform; but the Voron 2.4 has a separate Z stepper for each corner and uses the toolhead’s inductive Z probe to tram the gantry by reading the height above the platform at each corner of the printer and then adjusting the corners until the gantry is parallel to the build platform.

Voron 2.4 inductive probe

If the Z probe’s measurements are insufficiently repeatable, the tramming procedure may set the gantry out of parallel to the build platform, causing the nozzle-to-platform gap to vary (even on a perfectly flat platform, which I do not have) as the toolhead moves to different X-Y coordinates.

Klipper provides another macro to test the Z probe repeatability. Move the nozzle to a safe spot, call the macro, and it takes and reports several readings. It then moves the nozzle to the position where the probe was (according to the probe offsets in printer.cfg) — I don’t know why — so for repeated probe tests, move the toolhead back to the same spot before starting the next reading.

Read the rest of this entry »

Voron 2.4 Heated Build Platform, Part 1B: Z Limit Switch Repeatability — Using Your Tools Correctly

July 15th, 2023 by Keith Neufeld

Last week I started measuring the repeatability of my Voron 2.4′s Z limit switch and got very not-repeatable results.

Since the first layer’s ability to stick to the build platform relies on a repeatable height above the build platform which in turn relies on a repeatable measurement from the Z limit switch, this had to be corrected before proceeding — lack of repeatability here breaks everything the printer is trying to do! So I needed to find and correct the source of that deviation.

My first thought was to take apart the switch assembly and see whether anything had gone wrong between the plunger pin and the switch. But before I even got that far,

Voron 2.4 Z limit switch

I found all these filament droppings (oozed out of an idle hot nozzle — call them fwarf?) piled on and around the switch assembly. Although the only way I could imagine them impacting a reading like my previous trial would be if one had laid on top of the pin during a reading — and I’d been sitting there to see that none had — I figured I’d better clean them out and rerun the collection of calibration samples.

And while doing so, I found what appears to have been the actual problem:

Feeler gauges on Voron 2.4 build platform

When performing the first Z_ENDSTOP_CALIBRATION, when I got the nozzle closer to the platform than the thickness of my 0.10-mm feeler gauge, I swung the 0.02-mm feeler gauge out of its place in the holder and it delaminated and split in two. Uh, what????? Oh. Oh, it’s so thin that the 0.03-mm feeler gauge was stuck to the back of it and I swung both of them out together. I … uh … wonder how many times I’ve done that before. Randomly. On some of the measurements and not others.

Read the rest of this entry »

Voron 2.4 Heated Build Platform, Part 1A: Z Limit Switch Repeatability

June 27th, 2023 by Keith Neufeld

I have quite some difficulty with first layers on my Voron 2.4, so let’s take a foray into investigating the build platform and related components and configurations, shall we?

Voron 2.4 probing Z limit switch

My generation of Voron 2.4, configured as recommended at the time, finds mechanical position Z=0 (nozzle exactly touching build surface) by pushing the tip of the nozzle down onto a (heat-resistant) stainless-steel pin [the lonely white dot below the toolhead], triggering the Zmin limit switch, and then applying the recorded offset between the trigger position and the build surface.

This is brilliant in that it automatically compensates for different nozzle lengths and even compensates for nozzle thermal expansion, and the evil opposite of brilliant in that you have to make a new Klipper printer.cfg file for each different build surface and they tell you in the Klipper forums that you’re doing it wrong if you ask for a better way to maintain different offsets for different surfaces. And then the Voron team invents the Voron Tap, which is a better way but which I haven’t implemented yet on this printer because reasons.

Oh dear me, I seem to have meandered a bit. I think I was about to say that the first step of figuring out inconsistent first-layer behavior would be to check the repeatability of the Z limit switch. Yes, that was it.

Read the rest of this entry »

Voron 2.4 — First 3-mm Filament Prints

October 16th, 2022 by Keith Neufeld

test block printed in 3-mm filament

Nobody wants to talk about printing 3-mm filament on a Voron, but I have filament I want to use that was only available in 3 mm. So I ordered a bunch of vitamins and remixed the AfterBurner extruder and E3Dv6 hotend holder and here we are, making test prints with ancient MakerBot ABS before moving on to the new stuff.

3DBenchy printed on Voron 2.4 in 3-mm filament

Benchy can certainly use some tuning (at least a tad more cooling) but is reasonably respectable for sixty minutes of slowly pushing 3-mm filament through a 0.4-mm nozzle.