Coding, Computer Science, Crafty, Logic, Python, Simon's Own Code

A Small Program that Doubles Itself

I wrote a small program that copies itself. When the program doubles itself it executes itself twice. The code that doubles itself is now doubled. The second time you run it you will get 8 times its original copy. The following time it’s going to double 8 copies of itself 8 times. Afterwards it doubles 2048 copies of itself 2048 times — that I can’t run because it would overwhelm the universe 5 times!

Coding, Computer Science, Engineering, Logic, Math and Computer Science Everywhere, Python

Simon’s Halting Problem Gist

You can easily turn every statement into a program. If the program stops, or “halts”, then the statement is true, and if it never stops, or “loops”, the statement is false.

Like, for example, the following program corresponds to the statement: “There’s at least one even number that cannot be expressed as the sum of two primes” (this is the negation of the so-called “Goldbach Conjecture”):

So, if we can figure out if any program will halt or not halt, we can prove everything! Can we do that, though?

Read more on Simon’s GitHub

Computer Science, Logic, Math and Computer Science Everywhere, Notes on everyday life, Simon's sketch book

The three ages or 1-input 1-output logic gates

After a whole night working on my writing and not feeling very fresh in the morning, I told Simon about the three ages of life: the young age is when one can party all night long and the next morning feel like one has been sleeping like a rose, the middle age is when one parties all night long and the next morning feels like one had been partying all night long, and the old age is when has been sleeping all night long and the next morning feels like one has been partying all night long. He immediately drew these pictures, telling me it’s just like 1-input 1-output logic gates, but the only one that makes sense is the OR.

Logic, Math and Computer Science Everywhere, Murderous Maths, Notes on everyday life, Philosophy, Simon teaching, Simon's sketch book, Thoughts about the world

Simon’s graph theory thoughts about the overpopulation problem

In a complete binary tree, every node has two children (except for the bottom nodes that don’t have any children at all). This means one mind-blowing thing: that the bottom row always has more nodes than the number of nodes in the entire rest of the tree! Example: if there’s one node at the top of the tree, two nodes in the second row, four nodes in the third row and eight nodes in the bottom row, the bottom row has more nodes (8) than the remaining part of tree (7). I’ve been thinking about this, and I applied this to the real world:

The average number of children a parent has in the world is 2.23 (I’ve used an arithmetic mean, which is oversimplistic, should have probably used the harmonic mean). Does this mean that currently, the number of children exceeds the number of parents? The definition of “children” I’m using are people who don’t have children, so the last row of nodes so to speak. By “parents” I’m counting all generations. If you just want to talk about now, the parents living now, then you have to trim the top rows (the already dead generations). If the average number of children is 2 or more, are there going to be more children in the world than parents?

Well, in this model, I’m ignoring crossover. This means we should consider every node in our tree for 2 people*. So, now, if the average number of children is 4 or more, there’re going to be more children than parents. So, what I said earlier was wrong. The average number of people doesn’t exceed 4, so there aren’t more children than parents. But the number of children today may still exceed the number of parent generations still alive.

Logic, Machine Learning, Milestones, Murderous Maths, Notes on everyday life, Set the beautiful mind free, Simon's sketch book

Learning to See. On Machine Learning and learning in general.

December was all about computer science and machine learning. Simon endlessly watched Welch Labs fantastic but freakishly challenging series Learning to See and even showed me all the 15 episodes, patiently explaining every concept as we went along (like underfitting and overfitting, recall, precision and accuracy, bias and variance). Below is the table of contents he made of the series:

While watching the series, he also calculated the solutions to some of the problems that Welch Labs presented, like the question about the number of possible rules (= grains of sand) for a simple ML problem if memorisation is applied. His answer was that the grains of sand would cover all land on earth:

Simon loved the historical/philosophical part of the course, too. Especially the juxtaposition of memorising vs. learning, the importance of learning to make assumptions, futility of bias-free learning, and the beautiful quotes from Richard Feynman!

screenshot from Welch Labs Learning to See [Part 5: To Learn is to Generalize]

I have since then found another Feynman quote that fits Simon’s learning style perfectly (and I believe is the recipe to anyone’s successful learning as opposed to teaching to the test): “Study hard what interests you the most in the most undisciplined, irreverent and original manner possible.” We have discussed the possibilities of continuing at the university again. I have also asked Simon how he sees himself applying his knowledge down the road, trying to understand what academic or career goals he may have set for himself, if any. Does he have a picture of himself in five years from now, where does he want to be by then? He got very upset, just like when asked to sum himself up in one sentence for an interview last spring. “Mom, I’m just having fun!”

A beautiful humbling lesson for me.

Electronics, Engineering, Good Reads, Logic, Notes on everyday life, Simon's sketch book

Simon continues practicing Digital Computer Electronics

Reading the Digital Computer Electronics eBook (third edition):

writing the table of contents in Paint
studying algebraic simplification of circuits (from the DCE book)
algebraic simplification of circuits
Logic, Math Riddles, Milestones, Murderous Maths, Simon's sketch book

Too Many Twos Solution Proof

Simon has come up with an equation to solve the Too many Twos, the puzzle mode of the Add ‘Em Up game:

x is the number of twos I used to clear out just a single two at a time

y is the number of twos I used to clear out six twos at once.

We have two pieces of information. At the beginning, the twos are arranged in a pattern with 40 twos in it. And the number of twos I can use to clear out the whole grid is 25.

x + 6y = 40

x + y = 25

We thought we solved it, but no! The reason why is because of the way the twos are arranged there were spots where there were exactly 6 twos neighbouring an empty cell. And there was only one spot where there wee more than 6. Our equation says that there must be 3 of those. the way I solved this problem was by considering a third variable, z = the number of twos that I place without clearing any twos in the grid. So now our two equations look like this:

x + 6y – z = 40

x + y + z = 25

With a little bit of cleverness though, we know that these are all integers. You don’t have 2.7 twos! That doesn’t exist! Which means that we can use some number theory to narrow it doen. After solving these equations we get: x = 25 – y – z and y = 3 + 2z/5

We’ve got a fraction. We need to carefully choose the z for this to result in an integer! This is only true if z is divisible by 5.

I don’t want to check infinitely many solutions. Luckily, we know one more quite obvious thing: all of our variables must be positive. So if z gets too large, x will become negative. How large? Let’s just be lazy and use trial and error. Let’s draw a table. In our table we now only have four solutions that we need to check. The first one, with 0 z‘s, clearly doesn’t work.