#ThisWeeksFiddler, 20261030

This week the #puzzle is: Seeking Alpha #counting #average #probabilities

In the figure below, four points are arranged in a square. The top two points can each be labeled with one of eight letters: A, B, C, D, E, F, G, and H. The bottom two points can each be labeled with one of three three letters: J, K, and L. (Hence the numbers “8” and “3” in the figure.)
You are labeling exactly two of the points with letters. The other two points will remain blank.
Once you’ve labeled two points, you must choose one of the colored connectors (yellow, red, green, or blue) between the two points you labeled—note carefully where each color connector is in the diagram. But there are some more rules:
– If the two letters are the same, you cannot use a yellow connector.
– You can only use the blue connector when the bottom points have the same letter.
Finally, two diagrams are equivalent if they are reflections of each other. For example, the following two diagrams are equivalent:
All told, how many distinct (non-equivalent) diagrams can you make?

And for extra credit:

Next, it’s time for a little game. Let’s continue with the list of distinct diagrams you just found for this week’s Fiddler, being sure to choose exactly one representative from each pair of reflected diagrams. And further suppose every diagram in your list actually contains four letters: In addition to the two “visible” letters in the diagram, the remaining two points each have a “secret” letter—8 possible letters (A through H) for a point on top and 3 possible letters (J through L) for a point on the bottom—that are fixed for a given diagram. The top and bottom letters are chosen with replacement, so that a letter can occur more than once.
So here’s the game: In each round, you are randomly generating a new diagram. This time, the top two points are each randomly labeled with one of nine letters: A, B, C, D, E, F, G, H, and I. The bottom two points are each randomly labeled with one of four letters: J, K, L, and M. Letters are chosen independently and with replacement. Once these letters are assigned, you randomly pick two points whose letters are “secret.”
Between the remaining two “visible” letters, you randomly pick from among the four connectors between them shown in the diagram below:
While there are indeed four connectors between any two points, there are five connector types. Here are the point values associated with each type:
– A gray connector is worth 0 points
– A yellow connector is worth 1 point.
– A red connector is worth √2 points.
– A green connector is worth √3 points.
– A blue connector is worth √6 points if it connects identical letters—otherwise, it’s worth 0 points.
Now, you earn points when your randomly generated diagram perfectly matches one of the distinct diagrams from your list, including: the four letters, which letters are visible, their orientation (no reflections allowed this time!), and the color of the connector between the visible letters. If there is indeed a diagram that’s a perfect match, you get the number of points corresponding to its connector. Otherwise, you get no points.
On average, how many rounds of this game can you expect to play for each point that you earn?

Seeking Alpha

Solution, possibly incorrect:

Program

The only method I can think of is to count all the options. Before I start, I label the points.

  • Top left: a
  • Top right: b
  • Bottom left: c
  • Bottom right: d

I also label the letters.

  • A letter is the 1st letter, if the label for the point beneath the letter comes before the letter for the other point with a letter.
  • 1st letter: l1
  • 2nd letter: l2

Now let’s start counting.

  • Points with letters: a, b
    • l1 = l2, connector is G
      • 8 options
      • (8 options for l1, 1 option for l2, 1 option for connector)
    • l1 ≠ l2, connector is Y or G
      • 8 * 7 * 2 / 2 = 56 options
      • (8 options for l1, 7 options for l2, 2 options for connector, remove equivalents (AB is equivalent to BA)
  • Points with letters: a, c
    • l1 ≠ l2, connector is Y or R
      • 8 * 3 * 2 = 48 options
  • Points with letters: a, d
    • l1 ≠ l2, connector is Y or R
      • 8 * 3 * 2 = 48 options
  • Points with letters: b, c (equivalent to a, d)
  • Points with letters: b, d (equivalent to a, c)
  • Points with letters: c, d
    • l1 = l2, connector is G or B
      • 3 * 2 = 6 options
    • l1 ≠ l2, connector is Y or G
      • 3 * 2 * 2 / 2 = 6 options

In all, there are 8 + 56 + 48 + 48 + 6 + 6 = 172 options.

Method 2, I build a program to create all the options and count them. Same result.

And for extra credit:

Let me see, if I can count my way out of this one too.

This time the letters are simply la, lb, lc and ld. The 2 points chosen/visible are p1 and p2. The connector chosen is C.

A diagram is completely described by (la, lb, lc, ld, p1, p2, C).

When does a diagram fit perfectly with 1 from my list? The 1st yellow p is the probability the letters might actually hit something from my list of diagrams. The next is that the hidden letters fit with what I chose. The next is that the connector fits. And then I multiply those 3.

How often does the correct connector occur? The 1st p is the probability from above transferred down here. I multiply the probability with the average point value from the connectors. Then I combine into the 6 cases of point choices. And then I take the average. Finally I calculate the reverse.

Okay, let me see. The average of all of this is 0.009718. This reversed is 102.9005. This means, for every 102.9005 games, I get 1 point. So I guess that’s my answer. I have to play 102.9005 rounds of this game to get 1 point.

Method 2, add monte carlo to my program. Build a list of diagrams. Then create random diagrams and check whether they are in the list.

Number of loops.... 5 * :      3162523
Target deviation........: 0.0001000
Deviation so far........:
................result 1: 0.0000725
======================================
Final result E, 1.......: 0.0112332
+/- 0.0000725

Result F 1: average number of games / point, 89.021472

So this gives me about 89, and method 1 gave me about 103. There’s enough of a difference, that I must have made a mistake somewhere.

Method 3. Hm. Instead of generating random diagrams, let me count all of them. WLOG, let’s assume all the diagrams in the good list are the ac and ad reflections.

  • abCAAXY
    • This is a diagram, where the visible points are a and b, the connector is C, the visible letters are A and A (a letter from the A-I group) and the hidden letters are X and Y (letters from the group(s), the hidden letters belong to)
    • This can be done with 4 different connectors, 9 different letters A, 4 different letters X and 4 different letters Y.
    • 4 * 9 * 4 * 4 = 576 options.
    • Of these, 8 are in the list of good diagrams.
  • abCABXY
    • The visible letters are A and B, 2 of the letters from the A-I group.
    • 4 * 9 * 8 * 4 * 4 = 4608 options.
    • Of these, 56 are in the list of good diagrams.
  • acCAJXY
    • The visible letters are A and J, a letter from the A-I group and a letter from the J-M group.
    • 4 * 9 * 4 * 9 * 4 = 5184 options.
    • Of these, 48 are in the list of good diagrams.
  • adCAJXY
    • 5184 options.
    • 48 are good.
  • bcCAJXY
    • 5184 options.
    • 0 are good.
  • bdCAJXY
    • 5184 options.
    • 0 are good.
  • cdCJJXY
    • 4 * 4 * 9 * 9 = 1296 options.
    • 6 are good.
  • cdCJKXY
    • 4 * 4 * 3 * 9 * 9 = 3888 options.
    • 6 are good.

So far, there are 576 + 4608 + 4 * 5184 + 1296 + 3888 = 31104 options, and 172 of them are good. But we also need to count the points.

  • abCAAXY
    • 8 are good. All will have a G connector.
  • abCABXY
    • 56 are good. Half will have a Y connector, half a G.
  • acCAJXY
    • 48 are good. Half will have a Y connector, half a R.
  • adCAJXY
    • 48 are good. Half will have a Y connector, half a R.
  • cdCJJXY
    • 6 are good. Half will have a G connector, half a B.
  • cdCJKXY
    • 6 are good. Half will have a Y connector, half a G.

Connectors of each type:

  • Y: 28 + 24 + 24 + 3 = 79
  • R: 24 + 24 = 48
  • G: 8 + 28 + 3 + 3 = 42
  • B: 3

This gives a sum of points of 79 * 1 + 48 * √2 + 42 * √3 + 3 * √6 = 226.97685414.

So. With 31104 options, I score 226.97685414 points.

31104 / 226.97685414 = 137.03599919. I have to play about 137.04 games to get 1 point.

Hm. I think part of my problem with method 1 was, that I didn’t get the probabilities quite right. Like, the split into the 2 ab choices give 2 probabilities, and I think I just averaged them. But they represent groups of different sizes.

I have no idea what went wrong with method 2. But method 3 was much easier to calculate, so method 2 probably had a mistake in a complicated function.

Oh. I think I made a booboo. It’s important to count options. But I should still have added, that the ab-group and the cd-group are equally likely, even though they don’t have the same size. So. Oops. No time this week to get the correct result.

Method 4. Method 1 done right? About 137? Sheet

Nyt fra sf-land!

Bemærk at Politiken typisk benytter paywall.


»Jeg tror bare, at mængden af vedligeholdelse, livet kræver, overstiger mine evner«

Neeeej! Niels Klim-prisen bliver ikke nævnt. 😉


Disse værker kan hjælpe os med at forstå ai-advarslerne

Egentlig ret solid artikel.


I 1954 stillede en forfatter en supercomputer det ultimative spørgsmål. Svaret er mere ildevarslende end nogensinde

Endnu en solid artikel.


»Jeg står nu nede i den her blindgyde, helt rasende, og ved simpelthen ikke, hvordan jeg skal komme ud«

Udover at jeg godt vil opponere mod både-eller: 👍🏻

#ThisWeeksFiddler, 20261023

This week the #puzzle is: Can You Design a Quadrangular Logo? #area #average #ArithmeticSequence

Inspired by Delta Airlines, you and a graphic designer colleague are crafting a new logo for Fiddler Airlines. Your colleague starts with an equilateral triangle with a side length of 1 unit. Next, you pick a random point inside the triangle, giving you four points: the three corners of the triangle and this fourth point inside. There are several (simple) quadrilaterals that can be drawn whose four vertices are these four points. Your colleague picks one of these quadrilaterals at random, with each having an equal probability. This quadrilateral will be the new logo.
On average, what can you expect the area of the quadrilateral to be?

And for extra credit:

While picking random points inside the equilateral triangle with side length 1, you and your colleague notice that some points are “special.” When one of these special points is connected with the triangle’s three vertices, it creates three smaller triangles whose areas form an arithmetic sequence.
After further investigation, you realize these special points all belong to a locus, the total length of which is L. What is this length L?

Can You Design a Quadrangular Logo?

Solution, possibly incorrect:

Desmos Program

Mumble, mumble, equilateral = all 3 sides have the same length. Mumble, mumble, simple = no crossings or holes. So I guess this means I always get my quadrilateral by replacing 1 side of the triangle with a trip to the new internal point. I’m not sure it’s possible to create a non simple polygon this way. Let me mess around with this a bit. (Including some messing around on Desmos.)

So each row here has the same internal point, and then each quadrilateral represents a choice of which side of the triangle to replace.

Method 1: I guess I’m ready for some monte carlo now. Using a fun method for finding an internal point randomly. I can use 2 sides of the triangle as vectors, and an internal point will be 1 point + some part of each vector, where the 2 parts / fractions have a sum of 1 or less.

Number of loops.... 5 * :      3162523
Target deviation........:    0.0001000
Deviation so far........:
................result 1:    0.0000757
======================================
Final result F, 1.......:    0.2886861
                         +/- 0.0000757

Method 2: Meanwhile I’ve figured out how to do this another way.

The area of the triangle is:

A=1⋅322=34≈0.4330A=\frac{1\cdot\frac{\sqrt{3}}{2}}{2}=\frac{\sqrt{3}}{4}\approx0.4330

This area is also the sum of the areas of the smaller 3 triangles inside, using the internal point:

A=a1+a2+a3A=a_1+a_2+a_3

When I’m choosing a quadrilateral, I’m also choosing 2 of the small triangles. So the resulting area will be a sum of the corresponding areas. I’m choosing between these areas:

a1+a2,a1+a3,a2+a3a_1+a_2,a_1+a_3,a_2+a_3

Just looking at the case with this particular random internal point, what is the average area:

Aavg=(a1+a2)+(a1+a3)+(a2+a3)3A_{avg}=\frac{(a_1+a_2)+(a_1+a_3)+(a_2+a_3)}{3}

Aavg=a1+a2+a1+a3+a2+a33A_{avg}=\frac{a_1+a_2+a_1+a_3+a_2+a_3}{3}

Aavg=2a1+2a2+2a33A_{avg}=\frac{2a_1+2a_2+2a_3}{3}

Aavg=23(a1+a2+a3)A_{avg}=\frac{2}{3}(a_1+a_2+a_3)

Aavg=23AA_{avg}=\frac{2}{3}A

Aavg=2334A_{avg}=\frac{2}{3} \frac{\sqrt{3}}{4}

Aavg=123≈0.2887A_{avg}=\frac{1}{2\sqrt{3}}\approx0.2887

Assuming a random process chose the same internal point 3 times and then chose each possible quadrilateral 1 time each, the average area for just these 3 choices would be about 0.2887. And it doesn’t matter where the internal point is, this always holds.

Result confirmed! Area is 0.2887.

And for extra credit:

Mumble, mumble, arithmetic sequence = the distance between 2 neighboring elements in the sequence is constant. So we’re talking about a sequence like this:

a1,a2,a3a_1,a_2,a_3

a1,a1+k,a1+2ka_1,a_1+k,a_1+2k

Method 1: While my monte carlo is looking at random quadrilaterals, I will also peak at the areas and save good internal points. Then I will print out those points and transfer them to Desmos, to see what we’re talking about.

I’ve already guessed the point in the middle of the triangle will be a part of the goodness, as all 3 areas would be the same, k = 0.

Oh! The good points are on 3 lines going through the middle. The horizontal line goes from x = – 1/3 to x = 1/3 and has length 2/3. The 3 lines combined have length 2.

Method 2: After this enormous hint, let’s see if this can be proven in another way.

The 3 corners of the triangle are at:

(−0.5,0),(0.5,0),(0,32)(-0.5,0),(0.5,0),(0,\frac{\sqrt{3}}{2})

The middle of the triangle is at:

(0,123)(0,\frac{1}{2\sqrt{3}})

Looking at the horizontal line, assume some other x.

(x4,123)(x_4,\frac{1}{2\sqrt{3}})

The formula for the area of the big triangle:

A=|(x1−x3)(y2−y1)−(x1−x2)(y3−y1)|2A=\frac{|(x_1-x_3)(y_2-y_1)-(x_1-x_2)(y_3-y_1)|}{2}

The area of a subtriangle is obtained by replacing a point with the internal point.

A1=|(x4−x3)(y2−y4)−(x4−x2)(y3−y4)|2A_1=\frac{|(x_4-x_3)(y_2-y_4)-(x_4-x_2)(y_3-y_4)|}{2}

A1=|(x4−0)(0−123)−(x4−0.5)(32−123)|2A_1=\frac{|(x_4-0)(0-\frac{1}{2\sqrt{3}})-(x_4-0.5)(\frac{\sqrt{3}}{2}-\frac{1}{2\sqrt{3}})|}{2}

A1=|−x4123−(x4−0.5)13|2A_1=\frac{|-x_4\frac{1}{2\sqrt{3}}-(x_4-0.5)\frac{1}{\sqrt{3}}|}{2}

A1=|−x4123−x413+0.513|2A_1=\frac{|-x_4\frac{1}{2\sqrt{3}}-x_4\frac{1}{\sqrt{3}}+0.5\frac{1}{\sqrt{3}}|}{2}

A1=|−x4323+123|2A_1=\frac{|-x_4\frac{3}{2\sqrt{3}}+\frac{1}{2\sqrt{3}}|}{2}

A1=123|−3x4+1|2A_1=\frac{\frac{1}{2\sqrt{3}}|-3x_4+1|}{2}

A1=143|−3x4+1|A_1=\frac{1}{4\sqrt{3}} |-3x_4+1|

A2=|(x1−x3)(y4−y1)−(x1−x4)(y3−y1)|2A_2=\frac{|(x_1-x_3)(y_4-y_1)-(x_1-x_4)(y_3-y_1)|}{2}

A2=|(−0.5−0)(123−0)−(−0.5−x4)(32−0)|2A_2=\frac{|(-0.5-0)(\frac{1}{2\sqrt{3}}-0)-(-0.5-x_4)(\frac{\sqrt{3}}{2}-0)|}{2}

A2=|−0.5123+(0.5+x4)32|2A_2=\frac{|-0.5\frac{1}{2\sqrt{3}}+(0.5+x_4)\frac{\sqrt{3}}{2}|}{2}

A2=|−0.5123+0.532+x432|2A_2=\frac{|-0.5\frac{1}{2\sqrt{3}}+0.5\frac{\sqrt{3}}{2}+x_4\frac{\sqrt{3}}{2}|}{2}

A2=|0.513+x432|2A_2=\frac{|0.5\frac{1}{\sqrt{3}}+x_4\frac{\sqrt{3}}{2}|}{2}

A2=|123+x432|2A_2=\frac{|\frac{1}{2\sqrt{3}}+x_4\frac{\sqrt{3}}{2}|}{2}

A2=123|1+3x4|2A_2=\frac{\frac{1}{2\sqrt{3}}|1+3x_4|}{2}

A2=143|1+3x4|A_2=\frac{1}{4\sqrt{3}}|1+3x_4|

A3=|(x1−x4)(y2−y1)−(x1−x2)(y4−y1)|2A_3=\frac{|(x_1-x_4)(y_2-y_1)-(x_1-x_2)(y_4-y_1)|}{2}

A3=|(−0.5−x4)(0−0)−(−0.5−0.5)(123−0)|2A_3=\frac{|(-0.5-x_4)(0-0)-(-0.5-0.5)(\frac{1}{2\sqrt{3}}-0)|}{2}

A3=|123|2A_3=\frac{|\frac{1}{2\sqrt{3}}|}{2}

A3=143A_3=\frac{1}{4\sqrt{3}}

Let me just repeat that:

A1=143|−3x4+1|,A2=143|1+3x4|,A3=143A_1=\frac{1}{4\sqrt{3}} |-3x_4+1|,A_2=\frac{1}{4\sqrt{3}}|1+3x_4|,A_3=\frac{1}{4\sqrt{3}}

WLOG, let’s assume:

0<x40<x_4

And we already know:

x4≤13x_4\le \frac{1}{3}

Then it becomes:

A1=143(1−3x4),A2=143(1+3x4),A3=143A_1=\frac{1}{4\sqrt{3}} (1-3x_4),A_2=\frac{1}{4\sqrt{3}}(1+3x_4),A_3=\frac{1}{4\sqrt{3}}

And move them around a little.

A1=143(1−3x4),A3=143,A2=143(1+3x4)A_1=\frac{1}{4\sqrt{3}} (1-3x_4),A_3=\frac{1}{4\sqrt{3}},A_2=\frac{1}{4\sqrt{3}}(1+3x_4)

See, this would fit with the arithmetic sequence, if k=1433x4k=\frac{1}{4\sqrt{3}}3x_4.

Result: L = 2.

Paranoia RPG, solitaire adventure, flowchart

Recently I’ve been reading the rules for the Paranoia role playing game. I heard about it, oh, 35 years ago? And for reasons , I’ve been reminded of it lately. So, let’s study the rules !

Quite early in the rule book, there’s a solitaire adventure. Of course I want to play, and then create a flowchart for it. You know me, right?

Flowchart pdf.

Or maybe you want the whole thing as 1 big page?

Flowchart pdf.

There are a couple of interesting bottlenecks along the way. Death = red. Victory = green. Blah ending = yellow.

#ThisWeeksFiddler, 20261016

This week the #puzzle is: Can You Gerrymander Like a Dummy? #probabilities #voting

Fiddler Nation has an upcoming election between its two major political parties: the Suns and the Moons. You are drawing a new electoral map, and you have been tasked with gerrymandering on behalf of your party, the Moons. Fortunately, you know exactly how every citizen will vote in the election.
Fiddler Nation has seven districts, each with an equal population. For simplicity, assume that the Moons win any district in which they receive at least half of the vote.
What is the smallest total fraction of Fiddler Nation’s population needed to vote Moon such that it’s possible for the Moons to win a majority of the seven districts?

And for extra credit:

In the next election cycle you’re back at it, gerrymandering on behalf of the Moon party once more. This time, you can draw a map that results in any set of probabilities P1, P2, P3, P4, P5, P6, and P7 that you’ll win each of the corresponding districts—subject to the constraint that the average of the probabilities is 1/2. In other words, P1 + P2 + P3 + P4 + P5 + P6 + P7 = 7/2.
The bosses of the Moon party want to go big. More specifically, they want to maximize the party’s chances of winning at least five of the seven districts. However, you are concerned that such a greedy attempt at gerrymandering may backfire, a phenomenon that has become known as dummymandering. When you draw a map that maximizes your chances of winning at least five districts, the probability the Moon party blows it and winds up losing most of the districts is LA.
Your personal preference is to simply maximize the party’s chances of winning at least four of the seven districts—a simple majority of them. When you draw a map that maximizes these chances, the probability the Moon party loses most of the districts is LB.
How much greater than LB is LA?

Can You Gerrymander Like a Dummy?

Solution, possibly incorrect:

Facts:

  • There are 7 districts.
  • A win = winning 4 districts.
  • Winning a district = getting 50% of the votes or more.
  • All 7 districts have the same size, say V voters.
  • WLOG, win district 1-4.
  • In order to win district 1, V/2 Moon votes are needed. Minimize the number of votes needed by having exactly V/2. (So V is even? Hm…)
  • The same goes for districts 2-4.
  • In order to minimize the number of votes needed for a total win, just have 0 Moon votes in district 5-7.
  • In all this is 4 * V/2 Moon votes.
  • There are 7 * V votes in all.

Examining the proportion pM of Moon voters.

pM=4⋅V27⋅V=2⋅V7⋅V=27p_M=\frac{4 \cdot \frac{V}{2}}{7 \cdot V}=\frac{2 \cdot V}{7 \cdot V}=\frac{2}{7}

Result: 2/7 = 0.285714….

And for extra credit:

Program

One of the basic ideas of gerrymandering is, that you don’t waste votes in the districts, you don’t plan to win. Let’s use this idea.

p1+p2+p3+p4+p5+p6+p7=72p_1+p_2+p_3+p_4+p_5+p_6+p_7=\frac{7}{2}

Chance of actually losing, when going for a 5 district win is LA, Same for a 4 district win, LB.

Assumption for strategy: In order to maximize the chances of a 5 district win, give each of districts 1-5 the maximum probability pA, and district 6-7 0.

5⋅pA=725\cdot p_{A}=\frac{7}{2}

pA=75⋅2=0.7p_{A}=\frac{7}{5\cdot2}=0.7

This will be compared to going for a 4 district win.

4⋅pB=724\cdot p_{B}=\frac{7}{2}

pB=74⋅2=0.875p_{B}=\frac{7}{4\cdot2}=0.875

Computing.

1−LA=1−(PA)2=0.75=0.168071-L_A=1-(P_A)²=0.7⁵=0.16807

1−0.16807=LA1-0.16807=L_A

1−LB=1−(PB)2=0.8754=0.5861816411-L_B=1-(P_B)²=0.875⁴=0.586181641

1−0.586181641=LB1-0.586181641=L_B

LA−LB=(1−0.16807)−(1−0.586181641)L_A-L_B=(1-0.16807)-(1-0.586181641)

LA−LB=−0.16807+0.586181641L_A-L_B=-0.16807+0.586181641

LA−LB=0.418111641L_A-L_B=0.418111641

Result: 0.4181.

Just for the fun of it, I also wrote a program to simulate these 2 scenarios. Result confirmed.


And then I came back. Originally I had an idea, that spreading the voters over more districts might be better. I try it out in my program. And what do you know! This works for the 5 district case.

What happens when the voters are spread out?

Let’s say the voters are evenly distributed.

pA=p1=p2=...=p7=0.5p_A=p_1=p_2=…=p_7=0.5

What are the chances 5 of the districts will be won?

(75)⋅(0.5)7=7⋅62⋅0.0078125=0.1640625{7\choose5}\cdot (0.5)⁷=\frac{7\cdot6}{2}\cdot0.0078125=0.1640625

And 6?

(76)⋅(0.5)7=7⋅0.0078125=0.0546875{7\choose6}\cdot (0.5)⁷=7\cdot0.0078125=0.0546875

And all 7?

(77)⋅(0.5)7=1⋅0.0078125=0.0078125{7\choose7}\cdot (0.5)⁷=1\cdot0.0078125=0.0078125

And all together?

1−LA=(21+7+1)⋅0.0078125=29⋅0.0078125=0.22656251-L_A=(21+7+1)\cdot0.0078125=29\cdot0.0078125=0.2265625

1−0.2265625=LA1-0.2265625=L_A

This is a lower chance of losing, much better! (ETA: And then I forgot to count “a 4 districts win isn’t the intended win, but it’s still a win”.)

LA−LB=(1−0.2265625)−(1−0.586181641)L_A-L_B=(1-0.2265625)-(1-0.586181641)

LA−LB=−0.2265625+0.586181641L_A-L_B=-0.2265625+0.586181641

LA−LB=0.359619141L_A-L_B=0.359619141

And my program says:

Go for 5 wins, 5 districts with p = 0.700, 2 districts with p = 0
Wins: 0.170090
Go for 5 wins, 6 districts with p = 0.583, 1 districts with p = 0
Wins: 0.208540
Go for 5 wins, 7 districts with p = 0.500, 0 districts with p = 0
Wins: 0.227930

Go for 4 wins, 4 districts with p = 0.875, 3 districts with p = 0
Wins: 0.584810
Go for 4 wins, 5 districts with p = 0.700, 2 districts with p = 0
Wins: 0.529170
Go for 4 wins, 6 districts with p = 0.583, 1 districts with p = 0
Wins: 0.510270
Go for 4 wins, 7 districts with p = 0.500, 0 districts with p = 0
Wins: 0.499410

Difference: 0.356880

So, for 5 districts the best strategy is to spread the voters evenly. (And it’s still not a very good strategy.) For 4 districts concentrate the votes in 4 districts. (Gives 58% chance of winning instead of the fair and just 50%.) And the difference is: 0.3596.

#ThisWeeksFiddler, 20261009

This week the #puzzle is: How Fast Can You Surf? #trigonometry #maximum #differentiation

A surfer is riding along a crest of a sinusoidal wave given by the function y = 2·sin(x−t), where y is the height above sea level in meters, x is horizontal position in meters, and t is time in seconds. Based on this, the surfer knows that her speed—and the speed of the wave—is 1 meter per second.
But hold on—it appears that another wave is approaching from the opposite direction. This wave has half the amplitude but twice the speed: y = sin(x+2t).
The two waves, the forward and the backward, ”interfere,” meaning they combine. In other words, the height of the water at position x and time t is given by y = 2·sin(x−t) + sin(x+2t). Nevertheless, the surfer stays atop a crest of the combined wave.
As the wave moves along, what are the surfer’s slowest and fastest [horizontal] speeds, in meters per second?

And for extra credit:

The surfer rides the crest of the combined wave, y = 2·sin(x−t) + sin(x+2t), for a very long time.
What is her average [horizontal] speed, in meters per second?

How Fast Can You Surf?

Solution, possibly incorrect:

Desmos Program

Method 1: Code it up in Desmos, just to see what’s happening. Huh! The combined wave (purple) has a funny start and stop pattern, where horizontal movement seems to stop entirely, while the wave grows in size.

Method 2: Math. Everybody seems to agree, when vv = speed of wave (or in out case, speed of crest), λ\lambda = wave length and ff = wave frequency:

v=λfv=\lambda f

This can’t quite fit our situation, because the speed obviously varies, while the wave length and the wave frequency stay constant.

Let’s just look at a single moment.

t=0,w(x)=2sin(x−t)+sin(x+2t)t=0, w(x)=2sin(x-t)+sin(x+2t)

w(x)=2sin(x)+sin(x)=3sin(x)w(x)=2sin(x)+sin(x)=3sin(x)

When does this function have a max or min?

w′(x)=3cos(x),w′(x)=0w'(x)=3 cos(x),w'(x)=0

3cos(x)=03cos(x)=0

cos(x)=0cos(x)=0

x=arccos(0)=π2x=arccos(0)=\frac{\pi}{2}

And this max/min is:

w(π2)=3sin(π2)=3⋅1=3w(\frac{\pi}{2})=3sin(\frac{\pi}{2})=3 \cdot 1 = 3

Yeah, actually a max. So at time 0, the crest (or one crest) is at (π2,3)(\frac{\pi}{2},3).

Let’s try this with a more general time instead.

t=c,w(x)=2sin(x−t)+sin(x+2t)t=c,w(x)=2sin(x-t)+sin(x+2t)

Chain rule:

w′(x)=2cos(x−t)⋅1+cos(x+2t)⋅1w'(x)=2cos(x-t)\cdot 1+cos(x+2t)\cdot 1

Looking for a max/min:

0=2cos(x−t)⋅1+cos(x+2t)⋅10=2cos(x-t)\cdot 1+cos(x+2t)\cdot 1

0=2cos(x−t)+cos(x+2t)0=2cos(x-t)+cos(x+2t)

Identities:

0=2[cos(x)cos(−t))−sin(x)sin(−t)]+cos(x)cos(2t)−sin(x)sin(2t)0=2[cos(x)cos(-t))-sin(x)sin(-t)]+cos(x)cos(2t)-sin(x)sin(2t)

0=2cos(x)cos(−t)−2sin(x)sin(−t)+cos(x)cos(2t)−sin(x)sin(2t)0=2cos(x)cos(-t)-2sin(x)sin(-t)+cos(x)cos(2t)-sin(x)sin(2t)

0=cos(x)[2cos(−t)+cos(2t)]−sin(x)[2sin(−t)+sin(2t)]0=cos(x)[2cos(-t)+cos(2t)]-sin(x)[2sin(-t)+sin(2t)]

cos(x)[2cos(−t)+cos(2t)]=sin(x)[2sin(−t)+sin(2t)]cos(x)[2cos(-t)+cos(2t)]=sin(x)[2sin(-t)+sin(2t)]

2cos(−t)+cos(2t)2sin(−t)+sin(2t)=sin(x)cos(x)\frac{2cos(-t)+cos(2t)}{2sin(-t)+sin(2t)}=\frac{sin(x)}{cos(x)}

arctan⁡(2cos(−t)+cos(2t)2sin(−t)+sin(2t))=x\arctan(\frac{2cos(-t)+cos(2t)}{2sin(-t)+sin(2t)})=x

I try out this function in Desmos. It actually follows the minimum, but the math is the same.

So far so good! A visual inspection shows these values for the speed of the crest.

vmin=0(t=0,2π3),vmax=?(t=π3)v_{min}=0(t=0,\frac{2\pi}{3}),v_{max}=?(t=\frac{\pi}{3})

Doing a test where I look at how much the crest moves over a short amount of time, ϵ\epsilon, 0 is confirmed. And the max value seems to be 4!

Method 3: Write a program. This simply supplies Desmos with data to show the path of the crest and a curve for the speed of the crest. As it uses the same math, it spits out the same results.

Result: 0≤v≤40 \le v \le 4.

And for extra credit:

This is suspiciously easy.

Average speed = total distance / total time. From reading Desmos again, measuring between 2 maxima:

t=0,x=π2t=0,x=\frac{\pi}{2}

t=2π3,x=7π6t=\frac{2\pi}{3},x=\frac{7\pi}{6}

v=7π6−π22π3v=\frac{\frac{7\pi}{6}-\frac{\pi}{2}}{\frac{2\pi}{3}}

v=7π6−3π62π3v=\frac{\frac{7\pi}{6}-\frac{3\pi}{6}}{\frac{2\pi}{3}}

v=4π62π3v=\frac{\frac{4\pi}{6}}{\frac{2\pi}{3}}

v=4π6⋅32πv=\frac{4\pi}{6} \cdot \frac{3}{2\pi}

v=22=1v=\frac{2}{2}=1

Result: 1.

#ThisWeeksFiddler, 20261002

This week the #puzzle is: Can You Swim With the Fishes? #probabilities #normaldistribution

Can You Swim With the Fishes?

Solution, possibly incorrect:

Program

Method 1:

Result 1: 1.666667

Method 2: Every time fish 1 goes by at speed 1, fish 2 goes by at speed 2 twice. The average of 1, 2 and 2 is 5/3 or 1.67.

Result: 1.67.

And for extra credit:

Method 1:

Result 1................:    1.2533140
Result 1................: 1.2533792
Result 1................: 1.2532510
Result 1................: 1.2533647
Result 1................: 1.2532415
======================================
Number of loops.... 5 * : 100980391
Target deviation........: 0.0001000
Deviation so far........:
................result 1: 0.0000632
======================================
Final result 1..........: 1.2533101
+/- 0.0000632

Result: 1.25.

Nyt fra sf-land!

Politiken benytter paywall på mange af sine artikler.

Jeg burde åbenbart ikke holde af at synge ’I Danmark er jeg født’, fordi det er jeg ikke. Men jeg synes sangen er skøn alligevel

(Sjovt nok tænker jeg primært på forvanskning af historien i 1984.)

Han slog igennem med blod dryppende ned ad sixpacken

(Ikke et ord om Murderbot. Suk. Men Wicker må godt komme med. Dobbelt suk.)

Tim Curry er død

Tommy Lee Jones har fødselsdag:

Og i øvrigt – inklusive engelske undertekster:

Bo er blind …

Star Trek!

Why I love Star Trek, Discovery season 4

I ask every episode: Why do I love trek? Most episodes demonstrate some of the reasons.

Number / Name Why I liked it
401 / 4:1
“Kobayashi Maru”
Trying to save everybody. Bad thing?
Accept the non-perfect solution?
402 / 4:2
“Anomaly”
Visual of zero gravity.
Remember to say “Well done”.
Admit your trauma.
403 / 4:3
“Choose to Live”
A “soul” getting a new body.
404 / 4:4
“All Is Possible”
Therapy.
Leader + teacher. Topic: Working together.
Negotiation, mediation.
When a career change is the right thing.
405 / 4:5
“The Examples”
In mortal danger, everybody should be rescued.
The therapist might need therapy too.
Survivor’s guilt.
The right to choose suicide.
406 / 4:6
“Stormy Weather”
Helping a new AI deal with feelings.
407 / 4:7
“…But to Connect”
Trying to figure out the exact nature of an AI.
Trust. Communication.
408 / 4:8
“All In”
A poker game.
409 / 4:9
“Rubicon”
Handling that personal ties to “the enemy” = disqualification.
“Resting” the mind before a difficult mission.
410 / 4:10
“The Galactic Barrier”
Discussing parenting with your child.
411 / 4:11
“Rosetta”
Decryption! Communication!
Balanced response, not just criticism.
A headler in need of healing.
412 / 4:12
“Species Ten-C”
Learning a new language.
Math!
413 / 4:13
“Coming Home”
Reasons matter.

 

It makes sense to me, that a species might not look like a human, and that a translator might be needed. Unfortunately this broke “show, don’t tell” big time, and every aspect of the threat felt very abstract. (And “the enemy blew up my planet” is a cliche by now, yes?)

#ThisWeeksFiddler, 20260925

This week the #puzzle is: Can You Frame the Triangle? #trigonometry #triangle #circumscribe #montecarlo #coding #minimum #average

Congratulations—you just won your school’s tabletop football championship! You flicked your lucky paper football to victory countless times, and would now like to frame it for posterity.
The football is an equilateral triangle with a side length of 1 inch. What is the side length of the smallest square frame that will contain the football?

And for extra credit:

To add a little excitement to the framing process, your new plan is to spin the triangular football by a random angle, and then frame it with a square that is not rotated. That is, the square consists of two perfectly horizontal sides and two perfectly vertical sides.
On average, what can you expect the side length of the smallest resulting square frame to be?

Can You Frame the Triangle?

Solution, possibly incorrect:

Desmos Program

Checking… Yeah, this is a triangle, where all 3 sides have the same length.

My sense is, that this square will have side length 1 inch. But let me just check. Oh, that’s not right. Messing around with Desmos gives me something like 0.966. This is achieved, when 1 side of the triangle has exactly a 45 deg angle on the horizontal and vertical axes. This was actually fun. To go from an angle to a triangle, to a circumscribed rectangle, to a circumscribed square. Visit Desmos to see an animation!

So that’s method 1. Method 2 is monte carlo (where it’s kind of overkill to have a variance check, I’m looking for a minimum). Result confirmed.

0.966 inches.

And for extra credit:

The easiest is to let the monte carlo register a lot of squares and take the average. (It was already registering a lot of them and taking the minimum.)

======================================
Number of loops.... 5 * : 32010
Target deviation........: 0.0001000
Deviation so far........:
................result 1: 0.0000029
................result 2: 0.0000886
======================================
Final result 1..........: 0.9659279
+/- 0.0000029
Final result 2..........: 0.9886172
+/- 0.0000886

0.989 inches. This makes sense, as being between the minimum and 1.