This book is an exciting exercise. It is very amusing to see the authors code, and amusing still to know that Angus Croll is quite well versed in both coding as well as literature to pull off an idea like this. The analysis of style he provides per writer is bang on. When asked to produce a Fibonacci series for a given "n", Hemingway produces the most essential, no-nonsense code (not an extra line or variable anywhere), while Andre Braton, the surrealist, defines an array of indefinite length and puts a cap on it when he reaches a solution he desires (not very elegant a programmer would argue, but hey, its his style!)
The funniest moment in the book comes when Roberto Bolano is asked to do what Hemingway has done, and he does produce a code that works, but midway through the code he creates an unused array to store the names of some mathematicians, just like that!
rationalTheorists = ["Archimedes of Syracuse", "Pierre de Fermat (such margins, boys!)", Srinivasa Ramanujan", "René Descartes", "Leonhard Euler", "Carl Gauss", "Johann Bernoulli", "Jacob Bernoulli", "Aryabhata", "Brahmagupta", "Bhāskara II", "Nilakantha Somayaji", "Omar Khayyám", "Muḥammad ibn Mūsā al-Khwārizmī", "Bernhard Riemann", "Gottfried Leibniz", "Andrey Kolmogorov", "Euclid of Alexandria", "Jules Henri Poincaré", "Srinivasa Ramanujan", "Alexander Grothendieck (who could forget?)", "David Hilbert", "Alan Turing", " John von Neumann", "Kurt Gödel", "Joseph-Louis Lagrange", "Georg Cantor", "William Rowan Hamilton", "Carl Jacobi", "Évariste Galois", "Nikolai Lobachevsky", "Joseph Fourier", "Pierre-Simon Laplace", "Alonzo Church", "Nikolai Bogolyubov"]
Why? Well, its a homage to the mathematicians who came before him, and yes, it is perfectly alright to have that meaningless-looking info right in the middle of your algorithm. Bolano is one writer who has to define where he stands, the code can wait to produce results.
While all the writers use simple iteration to find numbers in the Fibonacci series, Dan Brown finds a secret number which when multiplied with each number produces the next number in the series. Here is how he defines it:
TheBotticelliVector = 1.61803;
This is Croll's analysis of Dan Brown's strange usage: "But wait, what’s this? It seems Brown has discovered a dark and mysterious multiplier (The Botticelli Vector, no less), which he uses to derive the next number from the one before. This arithmetic alchemy is all well and good, but we’re left wondering whether he knew he could just add the previous two numbers to make the next one. Anyway, it seems to work, so that’s probably all that matters." (A subtle jibe at Brown's secret way of fashioning his plots)
When asked to produce a general program to return the factorial of any given number n (for example, factorial of 4 would be: 4! = 4 x 3 x 2 x 1), Jack kerouac fashions his solution such that no matter what number you enter, his program will return the factorial of 43 every single time! Croll again: "because planning was so alien to his process that even functions are verboten. If you want the factorial of another number, you’ll need to pull a stimulants-induced all-nighter and rewrite it."
Seeing the way each code piece written by 25 different writers is commented on, you will notice that the intention is to hint at their literary style as well. Playfully, the book shows that the vast possibilities of both writing and coding are very reflective of the writer.
Franz Kafka, who attempts to write a code too, remains the only writer in this little book whose code never works. He attempts a very simple program but it enters a recursive loop till infinity from which an escape is impossible. The array of words that appear on screen becomes a long, terrible, useless string.
Croll's Analysis: "It’s as though it were subject to some kind of metamorphosis . . . Very Kafkaesque."