In the previous part of this article we formulated the Einstein's riddle in terms of matrices, and presented three matrix operations that will be the base for an algorithm to solve the riddle. In this part we'll be talking about this algorithm, and a JavaScript implementation which will allow solving this riddle and any other grid riddle similar to this one.
There are some programming languages as Prolog, designed to work with logic facts, where you can deal with logical problems in a natural way. By using the matrix formulation we can use any programming language to deal with this kind of riddles. Here we provide the implementation, in JavaScript, of the matrix object with the three basic operators used to solve the riddles. The selection of JavaScript is not arbitrary, it allows to show the effectiveness of the algorithm in this same post.
There are several logical grid puzzles you can find on the internet, but undoubtedly, one of the most popular known is the Einstein's riddle. Although it's attributed to Einstein, there's no evidence to back up that claim. It's rumoured that only 2% of the world can solve it, but it's really not so hard, all one needs is logic and deduction. In this article we are going to present a method based entirely on matrix operations to solve this riddle and any other similar.
There are five houses in five different colours in a row. In each house lives a person with a different nationality. The five owners drink a certain type of beverage, smoke a certain brand of cigar and keep a certain pet. No owners have the same pet, smoke the same brand of cigar, or drink the same beverage. The question is: Who owns the fish?
Nowadays information is at hand. Just open your browser, type some words about what you want to know, and thousands of pages will arise to satisfy your information needs; and surprisingly, you will find the most relevant information in the first proposed pages. It’s not a mystery the way the search engines work to make their magic, it’s just mathematics. Behind their complex algorithms is hidden the linear algebra and other mathematical theories.
Every search engine needs three basic elements: a web crawler, a database to save the data it finds, and an algorithm to determine the order of pages returned by any search inquiry. The two first elements can be automated easily, the main problem lies on the third one, and here is where the mathematical tools are the key to the solution.
Since humans invented the written language, they have tried to share information secretly. This is basically, the objective of Cryptography, the study of the techniques to protect sensitive communications by means of data encryption and its posterior decryption. Encryption is the transformation of data into some unreadable form, so, even those who can see the encrypted data cannot understand the hidden information. Decryption is the reverse of encryption; it is the transformation of encrypted data back into some intelligible form.
Although there are different methods to encrypt and decrypt messages, we'll focus on a linear algebra based cipher, the Hill cipher, which uses a matrix as a cipher to encode a message, and it's extremely difficult to break when a large matrix is used. The receiver of the message decodes it using the inverse of the matrix.
Linear Algebra is not what it seems at first thought. Behind all the matrices, polynomials, vectors and spaces, there is a fascinating subject which tools can help you to solve many practical problems. Linear Algebra is a topic connected to different fields inside and outside mathematics like functional analysis, differential equations, engineering, graph theory, statistics, linear programming, and computer graphics.
There are hundreds of books with the aim of teaching Linear Algebra, your choice will depend, basically, on the kind of course you are taking, and on the approach, prose and rigor of the text you prefer to study. Here I propose a brief list of books, based on my personal experience, from famous books I have read or consulted.