Es werden Posts vom Januar, 2022 angezeigt.

Solving equations by rule-based artificial intelligence

This probably isn't new, but it is an idea I've had now. When I was younger I wondered why computer programs can compute assignments but are unable to solve equations in which the variable that was to be assigned was not explicit. In fact it is quite easy to program a computer so that it is able to solve equations. The easiest way is to use a binary tree to represent an equation. A binary tree has an operator as its root, e.g. equality, and the operands as its right and left children. It is basically similar to a linked list and can be represented in prefix notation. For instance, the equation "(3 x + 5) * 4 = 44" would be "= * + * 3 x 5 4 44" in prefix notation. Now the computer only needs to know some rules such as that "= + a b c" is equal to "= - c b a". Then the computer can systematically use these rules to consecutively move the variable (e.g. x) to a higher position inside the binary tree than where it initially is, until it reach

Acey Ducey in Kotlin

While doing research for my job I bumped into the site where old computer games written in Basic are ported to modern languages. I am very fond of this project and I've already contributed a port myself, namely a port of Acey Ducey to Kotlin.

Project Euler #3

A colleague of mine has suggested solving Project Euler #3 as a challenge. I noticed that his code was working fine but very inefficient. In fact the specification of this task is misleading because it suggests that it is necessary to check if a solution is prime. But it is possible to formulate the solution without checking for primality. Here is my implementation in Kotlin. fun euler3(n: Long, i: Long = 2): Long =     if (i >= n) n     else if (n % i == 0L) euler3(n / i, i)     else euler3(n, i + 1) fun main(args: Array<String>) {     var numcur = euler3(600851475143)     print("$numcur") } The trick is to quit the loop when i exceeds n.

Mein Weltbild

Es gibt nicht nur die physische Welt, die wir mit unseren fünf Sinnen wahrnehmen können, sondern auch eine Welt der Ideen. Alles Denkbare existiert in dieser Welt. Der kreative Prozess besteht darin, Ideen in der physischen Welt umzusetzen.