#ThisWeeksFiddler, 20250620

This week the #puzzle is: How Greedily Can You Mow the Lawn? #geometry #area #volume #GreedyAlgorithm (Link at the bottom.)

You’re mowing a circular lawn with a radius of 1 unit. You can mow in straight strips that are 1 unit wide.
The fewest number of passes you would need to mow the entire lawn is two, as shown below. In one pass (shown in blue) you can mow half the circle, and in the second pass (shown in red) you can mow the other half of the circle.
However, instead of minimizing the number of passes, you greedily choose how to orient each pass so it cuts as much of the unmowed grass as possible. A pass doesn’t have to go through the center of the circle and can be in any direction, but must be straight and cannot bend.
With this “greedy” approach, how many passes will it take for you to mow the entire lawn?

And for extra credit:

Instead of mowing a two-dimensional lawn, now you’re boring cylinders through a three-dimensional unit sphere. Each cylinder has a diameter of 1 (and a radius of 1/2).
Once again, you are greedily choosing the orientation of your boreholes so that they carve out as much of the remaining sphere as possible with each pass.
With this “greedy” approach, how many passes will it take for you to pulverize the entire sphere?

Highlight to reveal (possibly incorrect) solution:

Desmos 1

And for extra credit:

Desmos 2 Researchgate

***

How Greedily Can You Mow the Lawn?

#ThisWeeksFiddler, 20250613

This week the #puzzle is: Can You Race Against Zeno? #integration #summation #speed #distance #time (Link at the bottom.)

I’ve been experimenting with different strategies in 5000-meter races (known as “5K”s). If I run the distance at a steady pace, I’ll finish in precisely 23 minutes.
However, I tend to find a burst of energy as I near the finish line. Therefore, I’ve tried intentionally running what’s called a “negative split,” meaning I run the second half of the race faster than the first half—as opposed to a “positive split,” where I run a slower second half.
I want to take the concept of a negative split to the next level. My plan for an upcoming race—the “Zeno Paradox 5K”—is to start out with a 24-minute pace (i.e., running at a speed such that if I ran the whole distance at that speed, I’d finish in 24 minutes). Halfway through the race by distance (i.e., after 2500 meters), I’ll increase my speed (i.e., distance per unit time) by 10 percent. Three-quarters of the way through, I’ll increase by another 10 percent. If you’re keeping track, that’s now 21 percent faster than my speed at the start.
I continue in this fashion, upping my speed by 10% every time I’m half the distance to the finish line from my previous change in pace. (Let’s put aside the fact that my speed will have surpassed the speed of light somewhere near the finish line.)
Using this strategy, how long will it take me to complete the 5K? I’m really hoping it’s faster than my steady 23-minute pace, even though I start out slower (at a 24-minute pace).

And for extra credit:

I still want to run a negative split, but upping my tempo in discrete steps is such a slog. Instead, my next plan is to continuously increase my pace in the following way:
At the beginning of the race, I’ll start with a 24-minute pace. Then, wherever I am on the race course, I’m always running at a 10 percent faster speed than I was when I was twice as far from the finish line. Also, my speed should always be increasing in a continuous and smooth fashion.
(On the off chance you find more than one speed as a function of distance that satisfies all these conditions, I’m interested in seeing how. If only one such function exists, can you prove it? Regardless, my expectation is for the function to be as straightforward as possible.)
Using this strategy, how long will it take me to complete the 5K? Once again, I’m hoping it’s faster than my steady 23-minute pace, even though I started out slower.

Highlight to reveal (possibly incorrect) solution:

Desmos 1 – just to be confusing, the definition of tZeno1 here is slightly different.

And for extra credit:

Desmos 2

***

Can You Race Against Zeno?

#ThisWeeksFiddler, 20250606

This week the #puzzle is: Can You Squeeze the Bubbles? #circles #geometry #area #minimize (Link at the bottom.)

Draw a unit circle (i.e., a circle with radius 1). Then draw another unit circle whose center is not inside the first one. Then draw a third unit circle whose center is not inside either of the first two.
Keep doing this until you have drawn a total of seven circles. What is the minimum possible area of the region that’s inside at least one of the circles?

And for extra credit:

Instead of seven unit circles, now suppose you draw N of them. As before, the center of each new circle you draw cannot be inside any of the previous circles.
As N gets very, very large, what is the minimum possible area of the region inside at least one circle in terms of N?

But first. Last week I made a booboo. At some point I began trusting my assumption about the probabilities so much, that I didn’t figure out, why my monte carlo results didn’t line up. This again lead to me saying 2 was the correct answer to the extra credit, when in fact… well, as I said, my monte carlo said something else. Something better. This is a detail from my heat map 5.

The lowest values occur, not in the corner (4), but towards the middle of the side (3). And the ratio is something like 2.7. Earlier heat maps actually showed this more clearly. Here’s the 3d image based on my monte carlo data, and for comparison the other 3d image again:

The important feature is that there’s a dip along the lower edge. Corner low, middle of side lower. Sigh. Anyway. Back to the puzzles from this week.

Highlight to reveal (possibly incorrect) solution:

Desmos live Two Circles Calculator Desmos image

And for extra credit:

Desmos image

***

Can You Squeeze the Bubbles?

Hugo-noveller

Og vi skal selvfølgelig også betragte Hugo-finalist-novellerne fra i år.

ISFDBISFDBMigKarakter
Five Views of the Planet TartarusRachael K. Jones5 x synet af planeten Tartarus👽👽☠️
MarginaliaMary Robinette KowalKant-rine👽👽👽
Stitched to Skin Like Family IsNghi VoFamilien er syet til huden👽👽👽
Three Faces of a BeheadingArkady MartineTriple halshug👽👽👽
We Will Teach You How to Read | We Will Teach You How to ReadCaroline M. YoachimVVii vviill llæærree ddiigg aatt llææssee👽👽☠️
Why Don’t We Just Kill the Kid in the Omelas HoleIsabel J. KimAltså, ungen i Omelas-hullet👽👽☠️

Allerede noget bedre at vælge mellem. “Three Faces of a Beheading” blev i mit hoved et godt stykke tid, så det er min favorit.

Triple halshug

Anmeldelse af “Three Faces of a Beheading” (gratis), af Arkady Martine. Novelle. 2024. Hugo-finalist.

Skitse: En mulighed for et computerspil er, at en enkelt spiller kan have et stort publikum. Det kan derfor også have stor betydning, når en spiller gør noget usædvanligt. I et autoritært samfund gør noget forbudt, noget farligt.

Er det science fiction? Jeps.

Temaer: Det omtalte spil er baseret på noget historisk. Der var en gang en kejser og et oprør. Noget historisk kan fortælles på forskellige måder. En historikers forsøg på at få mening i, hvad der egentlig skete, kan føre et nyt sted hen. Hvad var folks motiver? Hvem havde alliancer? Hvad er fortællingen her? Hvis der er en.

Hvis man ønsker at sige noget om sin samtid, så kan man også vinkle noget historisk på en passende måde.

Min fornemmelse er, at forfatteren er intelligent og veluddannet (fx er der fodnoter til novellen) og har valgt en indviklet metode. Bl.a. er der pudsige skift mellem 1. og 2. person. Jeg læste novellen 2 gange, for at være nogenlunde sikker på det hele.

Er det godt? Ja. Ja, det er det egentlig. 👽👽👽

Familien er syet til huden

Anmeldelse af “Stitched to Skin like Family Is” (gratis), af #NghiVo. Novelle. 2024. Hugo-finalist.

Skitse: Sommeren ’31 kan det godt være lidt indviklet at være kinesisk i Illinois, USA. Således også for hende her, der i øvrigt er rigtig god til at lappe tøj og sy det om. (I får mig ikke til at skrive omf*randre! Jeg gør det ikke!) Hun kan også få noget ud af at lytte til tøj. Og så leder hun efter sin bror.

Er det science fiction? Aldeles ikke. Fantasy.

Temaer: Hun kan noget med tøj og sko, specielt hvis hun har haft fat i det før.

Så mærker hun også racisme.

Er det godt? Hm. Det var jo et indviklet spørgsmål. Jeg gættede ikke det hele fra første linje. Jeg har sympati med hovedpersonen. Tjo. 👽👽👽

Kant-rine

Anmeldelse af “Marginalia”  (gratis), af #MaryRobinetteKowal. Novelle. 2024. Hugo-finalist.

Skitse: Her til lands er snegle kæmpestore, og man kan sagtens dø af at møde dem eller deres fodspor af syre. Margery skal på en eller anden måde håndtere, at hendes lillebror helt vildt gerne vil se sneglen, og at deres syge mor helst ikke må være alene.

Er det science fiction? Nej. Fantasy.

Temaer: Der går klassekamp i det her. Baronen mener, at han gør det så godt. Men passer han faktisk godt på sine tidligere ansatte? Ved han, hvad de har brug for? Og forstår han godt, at dem “under ham” kan være klogere og mere intelligente?

Er det godt? Ja. Der blev dog ved med at være underlige ting i teksten. Fx at Margery tilsyneladende brygger øl og vasker tøj samtidig. Men alligevel. 👽👽👽

#ThisWeeksFiddler, 20250530

This week the #puzzle is: Can You Weave the Web? #geometry #trigonometry #probability (Link at the bottom.)

A spider weaves a web within a unit square (i.e., a square with side length 1) in the following haphazard manner:
First, the spider picks two points at random inside the square. In particular, it picks the points “uniformly,” meaning any point is equally likely to be picked as any other point.
Next, the spider connects the two points with a strand of silk and extends the strand to two sides of the square. For example, here is a web made of 10 silk strands that were picked as described:
Within the unit square, which point (or points) is most likely to be on a new strand of silk, whose two defining points have not yet been picked?
(While the probability that any specific point winds up being precisely on the new strand is zero, some points and regions are nevertheless more likely to be on the strand than others.)

And for extra credit:

As we just acknowledged, there exists a point (or points) in the unit square that is more likely than any others to be on the randomly selected silk strand.
At the same time, there exists a point (or points) in the unit square that is less likely than any others to be on the random strand.
How much more likely is a most likely point to be on the strand than a least likely point? More specifically, suppose the maximum of the probability density for being on the strand is pmax and the minimum probability density is pmin. What is the ratio pmax/pmin?

Highlight to reveal (possibly incorrect) solution:

Program 1 Program 2 Desmos Heat map 1, 2, 3, 4, 5, 6. 3d image.

***

Can You Weave the Web?

#ThisWeeksFiddler, 20250523

This week the #puzzle is: How Long Is the River? #probability (Link at the bottom.)

… a phenomenon known as a “river”, where spaces between words diagonally align from one line of text to the next.
Before getting to rivers, let’s figure out where spaces are likely to appear in the (fictional) Fiddlish language, which includes only three- and four-letter words. These words are separated by spaces, but there is no other punctuation.
Suppose a line of Fiddlish text is generated such that each next word has a 50 percent chance of being three letters and a 50 percent chance of being four letters.
Suppose a line has many, many, many words. What is the probability that any given character deep into the line is a space?

And for extra credit:

Fiddlish is written using a monospace font, meaning each character (including spaces) takes up the same amount of horizontal space. As before, lines of text are very, very long, and each next word has a 50 percent chance of being three letters and a 50 percent chance of being four letters. Each line begins with a new word (i.e., words at the end of a line are not hyphenated into the next line).
Suppose the 12th character of a specific line of text is a space. You want to know how long the river down and to the right from this space will be. For example, suppose the 13th character on the next line and the 14th character on the line after that are both spaces, but the 15th character on the very next line is not a space. In this case, the river would have a length of 3. (By this definition, the length of the river is always at least 1.)
On average, how long do you expect the resulting river from the given space (again, the 12th character in its line) to be?

Highlight to reveal (possibly incorrect) solution:

Program 1

And for extra credit:

Program 2

***

How Long Is the River?

Develop some Easter, will ya!

Just like I participate in a couple of Christmas events (one for math, one for code), this year I participated in an #Easter event (called easters.dev), primarily for #code. And as a reward for completing the #challenge I got these 3 happy eggs:

It took some time, but I’ve essentially solved all 3 x 2 puzzles without outside help. There wasn’t a helpful forum, and I didn’t just want to publish my code and ask for a review. (A lot of places on the leaderboard haven’t been taken yet.)

These are some of my experiences.

On Friday and Saturday, within a reasonable time I got a program solving 1st test case, 1st actual case and 2nd test case and then got stuck. Trying to figure out where the error is is hard!

Sunday I just ran through!

 10101
1.G...
0..O..
1.O...
0G...O
1...G.

Above are the test data for Sunday.

The numbers on top and on the left describe the columns and rows. Like, the 1st 1 says, there will be 1 example of (item) in this column. Part of the puzzle is to place items, so that all the numbers are correct. I’ve seen a lot of games do something similar, like Picross. So I basically tried to solve it like that. I copied the map into a spreadsheet, so that the numbers could automatically be calculated and compared to expectations, and then I solved it by hand.

Some cells are very easy to fill. A number is 0? Go across and mark all the undecided cells as empty. Some you have to work a little harder for.

***

Next I came back to Saturday. I will spare you the debugging details.

123

456

123
789

Above we have some of the test data. This says, if the program (3rd block of digits) contains the target (1st block of numbers), substitute in the replacement (2nd block of numbers). So, in this simple case, 123 would be replaced with 456 in the program.

It’s much more complicated than that, and a lot of stuff has to be checked before a replacement goes through, and the replacement itself might also be complicated.

In writing my code, some of it was: Will there be a replacement? And then a handful of cases, where the answer was no. What I learned from this puzzle was: Create test data for each of these cases.

***

Finally I came back to Friday. It didn’t seem like I could transfer my new coding practice to this puzzle.

In this puzzle strings are translated into other strings. Like, I have to translate “cuzb” into “awa”. There are rules for which translations are possible and how much they cost, and the goal is to find the lowest accumulated cost.

Again, after a lot of tedious debugging, I was halfway there. I had found a case, where my handmade translation was cheaper than the one my program found. But I didn’t know the reason yet.

By the way, creating a handmade translation involved analyzing the rules. The rules were represented by a map, and it was fun to play around with the map and see, that the structure shown was actually something like 8 structures smooshed together, so that they just looked like 1.

So. I fiddled around with my case. At some point I realized, that my handmade translation was much better at handling the final few characters in the string. Fiddle, flail, fiddle. And suddenly I was staring at 5 lines of code, that seemed wrong.

The task is to translate “weeds” (“cuzb”) into a nice pattern of “plants” (“awa”). (Yes, that’s a nice pattern.) I handle this recursively. Given that I want to go from “cuzb” to “awa”, and with a choice of beginning with 1 of 3 different actions, let’s just try all 3!

  • I can translate “cuzb” into “acuzb” (as a middle step) by introducing a new plant “a” + translating “cuzb” into “wa”.
  • I might be able to transform “c” into “a” + translating “uzb” into “wa”.
  • Or I can get rid of “c” + try to translate “uzb” into “awa”.

And then I just repeat for these shorter strings. When I know enough, I can choose the cheapest. Recursion, baby. (Actually fastest.)

So now for my 5 lines of weird code.

If I have 0 weeds and 0 pattern left, I am done. Fine.

If I have some weeds and 0 pattern left, well, my first thought was, that I would be stuck, ending in an impossible situation. But I suddenly realized, that was false. Of course I could handle this situation, by getting rid of the rest of the weeds.

And suddenly my program ran correctly!

***

That was fun. And apparently I have a position on the leaderboard as #3 and can’t be dislodged.

***

Link: easters.dev.