Diary, December 2020

 Sun Mon Tue Wed Thu Fri Sat 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Tuesday, December 1, 2020

Double date

Today is a double date when the date is written in the format MM/DD/YY or YY.MM.DD. The next such date is on February 10, 2021. This is the seventh and last special date of this year.

Saturday, December 5, 2020

Hyper Sudoku

We had some problem solving a Hyper Sudoku and we wondered if it could be solved without guessing. For this purpose, I modified the program for converting a Sudoku to an Exact Cover problem. (On September 9, 2010 is used this program for solving the Hardest Sudoku.) With the program, I checked that the two Hyper Sudokus as published on page 42 of Denksport Logisch 2-4★ vakantieboek NR.38, indeed did only have one solution and could be solved without guessing.

Sunday, December 6, 2020

Steen bij de Höfte

Around noon, Conny and I walked the through the park called Zweringbeekpark. This year October 30, a replacement for the marke stone Steen bij de Höfte was placed in the park at about the original location of the stone.

Tuesday, December 8, 2020

BindingList with filtering

A BindingList<T> in the .NET framework can be used to bind a user-interface control with a data source that consists of a list. The idea is that the control will follow any changes in the contents of the list and that through the control the contents of the list can be changed. But it lacks good possibilities to implement filtering and sorting. In my search for how to implement this, I found the blog: Databinding with a filter and a sort. In the end, I created my own solution, for a one-way use where the control cannot directly change the list. I created a class derived from BindingList<T> with an _inner member of type BindingList<T>. It implements an event handler on ListChanged event of _inner, which performs the filtering (and sorting) and then fills the Items collection again with the elements (in the sorted order). Each change in the Items collection will raise a ListChanged event. To prevent this, the RaiseListChangedEvents property can be set to false to surpress these events. However, it is not possibility to raise the ListChanged event in a derived class, because it is not defined in the proper way. (See: How to raise base class events in derived classes in the .NET programming guide.) I implemented a trick by which each change to the Items collection is delayed and that the last change is applied after RaiseListChangedEvents has been set to true again. (After this, I also added a call to the ResetBindings method.)

Random numbers on micro-controller

I got some question from an artist with respect to random number generation on an micro-controller. These usually have a build in pseudorandom number generator. Although these usually produced a good random sequence, they generate the same sequence every time the micro-controller is started. A common solution to avoid this, is to add a call to randomSeed in the initialization with some hardware related random source, for example, to call analogRead on an 'open' input pin. However, analogRead from an open pin is usually not a very good random source because they do not have a uniform distribution or contain a strong 50/60 Herzt signal from a nearby power line. The least significant bit, are usually a better random source. There are some tricks to combine many samples into a better signal with some shifting and exclusive-or bitwise operations. (See for a long discussion about this: Better Arduino Random Numbers.) Another solution is to combine the 'good' pseudo-random source with a 'weak' random hardware source. The artist wanted to have a one-in-eight random change expression. I suggested to use:
An even better and genertic method is to mix the two random sources. See for example the (untested) modified random function from the Arduino implementation:
static long myRandom(int n, int pin)
{
/*
* Compute x = (7^5 * x) mod (2^31 - 1)
* wihout overflowing 31 bits:
*      (2^31 - 1) = 127773 * (7^5) + 2836
* From "Random number generators: good ones are hard to find",
* Park and Miller, Communications of the ACM, vol. 31, no. 10,
* October 1988, p. 1195.
*/
static long x;
long hi, lo;

x = x ^ analogRead(pin); // Mix with 'weak' random source

/* Can't be initialized with 0, so use another value. */
if (x == 0)
x = 123459876L;
hi = x / 127773L;
lo = x % 127773L;
x = 16807L * lo - 2836L * hi;
if (x < 0)
x += 0x7fffffffL;
return x % n;
}

Note that for us humans it is quite difficult to recognize pseudorandom sequences from 'hardware' random sequences. Below two images, one generated with a short pseusorandom sequence of length 127 and the other from www.random.org. Click on the image so see which is which.

Wednesday, December 9, 2020

Twinkly

Yesterday, we installed the Twinkly starter light set with 105 RGB LED's. I installed the app on my phone and played at little with it. This evening, I wanted to try to access it through a laptop with the help of XLED - unofficial control Twinkly - Smart Decoration LED lights. I spend some time installing all the depended modules (using pip3) and was able to connect to it. But I got invalid challenge-response errors like described in issue 30. I have a TW105SEUP09 device with firmware version 2.1.8. There is a firmware update to version 2.3.8 available. I am thinking about developing a program in C++ that uses the Real time LED operationg mode by sending UDP packets to port 7777. For this I do need the authentication token. I hope I can retrieve this using the XLED Python library.

Saturday, December 12, 2020

Compile on save

I came up with very simple bash script, which will compile a give C++ program every time when it is saved:

#!/bin/bash
while true; do
exetime=`stat -c %Y \$1`
cpptime=`stat -c %Y \$1.cpp`
if [ \$cpptime -gt \$exetime ]; then
g++ \$1.cpp -o \$1
fi
sleep 1
clear
done

Futoshiki to Exact Cover

I wrote a program to convert Futoshiki puzzles into Exact Cover problems. I first attempted this by generating all permutations for each row and column that are allowed by restrictions, but that did not lead to an exact cover that could be solved easily. With this second version, I took the same approach as the method for for sudoku puzzles.

Fungus on tree

When I was cleaning the leaves in the garden, I noticed many very small mushrooms on the trunk of the large tree in our garden. They were on the side of trunk that is overgrown with moss. Appearantly, that part of the trunk is also infected with some type of fungus. I have no idea if this is a bad sign or that it is relatively benign condition. On the right a close-up of one of the mushrooms.

Wednesday, December 16, 2020

Pythagorean triple date

Today is a Pythagorean triple date because 16² + 12² = 12² + 16² = 20². It was due to a new paper article by Ionica Smeets that I heard about these kind of special dates. This makes it the eight special date of this year.

Saturday, December 19, 2020

Groote Boekel

Conny and I went searching for three marke stones along the former marke Esmarke and Lonneker, namely: Steen bij de Stroinksbleek, Steen bij erve Kleinvoort, and Hoge Boekelersteen. We only found the first, which is not an original stone, but one placed on Augustus 18, 2017. It happened to be near the entrance of a school that Andy attended for some years. We could not find the second stone, because the location was overgrown and we could determine its location. The third stone is at the Groote Boekel estate. We looked around the estate and some adjecent fields and roads and walked about 4Km. We could also not locate the last stone, which should be on the estate. Conny did take a nice picture at the estate which happens to include me.

Sunday, December 20, 2020

Twinkly red-orange animation

In the past weeks, I made some further attempts to control the Twinkly starter light set. I managed to write a Python script that writes the authenitication token to a file and changed the mode to rt with some small modifications to the xled library, using the following script fragment:
control.get_mode()
file = open("token.txt", "w")
file.write(control.session.client.authentication_token)
file.close()
control.set_mode('rt')
I also wrote a C++ program that would send UDP packets to port 7777 as described in the documentation about Real time LED operating mode, but I failed to get it working. So, today, I wrote a Python script, which uses the movie mode to send movies of one frame to animate the LEDS with a pattern consisting of red and 30 orange lights, where every second at most five orange lights change place. Then, while writing this, I read the documentation about the Real time LED operation mode, I realized that I had left the byte out specifying the number of LEDs. When I modified the test program, it worked. I modified the program to have a similar effect as the Python script.

Monday, December 21, 2020

VUI - 202012/01

I find it rather bizar, that due to some statement about the a new COVID-19 variant, officially known as VUI - 202012/01, all personal traffic with the United Kingdom has been stopped. On one hand, I am surprised that now suddenly it is possible to shutdown flights within very short noticed, while in the past people were adviced to go into quarantine when coming from an area with a high infection rate. On the other hand, I am surprised because the variant was already found in the Netherlands. It might already have been going round for over a month, because the variant was first detected early October from a sample taken in September. It might even be the case that the variant is responsible for the 'third' wave here in the Netherlands. We do not know this, because here in the Netherlands not much samples are being sequenced for the detection of new variants. So, I feel it is like slamming a door after giving the foo ample time to slip inside. It is clearly an overreaction caused by fear.

Tuesday, December 22, 2020

Moleskin daily planner

This morning, I realized that I had not yet bought a Moleskin daily planner for next year. I ordered one from the webshop of Bookshop Broekhuis for € 19.90. This evening, I found a Moleskin daily planner for 2021 being delivered, probably by someone from the bookshop. Made me happy!

Saturday, December 26, 2020

Three cases

There have no been three cases being reported of the new variant of the COVID-19 virus in the Netherlands. Two cases are found in Amsterdam and one in the region of Rijnmond, which is near Rotterdam. In all cases no direct relation to the United Kingdom was found, which means that the new variant is already circulating in the Netherlands. It is possible that the virus is not more infectious but spreading more easily because it makes less people ill. It might look more like the normal coronavirus for which most people have some immunity. If people have no or vague symptoms, they are more likely to infect others.

Monday, December 28, 2020

Goki puzzle: no touching colours

Before, I already investigated the number of solutions for the round Goki puzzle ignoring the colour of the pieces. Someone raised the question about the number of solutions when pieces of with the same colour are not allowed to touch. I extended the program with two new options. One option to generate an Exact Cover and one option to check the results. The program found 256,299 unique solutions with respect to rotations and mirroring.

Tuesday, December 29, 2020

Oklab colour space

About a week ago, I came accors the Oklab color space. This morning, I tried to use it for generating a colour palette, like I did before with the HSLuv colour space. For the a and b parameters, I used the sine and cosine functions multiplated with a saturation factor. To get a palette looking similar to the HSLuv palette, I had to use saturation (chroma) factors ranging from 0.07 to 0.17 and values from 0.6 to 0.9 for the L parameters. Althought Björn Ottosson claims that the Oklab colour space is better than the other colour spaces. About HSV he states: Only on this list because it is widely used. Does not meet any of the requirements except having a D65 whitepoint. He does not mention HSLuv nor compare it with his colour space. I am also a little worried about colours getting out of range. In the palette below there are eight clipping errors with values being 12.5% out of range. For a more in-depth discussion see: Oklab: A perceptual color space for image processing on Hacker News.

This text is displayed if your browser does not support HTML5 Canvas.

Round Goki puzzle

I extended the program with another command for some further analysis of the round Goki puzzle. There are 1,789,051 unique solutions to the puzzle when the colour of the pieces are ignored. For each of these solutions, there are 288 (=2*2*2*3*2*6) solutions when the colour of the pieces are taken into consideration. This leads to a total of 515,246,688 unique solutions not taking into account rotations and mirroring. Only 256,299 of these solutions have no pieces with the same colour touching eachother. That is only about 0.05% of all solutions. According to the new command of the program only 26,661 of the 1,789,051 unique solutions to the puzzle when the colour of the pieces are ignored, do have solutions where no two pieces with the same colour are touching. That is about 1,49%. I furthermore, made a break down of how many of the unique solutions ignoring the colours have solutions with no touching colours. These results are presented in the table below. According to this table, 898 of the unique solutions ignoring the colours do have seven solutions where the pieces of the same colour are not touching eachother.

407  1   |  1739 10   |    84 30
1494  2   |  4187 12   |   158 32
1170  3   |   281 14   |     1 33
3631  4   |    24 15   |   104 36
441  5   |  1194 16   |    54 40
3879  6   |   317 18   |     3 42
898  7   |   599 20   |   165 48
4117  8   |    36 21   |     5 60
99  9   |  1539 24   |     6 64
11 11   |    18 28   |

Wednesday, December 30, 2020

Mander circles

Conny and I walked along the Mander circles near the village Mander. We search for some border poles, and found the following:
• At 15:40, pole 86-III
• At 16:08, pole 87
• At 16:17, pole 87-I
• At 16:25, pole 87-II
We searched for border pole 86-IV, but could not find it.

Thursday, December 31, 2020

Galgenberg

Conny and I went walking to Galgenberg, which translate as gallows hill in English. It is named so, because in the middle ages, there was a gallows where the corpses of death row inmates were put on display as a deterrent. Before we went there, we looked at a watermill along the mosbeek. While walking around the area, we found the following border poles:
• At 11:55, pole 83
• At 12:35, pole 84
• At 12:52, pole 85
• At 12:59, pole 84-I