## 30 August 2011

### The Beauty of a Coded Revolving Door

I have been struggling with a programming problem for a couple of years that I found nearly impossible to solve. (I finally solved it just last week, but that is the point of this posting.) The problem was so overwhelming, and my desire to solve it so strong, that I would ask almost everyone that I had known for a while about it. I had asked programmers, biologists, geologists, physicists and just about everyone else I could think of (except artists and musicians who generally turn their noses up and programming related things). Though I would try to translate the problem into their respective field, they all got the same basic problem.

My primary purpose in asking so many people from so many different backgrounds was in hopes that one of them would spark some idea of a solution that I could run with. To my disappointment, none could offer any real help with the issue. Though, one programmer suggested using an array to store the variables which is eventually what I did and many added to the solution, none offered the big solution that I was hoping for. In the end, I should have expected that the solution would come from dozens of little nuggets instead of a giant lump.

The problem goes like this: There are eight basic virtues. I wish to determine a person's ultimate virtue, the one that overrides all others, partly because it is fun and partly because it can tell a lot about that person's perspective and thus why they do what they do.

The best way I know to determine the overriding virtue is to compare the each virtue against each other (a or b) instead of a ranking or other comparison. This method forces the person to decide which virtue is valued most of all in a given context. Such questioning results in a bank of 28 questions containing all the possible pairings (I did not develop the question bank; Origin Systems gets credit for that). In just seven questions, I can reduce the eight virtues down to the single most important virtue. To do this I ask a series of four randomly selected questions that compare all eight virtues, and only the eight virtues.

The first key to the problem was that there could be no overlap: each virtue is asked only once in the opening round. Asking any one virtue twice would defeat the purpose. The second key to the problem—and perhaps the more challenging—is the preference to have the first four questions randomized. If I would have forsaken the randomization then I could have solved the rest of the problem long ago; but what fun would that be? After the opening round, the virtues are then compared in a tournament style: the answers from questions one and two are compared in question five and the answers from questions three and four and compared in question six. The final question, question seven is a comparison of the answers from question five and six.

One of the primary motivators for programming this has been a desire to share the test with others. I could have simply given out the whole of 28 questions but knowing most people the sheer number and complexity of the questioning would have proved foreboding. Instead, I wanted to "hand out" a polished form of the test that could be taken as easily as shared. And, I must confess, at some point I find it difficult to flip through a list of 28 questions trying to remember which virtues have been compared and what the response were.

The solution to providing a randomized tournament questionnaire came while running. (Since my running partner decided to go home to get married, I wish them the best, I have found that I have a lot of thinking time while running and was able to bring together everyone’s input over the years.) Also a major part of the solution and jogging ideas has been my recent massive expenditure of time on learning Action Script 3 (the programming language of Adobe Flash) for another project. Everything came together and here is the final outline of the solution:
1. All eight possible virtues are stored in an array (an array is a way to store multiple variable under a single name, like the shoe storage bins outside a play pin: one object, the shoe bin, multiple and separate slots). The array, called myVirtues, looks like this: `myVirtues:Array = ["Compassion", "Honesty", "Valor", "Sacrifice", "Honor", "Justice", "Spirituality", "Humility"];`
2. The array is randomized using some quick sorting which is by no means scientific and I am sure not that good, but good enough.
3. The brilliance that made the whole thing possible is: `pop()`. This attribute removes the last item from the array (i.e. takes out the last pair of shoes from the shoe bin). The removal ensures that the virtue cannot be reused and moves the marker to the next available virtue. `pop()` is ran again with the second virtue stored with the first one in another array called `myQuiz`.
4. The second array, `myQuiz`, is sorted alphabetically before proceeding. This too was a stroke of brilliance inspired from by a friend teaching me calculus. Before the sorting, I was having to double all my coding related to matching `myQuiz` with the appropriate questions; once as a + b and again as b + a because I was not sure which order they would pop out in. By sorting them before the comparison I do not need to worry about the order because they will always be in alphabetical order so I only needed to make sure the values `myQuiz` is compared against were also in alphabetical order.
5. Once `myQuiz` is matched to a question number, the question is presented to the user.
6. At this point, I have come to realize that in terms of programming Google is my best friend for learning things but biology is my best teacher for helping me find solutions. I have found inspired solutions many times by learning how living creatures have developed to overcome obstacles. In my original plan of how to handle round two of questions I was going to create a third array to store the answers in. This turned out to be unneeded by using `unshift()` which does the opposite of `pop()`: it puts something in first place in the array and pushes everything else back one (i.e. it moves all the shoes down one slot and adds a pair into the first slot). This was somehow inspired by the way the body handles stress though the actual connection between the two escapes me. This technique reduces the amount of code needed by allowing the exact same mechanism that selects the first round of questions to handle the second and all subsequent rounds without modification. The initial array becomes a revolving door for providing virtues until the array is down to its last virtue.
For me, one of the most beautiful parts of the code is the "revolving door" array  because that with a single line of code the program knows when it has asked the seventh question: `if(myVirtues.length > 1)`. The program keeps asking questions until it is done. No extra coding, just plain and simple "`end of line`."

Thank you to everyone who has ever answered my probing questions about the way things work, without you I would never have found this solution.

## 27 August 2011

### Teachers: You'll need it later in life

(I found this in my notes--towards the bottom of the list--next to the note Can I, May I and Can I Go to the Bathroom.)

One of my personal favorites was being told that I would need something later in life. The teacher didn't know when or how, just that I would. Now that I am later in life I look back on these statement and realized they might as well have told me that at some point I would be shot by a mobster, they just don't know when or why.

The key thing this statement communicates to children is that the all knowing teacher knows that you will need some bit of information but that the children, in their limited knowledge and understanding will need to struggle and figure out, throughout life, how to use the information. If they happen to die before figuring it all out then they will die wondering "how was I supposed to use that incredibly valuable piece of information that no one knew how I would use it?".

What is tremendously better is what my college algebra teacher was explained to me: "higher math is required not because you'll actually need it, because you won't. Higher math teaches you to think differently, that's why we learn it." Thus explanation is so much better than "because you'll need it in some indefinite time in your life for some indefinite purpose."

## 24 August 2011

### The (unexpected) blessing of Chat

I remember back when my work first switch to our current email service, Google Apps, from the old antiquated one, a private offering. The old service provided basic email services, 100mb of space and no calendaring or document sharing support. For its time it was normal, compared to now it was dismal. As I was proposing the switch from the old service (which we paid for) to the new service (which was free at the time) I was explaining the benefits of Google Apps: Gmail was a smarter email system, shared calendaring, Docs and Spreadsheets that have only got better with time, Chat to allow instant communication, and of course, Free. I think it was the word "free" that won out in the end, but I remember that Chat was of particular concern. Mostly, the management was concerned that employees would abuse it.

Fast forward four years to yesterday: My work just announced the opening a new location. While the new store will not be open for several weeks (the actual opening date has not been announce) the announcement alone has caused a fervor of activity. There are computers to get ready, inventory to order, people to hire and plans to put down. I, being a remote worker, do not have the normal luxury of roaming in and out of offices to get the answers to questions I have about the opening. How many computer terminals do we need? Who is the store manager? What dates have been announced? How will the new store effect back end staffing? Each of these is a pressing question that needs to be answered sooner rather than later: they each effect a series of other choices that need to be made.

Features such as a live shared calendar are good to be able to track dates on a unified calendar; we are using a Google Spreadsheet to track assignments, record progress notes and completion of tasks. But it is Chat, the Google instant messaging service built into Gmail, that is proving to be most helpful with getting quick responses to simple, but important questions. The one service that we feared would be damaging is invaluable. Unlike email, Chat has a more immediate and pressing presence and allows for quicker back and forth communication and the resolution of additional questions that arise.

This instant communication is good for handling questions, but there is more to it than just question answering. Chat allows remote workers, whether it is me several hundred miles away from the company or the Customer Service Office just a few miles away from the Corporate Office, that help us feel closer together. Close enough to vent our frustrations, tell jokes and even share pictures all the while remaining productive and active in our respective offices. In some ways, I think Chat allows us the benefit of both worlds: distance brings us more productivity because it puts us closer to what each of us manages (the Customer Service people are closer to the warehouse people they work closely with, the Admin people are closer to their records, the merchandiser are closer to their catalogs and I am closer to my phone) while also allowing us to feel a sense of connectedness and camaraderie that improves moral and binds us together.

## 18 August 2011

People who have been successful through out history (at least modern history) have been so because of the enormous effort they have put into their success, so argues Gladwell. He suggests that coming from a wealthy background and being born with a high IQ can help lay a foundation for that success but notes that there are more that many people who inherited wealth squander it and that there are more geniuses who have less than noteworthy jobs than those who do. Instead, proficiency and success usually comes after about seizing an opportunity, applying about 10,000 hours of practice and recognizing your cultural legacy. As with Gladwell's other books, Outliers presents a narrative with a broad collection of story to illustrate his point.

Interesting tidbit: nineteenth century European farmers generally worked about 1200 hours a year. That is 200 more hours a year than hunter/gatherers (and I was always under the impression that we changed from hunter/gatherer to farmer because it was easier). Both of these pale in comparison to the rice farmers of the era who generally worked (and many still do) 3000 hours a year.

## 15 August 2011

Most of the most important decisions we make, are made in a split second using "thin-slicing" decision making. These decisions are often made more correctly than we can manage if we put our minds to it. For example, doctors diagnosing heart attacks usually go through a long list of tests and procedures to determine if the attack is real. Doctors correctly diagnosed the heart attack 70%-90% of the time. Gladwell cites a study by Dr. Goldman who took hundreds of heart attack case studies into a computer program developed by physicists to build correlation models for particles. The result was a comparatively simple, and much less (needlessly) expensive, algorithm that allowed doctors to correctly diagnose heart attacks more than 95% of the time. Goldman's process, as is the point of the book, happens with less information, much quicker and more accurately than the traditional process.

Interesting tidbit: John Gottman, a psychologist at the University of Washington, has developed a 15 minute analysis, that with a 95% accuracy, can determine if a couple will still be married in 15 years. All by "thin-slicing" the conversation.

## 11 August 2011

### "Made to Stick" by Chip Heath and Dan Heath

This book seeks to capture the essence of why things stick with us in society. Why is the urban legend about a man waking up in a tub of ice with his kidney removed still floating around when we cannot barely remember yesterday's news? Why is Southwest still profitable (for 30 plus consecutive years) while other airlines struggle? The brothers Heath identify many underlying reasons and write them in an easy, and fun, easy to follow narrative.

Interesting tidbit: In one study, people who thought analytically before being asked to donate to African relieve donated an average of \$1.14 out of \$5. People who thought emotionally before being asked to donate to African relieve donated an average of \$2.38 out of \$5.

Side trivia: you are 300 times more likely to be killed by a deer than a shark.

## 08 August 2011

### "The Man Who Lied to His Laptop" by Clifford Nass

This book is an impressive collection of insights and studies gleaned by a consultant and professor over a long, long time. Most of the studies use some sort technological interaction to explore a human relational question (computers are a lot easier to control that people). For example, one studied compared how well happy or sad people worked with computers that were happy or sad (happy people prefer working with the happy computers while sad people prefer working with sad computers). Much like "The Shallows" by Nicholas Carr and "Switch" by Chip and Dan Heath, this books is a good read and then good again for reference because there are so many good studies presented.

Interesting tidbit: negative experiences cause "retroactive interference" to our memories; we have a hard time remembering what happened immediately before the bad experience. After the negative experience, however, our memories are increased beyond normal clarity. This is why often survivors of a bad accident cannot remember what caused it but can tell you, in great detail, everything that happened immediately after it.

## 05 August 2011

### "Tipping Point" by Malcolm Gladwell

As things begin building, they come to a point where a small extra effort pushes it over the brink. He uses a series of examples to show how three things come together to create a tipping point, for example: Connectors, Mavens and Salespeople. The Connectors keep in contact with a broad variety of people. They do not necessarily know much nor are they really good at convincing people to do things, but they can connect a people from very different walks of life. The Mavens stockpile information. Where the Connector works to stay in contact with people, the Mavens gather information so they can share it with other people. Salespeople do what the Mavens cannot do, convince people. When things reach the tipping point, these three types of people get together. The Connectors are able to connect a Maven (who knows stuff) with Salespeople (who can convince people to 'buy' the Mavens 'product', whatever it be) and things can take off.

Interesting tidbit: William Dawes rode on the same mission as Paul Revere, but because he was not a good Connector, Dawes was only able to arouse the two individuals he was assigned to where Revere was able to awaken the whole countryside.

### Whoever was working on Australia got lazy

I was reading A Fragile Balance by Christopher Dickman and Rosemary Woodford Gany--okay, reading is a bit of a stretch... I was looking at the pictures in  A Fragile Balance and started to realize that Australia has a lot of animals that look like kangaroos. I have known for several years that Australia has kangaroos and wallaby, but never realized that they also have wallaroo, potoroo bettong, pademelon, dorcopsis and quokka all of which look like close friends of the kangaroo. It is almost as if who ever was in charge of animals in Australia got lazy just tweaked the kangaroo frame over and over again.

http://en.wikipedia.org/wiki/Kangaroo
http://en.wikipedia.org/wiki/Wallaby
http://en.wikipedia.org/wiki/Wallaroo
http://en.wikipedia.org/wiki/Potoroo
http://en.wikipedia.org/wiki/Bettong
http://en.wikipedia.org/wiki/Dorcopsis
http://en.wikipedia.org/wiki/Quokka

## 04 August 2011

### IF(CHECK == RUN_DATE)

I have been writing a lot of scripts for Google Docs at work lately, mostly because I have finally learned how to do more advanced scripting than I had done previously. The Admin office had requested a script that ran once a month, towards the end of the month, to notify them of the upcoming birthdays and insurance eligibility. The script itself was very similar to one I wrote for the Customer Service office so this one was not too hard. The bigger challenge, oddly enough, was not the script but the timer. They only wanted it ran once a month but Google only has built in timers for Minute, Hour, Day and Week. I wrote the script and puzzled over how I was going to get it  to run monthly. Then it struck me: No one cared how often the script ran as long as it only sent out emails once a month. With this in mind the solution was simple: IF(CHECK_DATE == RUN_DATE)--in other words: if today's date happens to be the 26th then run the script. I set the script to run daily and now it runs for a second to compare dates and 29 days a month (actually, 30 some months and 27 or 28 for one month depending on the year) the script does nothing. But on that one special day it works its magic.

Where was I going with this? Oh, I remember. Sometimes I get so focused on the vision of how I think things should work that I forget that the how (in most cases) is far less important than the accomplished end goal. In Malcolm Gladwell's Blink he talks about how the military used to write incredibly articulated orders that were intended to cover every action to be taken by the soldiers. They found that these orders were nearly useless once the fighting started. The military phased out these verbose orders and replaced them with what they call the "Command Intent" (CI). The CI tells every level of the command structure, in short concise language, the single most important goal. Note that the CI is ONE goal, not several goals. This is because as soon as you start interlacing various objectives you water down the entire purpose of the CI: your soldiers no longer have a singular focus. Coupled with the CI there may be additional orders that clarify and flesh out the CI with additional goals and preferred outcomes but the CI removes all ambiguity as to what success looks like. Something like:
Command Intent: Build a bridge to move tanks across the river.
Additional Information: We would prefer that the bridge be a far north as possible and in a location that will allow for quick access to roads on both the east and the west sides while providing a strong defense position.
Note how the preferences do not cloud the CI (by the way, I made up those commands just as an example, Gladwell includes better examples in his book). The CI tells us that the commanders will be happy if there is a bridge that support tanks. They would be elated if the other conditions were also met, but they will be happy with the bridge. The magic of this type of ordering is that the soldiers who are actually running the bridging equipment and playing in the forests with the enemy can work out where the most effective position will be instead of a commander in a distant office. In the end, the commander really does not care where the bridge is as long as he can get his tanks across. Another advantage is that everyone knows what the overall objective is and if the see one group struggling, they can quickly step in and assist. Before it was "our orders are to stay here and guard nothingness" and now it is "we need to get the bridge built, what can we do to help". This creates a more efficient use of resources, one that can quickly adapt to environmental changes (like ants in an ant nest as in
Quorum Sensing (or Natural Leadership Vetting).

In the context of this script, I was too focused on the mechanics of running a script monthly instead of the Command Intent of monthly emails. After realizing that the intent was to get monthly emails and that it did not matter how often the script ran, the needed course of action seemed obvious.

Sometimes express direction is needed, and indeed critical, but I am finding it more often that such directions only cloud the judgement and creativity of the individuals by forcing them to do it my way instead of allowing them to learn and grow by doing it there way.

## 03 August 2011

### "The Shallows" by Nicholas Carr

A thorough examination of the topic: "What is the Internet doing to our brains?" Carr pulls together a broad range of experiences, reports and research studies to evaluate, though not necessarily draw conclusions, of how our use of computers, and particularly our use of the internet, is literally reshaping our brains. There is a lot of good material in this book, including some ideas on how to enhance your brain.

Interesting tidbit: when reading off of a paper, our eyes are drawn line by line, row to row in a zig-zag fashion (left to right, top to bottom). When reading off an electronic display (e.g. computer, phone, tablet, etc.) our eyes are drawn across the first line of the page, down the left side until the half way point, across the half way point and then down the left side to the bottom of the page (in an "F" shaped pattern). This means, as proved in numerous studies, that students learn and retain more from an actual book than from electronic books. Which is almost ironic to consider how hard schools are pushing ebooks on their students that will inherently result in slower, more difficult learning.
(Note: these patterns are for the Latin based world, that is English, French, German, etc. Arabic and other language bases have their own distinct patterns that the eyes follow.)