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.

Nebula-noveller

Lad os tage et kig på de Nebula-nominerede noveller, det nyeste kuld.

Evan: A RemainderJordan KurellaResten af Egon👽👽☠️
Five Views of the Planet TartarusRachael K. Jones5 x synet af planeten Tartarus👽👽☠️
The V*mpireP. H. LeeV@mpyren👽👽☠️
The Witch TrapJennifer HudakHeksefælden👽👽☠️
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👽👽☠️

Måske er jeg ekstra gnaven i år? Det kan man jo ikke afvise. I hvert fald er der ikke noget, der lige får mig op at ringe. Men blandt alt det næstbedste, så er det “Five Views”, der ligger øverst.

Jeg har skrevet om Hugo- og Nebula-tekster før.

Altså, ungen i Omelas-hullet

Anmeldelse af “Why Don’t We Just Kill the Kid In
the Omelas Hole” (gratis), af Isabel J. Kim. Novelle. 2024. Nebula-nomineret, Hugo-finalist.

Skitse: Nogen myrder barnet i hullet i Omelas, og så sker der alle mulige ulykker, og så bliver et nyt barn proppet i hullet, og alting er godt igen.

Er det science fiction? Tja?

Temaer: Omelas, hele dagen, alle vegne! #JeSuisOmelas

Selvom alle er lykkelige og lige og alt det der, så er nogle huse alligevel lidt pænere end de andre. Måske er der en modsætning mellem de rige (?) og de gode (?)?

Historien virker meget moderne, nutidig.

Er det godt? Hm. Jeg kan ikke helt se, hvad den her version tilfører af nyt. 👽👽☠️

#ThisWeeksFiddler, 20250516

This week the #puzzle is: Can You Permeate the Pyramid?

Consider the following figure, which shows 16 points arranged in a rhombus shape and connected to their neighbors by edges. How many distinct paths are there from the top point to the bottom along the edges such that:
– You never visit the same point twice.
– You only move downward or sideways—never upward.

And for extra credit:

Consider the following figure, which shows 30 points arranged in a three-dimensional triangular bipyramid. As before, points are connected to their neighbors by edges. How many distinct paths are there from the top point to the bottom along the edges such that:
– You never visit the same point twice.
– You only move downward or sideways—never upward.

Highlight to reveal (possibly incorrect) solution:

Program 1.

And for extra credit:

Program 2. Program 3. Program 4.

VVii vviill llæærree ddiigg aatt llææssee

Anmeldelse af “We Will Teach You How to Read | We Will Teach You How to Read” (gratis), af Caroline M. Yoachim. Novelle. 2024. Nebula-nomineret, Hugo-finalist.

Skitse: Nogen (rumvæsner?) forsøger at kommunikere med os, men det er svært, fordi deres egen form for kommunikation er helt anderledes end vores.

Er det science fiction? Måske.

Temaer: Udover det her med at kommunikere på en helt anden måde, så hører vi også snipper af, at deres samfund er ved at dø, og at de unge ikke længere lærer at læse.

Er det godt? Tja. 👽👽☠️

Heksefælden

Anmeldelse af “The Witch Trap”, af Jennifer Hudak . Novelle. 2024. Nebula-nomineret.

Skitse: En sko under gulvet holder heksen væk.

Er det science fiction? Nix. Mest fantasy.

Temaer: Vi hopper rundt mellem forskellige tekster, der handler om hekse. Det skal vist forestille, at gulvets ejer researcher fænomenet. Og så beslutter, hvad der skal ske med skoen.

I øvrigt synes hekse: Ned med patriarkatet.

Er det godt? Tjo. Af gode grunde fragmentarisk. 👽👽☠️

V@mpyren

Anmeldelse af “The V*mpire” (gratis), af PH Lee. Novelle. 2024. Nebula-nomineret.

Skitse: Det er 2012 og på tumblr, og du er 14, og det giver bare mening at sige, at du er en pige. Er det okay at lade som om? Hvad er det der med trans? Og hvorfor er det forskelsbehandling ikke bare at invitere alle vampyrer ind i sit hjem?

Er det science fiction? Nix. Fantasy/horror.

Temaer: Øj, en ordentlig omgang “jamen, hvad er det okay at sige?”. Fordi det er ikke kun “de gode”, der retter dig. Og er det ikke altid okay at kalde, æhm, problematiske personer ved det navn? Være intolerant overfor de intolerante.

Psykisk og fysisk vold. Nok til at teksten starter med en advarsel.

Er det godt? Åh, den rammer noget. Sådan, lidt for meget. Av. 👽👽⭐

5 x synet af planeten Tartarus

Anmeldelse af “Five Views of the Planet Tartarus” (gratis), af Rachael K. Jones. Novelle. 2024. Nebula-nomineret, Hugo-finalist.

Skitse: Et rumskib fyldt med fanger ankommer til planeten Tartarus og Orfeus-fabrikken.

Er det science fiction? Nemlig.

Temaer: Det er kun hvert 10. år, sådan et rumskib er der. Min fornemmelse er, at vi taler om uhyrlige forbrydelser og utænkelig straf, men det fremgår ikke eksplicit. En del af mekanismen er, at fabrikken giver evigt liv.

Teksten er ganske kort. Det virker som et godt valg.

Er det godt? Tja. 👽👽☠️

Resten af Egon

Anmeldelse af “Evan: A Remainder”  (gratis), af Jordan Kurella. Novelle. 2024. Nebula-nomineret.

Skitse: Da Evan sagde højt, at han faktisk er en mand, førte det til en skilsmisse og et nyt liv i en grim lejlighed. Han bliver optaget af en blodplet på gulvet, der bare ikke vil gå af, og af at spytte tænder (?) ud.

Er det science fiction? Det kan man vist ikke påstå. Horror, nutid.

Temaer: Noget med transformation. Noget med at acceptere hvem man er og har været.

Noget med knogler.

Noget med kærlighed.

Formen har hop i tid.

Er det godt? Jeg ved ikke, om det her er nyskabende. Det er i hvert fald ikke lige mig. 👽👽☠️

#ThisWeeksFiddler, 20250509

This week the #puzzle is: Can You Sweep the Series? #probability

Let p represent the probability the Celtics win any given game in the [best-of-seven] series. You should assume that p is constant (which means there’s no home-court advantage) and that games are independent.
For certain values of p, the likeliest outcome is indeed that the Celtics will win the series in exactly five games. While this probability is always less than 50 percent, this outcome is more likely than the Celtics winning or losing in some other specific number of games. In particular, this range can be specified as a < p < b.
Determine the values of a and b.

And for extra credit:

Let p4 represent the probability that the Celtics sweep the Knicks in four games. And let p7 represent the probability that the series goes to seven games (with either team winning).
Suppose p is randomly and uniformly selected from the interval (a, b), meaning we take it as a given that the most likely outcome is that the Knicks will lose the series in five games. How likely is it that p4 is greater than p7? In other words, how often will it be the case that probably losing in five games means a sweep is more likely than a seven-game series?

Highlight to reveal (possibly incorrect) solution:

Program 1.

And for extra credit:

Program 2. WolframAlpha.