Posts tagged ‘programming’

September 23, 2013

An Investigation into the Death of Ivan Ilych

by Mikael

“The Death of Ivan Ilych” is a short novel by Leo Tolstoy, one of his masterpieces. In the words of Wikipedia:

The novella tells the story of the death, at age 45, of a high-court judge in 19th-century Russia. Living what seems to be a good life, his dreadful relationship with his wife notwithstanding, Ivan Ilyich Golovin injures his side while hanging up curtains in a new apartment intended to reflect his family’s superior status in society. Within weeks, he has developed a strange taste in his mouth and a pain that will not go away. Several expensive doctors are consulted, but beyond muttering about blind gut and floating kidneys, they can neither explain nor treat his condition, and it soon becomes clear that Ivan Ilyich is dying.

Anthony Briggs in the introduction of my copy points out an interesting litterary device that Tolstoy employs: As the story progresses towards the inevitable end (already given away in the title), the chapters and paragraphs become shorter and even the sentences briefer. This seemed like something that could be systematically tested. I therefore helped myself to the text in plain form from Project Gutenberg and wrote some simple parsing code.

The numbers may seem unremarkable at first but when we take a look at the rolling averages, the trend becomes strikingly clear. The chapters, paragraphs and sentences indeed become shorter towards the end. In fact even the words Tolstoy chooses become progressively shorter on average. One must wonder to what extent this was a conscious decision.

The Results [PDF]

tolstoy-the-death-of-ivan-ilych

The alignment on the horizontal axis is by word index, i.e. Chapter II starts at about 15% since Chapter I has 3229 words out of the 21821 in the whole book. The longest words (16 letters each) are: circumstantially, lightheartedness, misunderstanding, and incomprehensible. The longest sentence with 123 words is:

Having graduated from the School of Law and qualified for the tenth rank of the civil service, and having received money from his father for his equipment, Ivan Ilych ordered himself clothes at Scharmer’s, the fashionable tailor, hung a medallion inscribed *respice finem* on his watch-chain, took leave of his professor and the prince who was patron of the school, had a farewell dinner with his comrades at Donon’s first-class restaurant, and with his new and fashionable portmanteau, linen, clothes, shaving and other toilet appliances, and a travelling rug, all purchased at the best shops, he set off for one of the provinces where through his father’s influence, he had been attached to the governor as an official for special service.

Finding the longest paragraph is left as an exercise to the reader 😉

Advertisements
July 23, 2011

Interview Question: Data Structure for Tic-Tac-Toe

by Mikael

Got this recently:

Tic-Tac-Toe decision tree

Tic-Tac-Toe decision tree

How would you design a data structure for the game Tic Tac Toe? The main objective is to provide: A method, as efficient as possible, for checking the board to see if there is a winner.

read more »