Saturday, October 3, 2015


There are three empty jugs on a table. Winnie the Pooh, Rabbit, and Piglet put walnuts in the jugs one by one. They play successively, with the order chosen by Rabbit in the beginning. Thereby Winnie the Pooh plays either in the first or second jug, Rabbit in the second or third, and Piglet in the first or third. The player after whose move there are exactly 1999 walnuts in some jug loses. Show that Winnie the Pooh and Piglet can cooperate so as to make Rabbit lose.

Let us arrange the jugs and the players as described.



In order that Rabbit be made to lose the jugs 2 or 3 must have both 1998 walnuts each.

Now each one takes equal turns upto that and Rabbit would have put his share in either jugs 2 or 3

So Winnie and Piglet can both match the contribution from Rabbit  to their respective 2 and 3 jugs. Neither of them is the first to put a walnut in either jug 2 or 3 but they are equally responsive to keeping the count even in both 2 and 3.

After the one of the two jugs 2 or 3 becomes 1998, that jug is closed for contribution. Now it’s the other jugs that will be filled up to 1998 by the matching and since Rabbit is forced to playing the odd numbered count in that jug, Rabbit is forced to lose.

Today we review the book “Good leaders ask great questions” by John Maxwell. 
The author is a celebrated leadership authority and he cites examples of how questions have changed his life. He also takes on about seventy questions on leadership that people have asked him. 
This book shows why it’s important to ask questions, now and throughout your career. It helps you find the key questions you should ask yourself and your team. It shows how questions help you lead yourself so that you may lead others. Finally it helps you weather poor leadership and develop emerging talent. 
The irony with questions is that you only get answers to the questions you ask. If you are looking for some light, you have to ask the right questions. Questions also unlock and open doors that were previously unnoticed or unopened. 
Questions help us be humble, to engage others in conversation, to build better ideas, and to get a different perspective. In fact, it helps you challenge mindsets and can get you out of the ruts. The author says when you feel you have reached a status quo, questions can help you break out of it. In his words, 
“Good questions inform. Great questions transform.” 
Let us first ask what questions do I ask myself as a leader ?  While it may be easier to list questions about yourself, you want to pick those that attribute to your leadership. For example, when you ask am I investing in myself ? It will let you know how you see yourself, how you see your future, how others see you. If you ask am I genuinely interested in others ?  It will help you show that your motives matter. If you ask am I grounded as a leader ? It will demonstrate stability. Questions about your team, your strength zone and your continued value to the team, your focus on today and your time with the right people will explore and widen those aspects of your leadership. Maxwell quotes Socrates as “The unexamined life is not worth leading”. 
Once we have explored ourselves and our leadership abilities, we can then focus on our team. Questions to your team members puts their strength, passion and ideas to work. Questions about your assistance to the team members will establish the interaction for success. Maxwell firmly believes that leadership is servanthood. In addition, he says successful leaders know the context more than the content. So they communicate better. You should ask your team members what they learnt and what remains to be learned ? Questions like did we make the most of the opportunity and does our numbers show improve the team. Even a simple what am I missing can help you review. 
Maxwell then includes a list of questions that leaders have asked him. For example, he has been asked why leading oneself seems more difficult than leading others ? He answers by saying this is due to blind spots which are very harmful as they manifest in the action taken by leaders and cascade down. Blind spots such as having a singular perspective, insecurity, an out of control ego and weak character make it harder for us.  
He has been asked what the most important values for a leader were to which he cites servanthood, purpose, integrity, relationships and renewal. Along these lines when he asked what is one habit a leader could practice daily to which he responded – giving more than you receive. 
When asked about humility and servanthood being considered as signs of weakness, he says this is not so.  People who achieve at a high level of excellence can smell weakness. That is different from humility which is being realistic and grounded. 
Does everyone have the potential to be an effective leader? Maxwell says three main components come into play in the development of the leader : environment, exposure and equipping. And yes its more caught than taught. 
When asked about other questions on how leadership works, Maxwell continues with some more examinations.  When asked about the greatest challenge in leadership, he responds by saying it’s the ability to make tough choices and uncomfortable decisions. 
When asked about top skills required to lead people through sustained times, Maxwell responds with the following guidelines to lead the team members: 
  1. Define reality – as a leader, you can define the things that restrain people especially when they have a hard time figuring out on their own. 
  1. Remind them of the big picture – Leaders will keep reminding the vision because the people will need it. 
  1. Help them develop a plan – You need to know where you are and where you want to go. 
  1. Help them make good choices  People’s choices define who they are and where they go 
  1. Value and promote teamwork – Maxwell says no team can win and keep winning unless everyone works together. 
  1. Give them hope – Crisis, difficult times and conflicts are opportunities to build better relationships. 
When asked about how to determine your leadership potential, he answers with four areas: 
  1. Pay attention to the need you see – leadership begins with a need 
  1. Use your abilities to help others – you know yourself or find others who do or examine what makes you most productive or influential. 
  1. Make the most of your passion and  - passion in a leader is compelling to others 
  1. Develop your influence – you must persuade other people to work with you. 
When asked about his advice to first time leaders, he says not to worry too much about what others think and to do your best, work hard and keep growing. 
The next section focuses on resolving conflicts and leading challenging people. 
Maxwell is candid when saying people who hurt team productivity do not change. It doesn’t make you a bad leader but it means you have someone who’s bad for the team and the organization. 
When we make a mistake or suffer a loss, we sometimes get emotionally stuck and some losses require time because they cut deeply. But we have to move past them and put energy into healing. 
When asked about how to inspire the team to make its current work a career and something to be proud to do, he responds saying don’t focus on the job and instead focus on the people. Jobs don’t have future but only people do. And if the people are growing and learning, their future is bright. Share your passion. It’s contagious.  
When asked about how to know a relationship is broken and how to save it, he responds saying the telltale sign is that it’s hard to have an honest conversation. 
To fix such a relationship, you have to take the initiative. Give others the benefit of doubt. In fact Maxwell says he always goes into that conversation assuming he has done something wrong. Once he discovers there’s hope for helping a relationship come back, the conversation goes better if he is open and willing to take the blame. He says always walk the second mile and speak well of people afterwards. 
Finally he gives some advice about working under poor leadership and successfully navigating leadership transitions. He says when the leader fails to share vision, tap into the organization’s larger vision. When you identify the larger vision, share it with your leader. You may have to adjust it to his or her values and goals. And develop your own sense of purpose. You will just need to be more certain about it. 
In order to navigate leadership transitions, he quotes Brian Tracy as saying “In a time of rapid change, standing still is the most dangerous course of action.” Sometimes transitions are self-initiated.  This is because leaders are restless and try to find new mountains to climb. Good restlessness is healthy but bad restlessness comes from being bored and unhappy. He says don’t move anywhere else until you have given the best you have. 
When asked about what leadership principles enable a failed leader to lead again successfully, he responds with honest evaluation ? Do you realize what you need to change ? And rebuild your emotional strength. You can then make adjustments needed for your future success. 
The end note of the book is about how to develop leaders. He says to help others become better leaders, do the following: 
  1. Make sure people worthy of your time and attention have a learning attitude. They’re open to instruction and hungry to grow. 
  1. Identify their strengths – the people you lead may not know where they are good at. 
  1. Give them a place to practice because they will certainly need practice to be perfect 
  1. When they make mistakes, walk alongside them to give them the security and to help them through the most difficult times 
  1. Keep increasing their responsibilities so that they can step in and take your place. 

At the very foundation of doing this kind of service, is to be a better leader ourselves. 

Friday, October 2, 2015

Today we review the book Pitch Perfect by Bill McGowan and Alisa Bowman. Its a book that teaches how to say it right the first time, every time. Its teaching is built on the premise that during pivotal moments of our lives, its not only what we do but also what we say that matters.Using the right tone to convey the right message to the right person at the right time is therefore the purpose of this book. In this book, the authors use their own principles of persuasion, which are highly effective and easy to learn, implement and master. The right language can make you more confident, persuasive and certain. It also serves to leave an indelible impression and create memories.
Moreover, the author says Pitch-Perfect moments happen in business every day. By using the simple seven principles of persuasion, we stand out by displaying genuine interest. It improves us in such a way that we create compelling stories, anticipate questions and speak with conviction.
Communication skills are always sought after by one and all. and every time we speak its an opportunity to inform, influence and inspire. If you say it right, you have sealed the deal. If you say it wrong, you might be considered annoying, tedious, ineffectual or  irrelevant.
Pitch perfect moments may be recalled from our past when we deliberated a lot or rehearsed more  and yet we did not succeed or may be we did. But how do we know what's perfect.
Here are some traits of 'Pitch-Perfect' practitioners:
1) They practice - there is no shortcut to rehearsal
2) They develop  distinctiveness while most of us let us fall into a conformity zone
3) They show crisp conviction: they never equivocate
4) They keep it short - yes less is more, you usually have ten to eighteen minutes
5) They display sheer delight - Even if you need to fake it, you want to exude a palpable enthusiasm.
So what are the principles of persuasion:
1) The headline principle -  Get attention by starting with your best material, especially a grabbing thought provoking line
   Here we can choose to talk like a journalist when she writes a new story.
They have a compelling 'lead' paragraph that evokes "what's this about ? I want to know more"
They are short usually with the opening sentences.
They are suspenseful - the intrigue you include lets your audience to chew mentally rightaway and
They are surprising - often leaving with the audience "This is new. I haven't heard it before"
2) The Scorsese principle - Visual story telling is the sweet-spot of good communication. In a way good communicators are a lot like film directors. They provide rich detail but keep it tight. The authors cite studies where facts are recalled twenty two times more likely when they are told in stories and sixty thousand times more memorable than words. How to say it as a story ? The formula:
The Setup - weave the story in your presentation instead of calling it out
The Build - your build sets the scene, introduces key characters and hints at some tension or conflict to be resolved.
The Reveal - This is the anecdotal equivalent of a joke's punchline
The Exit - Let the message sink in with a pause for a beat or two
3) The Pasta-Sauce principle There are several incredible parallels between cooking and communicating -  for example, less is more and simpler is better
How to boil down a message - Develop decisive starts and finishes. and serve your emotional ties to the content. Use the headline principle and practice a lot more. Avoid numbers. Rick Perry lost the election when he said he would eliminate three departments and remembered only two and always leave them wanting more.
4) The No-Tailgating principle :  Think of your brain and your mouth as two cars traveling down the road The first gives the direction and the lead time while the latter give more space and lag. How to practice this ? Well:
Mix up your pace - quicker through familiar notes and more deliberate with others
Talk cleanly - the clearer the idea you present the better
When in doubt, stop talking - yes it helps too
Focus on what you want to say, now how it will be received.
Listen more, talk less if you really want to know how things are going.
5) The conviction principle - If you are confident, your message will be carried so. The author says there are three stages of public speaking:
Stage 1) Dread
Stage 2) Tolerance
Stage 3) Enjoyment
and the more you fake enjoyement, the more likely you will get there.
And also under this principle don't copy your colleagues. You want to avoid the cliches, industry speak and oversimplification.
Staying confident in rough conversations - Validate, don't bully, find out a way to agree and point out a strength.
6) The curiosity principle - This principle lets you stay tuned with the impression you are creating. It helps you overcome the mismatch between how you feel inside and how you appear on the outside. The more often you listen with curiosity, the more skilled you will be at reading people.
In reality, the best conversationalists are extremely good listeners. They demonstrate interest, generosity and modesty.
7) The Draper principle - Draper said "If you don't like what's being said, change the conversation". How to do this ? Steer the conversation away from your weaknesses. Get inside your interviewers head. Anticipate the question and line up the Pitch-Pefect triumvirate - the three questions you want to answer  : a) what's my point ? b) How will I illustrate it ? and c) what are the first few words out of my mouth ?
Together these seven principles guarantee the following formula :
Fairness + Honesty + Empathy =  Good Outcome.

Thursday, October 1, 2015

Proof by induction for the Olympiad question described below: 
[Czech and Slovak Republics 1997] 
Each side and diagonal of a regular n-gon (n ≥ 3) is colored blue or green. A move consists of choosing a vertex and switching the color of each segment incident to that vertex (from blue to green or vice versa). Prove that regardless of the initial coloring, it is possible to make the number of blue segments incident to each vertex even by following a sequence of moves. Also show that the final configuration obtained is uniquely determined by the initial coloring. 
In a polyhedron with n vertices, the total number of edges to form a complete graph is N = n(n-1)/2. 
For n=3, this is 3 edges (triangle) 
For n=4, this is 6 edges (four sides and two diagonals in a square) 
For n=5, this is 10 edges (five sides and five diagonals in a pentagon 
Due to symmetry, in all these cases each vertex has equal number of edges incident on it and these are the total number of edges connecting that vertex to the remaining vertex. 
Therefore the possible blue or green to a vertex can be 
(1, N - 1), (2, N-2), (3, N-3) … (N/2, N/2) if N is even or ((N+1)/2 - 1,(N+1)/2) if N is odd  
For each of the configurations we have (odd,even)(odd,odd)(even,odd)and(even,even) 
For (odd,even) we make one move and we can reverse the colors to a case where blue is even. For (even,even) with or without any moves the number remains even. For (odd, odd) we can show that alternate vertices can have (odd,even) leading to an exchange of exactly one edge shared with the (odd,odd) vertex causing it to change into one having odd, even. Note that there can be at most only one (odd,odd) or (even, even) in the set for any N and correspondingly at least one edge different from the rest in color. 
We use the same logic for formal proof by induction. We say let the facts be true for N. With the addition of one more vertex, we now have a configuration set as earlier but with the terminal changing (odd,even) to (odd,odd) or (even,even) and vice versa. 
Therefore the facts hold for N+1. 

#Technology
How do we transfer ownership of Buckets in AWS compatible S3 storage ?
Let us take a look at the ACL we can place on the bucket

$result = $client->putBucketAcl(array(
    'ACL' => 'string',
    'Grants' => array(
        array(
            'Grantee' => array(
                'DisplayName' => 'string',
                'EmailAddress' => 'string',
                'ID' => 'string',
                // Type is required
                'Type' => 'string',
                'URI' => 'string',
            ),
            'Permission' => 'string',
        ),
        // ... repeated
    ),
    'Owner' => array(
        'DisplayName' => 'string',
        'ID' => 'string',
    ),
    // Bucket is required
    'Bucket' => 'string',
    'GrantFullControl' => 'string',
    'GrantRead' => 'string',
    'GrantReadACP' => 'string',
    'GrantWrite' => 'string',
    'GrantWriteACP' => 'string',

));
and all we need are
1)  the canonical ID of the new owner as the Grantee, 
2)  the Permission as 'FULL_CONTROL' and 
3)  the name of the bucket.

The canonical ID can be retrieved as follows:
curl -i -k -u user:pass 'https://s3_endpoint_url\/user?userId=<newowner>&groupId=<team_id>'
which gives data 
 {"active":"true","userType":"GroupAdmin","fullName":"Ravi Rajamani","emailAddr":"rajamani@adobe.com","address1":"","address2":"","city":"Seattle","zip":"","phone":"","website":"","state":"Washington","country":"United States","groupId":"team1","userId":"rajamani","canonicalUserId":"db67c360ed6977kkkkkaf9cb43f9de64"}
and includes the canonical ID.

I tried this out and surprisingly the ACLs don't get applied as intended. On the other hand, the recommended practice is to copy the contents of the bucket from one to the other. 

Wednesday, September 30, 2015

In the previous post we brought up a question as follows:
[Czech and Slovak Republics 1997]
Each side and diagonal of a regular n-gon (n ≥ 3) is colored blue or green. A move consists of choosing a vertex and switching the color of each segment incident to that vertex (from blue to green or vice versa). Prove that regardless of the initial coloring, it is possible to make the number of blue segments incident to each vertex even by following a sequence of moves. Also show that the final configuration obtained is uniquely determined by the initial coloring.
Lets take the four sided square now as n = 4. At each vertex we have two edges and a diagonal incident on it. Let us say the edges are alternatively blue and green and the diagonal is also alternatively blue and green. We again have the same condition that at a vertex, we have a simple majority of one color or all colors the same.and there will be another vertex with the colors switched.
 Let us say the simple majority was green and the number of blue segments to this vertex is odd.
The initial configuration is therefore
X G r e e n Y
G B         G B
r     l       r    l
e       u  e     u
e       e  e     e
n    n       x   x    
Z B  l   u  e W

Where X, Y, Z and W are vertices. As noted earlier vertex X has 1 blue while W has all three blues.
If we make a move at X, the two greens become blue and the diagonal XW becomes green leaving leaving the total count of blues even at any given vertex.
The total number of edges in a square is 4 and with diagonals the count is 6 an even number, the blues and greens can be divided in sets (1,5)(2,4)(3,3). Therefore permitting them to switch the colors at a vertices will not add or subtract the total count but  it can be made even because there will be odd number of vertexes with opposite number of colors. While the initial coloring configuration is unique and the flipping sequence to make the coloring at a vertex even and blue is also unique.
Since we verified for both n = odd and n = even, we can state the same for all n>= 3. Formal proof may be shown by induction method.

Tuesday, September 29, 2015

We conclude the review of the book "Anticipate" with the following summary:
The final part is about our visionary self and how to improve it. 
This section asks you to begin by trying to write your own obituary so that we can gain clarity about our own beliefs and values as a critical step. Another exercise in this way would be to ask a friend to interview you and respond with honest answers. Questions could include say, describe three different situations in which you were truly at the best.  
Then the section asks us to lead by example. Being mindful of these values helps us observe what may have been overlooked.  Another practice is to deliberately break your normal pattern of working, communicating, thinking, reacting or responding. Get radical exposure by engaging with folks who are different from us. And finally try opinion swap such as adopting the opinion of someone you don’t necessarily agree with. 
This is where we use the power of language. We use verbs to carry sentences. We can use a predefined list of verbs that attract attention. Similarly show picture. This evokes imagination and helps them envision a different world.  Also metaphors make the message stick. If you give an example with a metaphor, it’s much easy to relate to. Likewise analogies can be drawn to something that is actionable. If you say you want something to be the ivy league in its industry, it becomes clearer. Finally, stories inspire. They are catchy and heighten our natural curiosity. 

#Olympiad_problem
[Czech and Slovak Republics 1997]
Each side and diagonal of a regular n-gon (n ≥ 3) is colored blue or green. A move consists of choosing a vertex and switching the color of each segment incident to that vertex (from blue to green or vice versa). Prove that regardless of the initial coloring, it is possible to make the number of blue segments incident to each vertex even by following a sequence of moves. Also show that the final configuration obtained is uniquely determined by the initial coloring.

Let us take the example of a triangle. Since there are three vertices a, b and c in a triangle , any vertex has two edges incident on it. It doesn't have any diagonals. If we choose edges ab and ac to be blue and bc to be green as an initial configuration, then b and c don't have any even number of blues.

If we flip the color of edges incident on b, then ab becomes green and bc becomes blue, leading the colors of c to be even and blue.

If instead we flip the color of edges incident on c, the edges of b become both blue.

Since a already had even number of blue edges to begin with, all the vertices of the triangle have each been able to make their incident edges blue.
The total number of edges in a triangle is 3 and because its an odd number, the blues and greens are divided unequally. Therefore permitting them to switch the majority with each move. Futhermore the majority can be even. Lastly all the moves at a vertex can be the same for all the vertices since they are all the same. But the initial coloring configuration is unique and therefore the flipping to make the coloring at a vertex even and blue is also unique.

Monday, September 28, 2015


A book review of Anticipate – by Rob - Jan de Jong.

In order to be successful with a campaign, leaders must have a vision argues Rob-Jan de Jong in his book Anticipate.  Heis a strategy and leadership expert and he says usually a vision is not compelling or one that inspires or energizes their people. Vision is not exclusive to anyone.

To develop vision, one must sharpen two skills – The first is the ability to see things clearly – spotting the first hints of change on the horizon. The second is the power to connect the dots – turning those clues into a gripping story.With these skills, we will be able to frame the big picture, provide a direction and communicate our vision. When we anticipate change before our competitors, we create enormous strategic advantage.

The author leads us into this self-help book with the following structure:

Find the purposes and ingredients of a personal vision

See things clearly and connect the dots

Find core values to develop our vision.

A company’s vision is different from a personal vision. We focus on the latter.  A personal vision improves our leadership abilities because we are exciting the people to look to us for leadership.

Powerful visions have four fundamentals:

A vision shows the path forward: A vision provides guidance and direction to what lays ahead

A vision stretches the imagination: It takes us beyond the obvious to the unknown.

It changes the status quo and breaks through existing paradigms forcing us to tap into unseen opportunities

It energizes and mobilizes by galvanating those we lead.

In order for a vision to be persuasive, it must have emotional and intellectual appeal. When we use our imagination, we lend pathos to our vision so that its more engaging. For example, the idea of a pizza slicer evokes expectations of a speedy delivery, frozen pizzas and specialized utensils. It tethers some ideas for customer satisfaction.

Sometimes we can even use others as an example to think differently. For example, the expression WWGD stands for what-would-google-do? Start by selecting a number of iconic companies that everyone has strong brand association with.

To grow your visionary capacity, we should have the ability to see things clearly – the first signs of change often manifest as random noise or faint warning signals. And second, the ability to connect the dots to frame a bigger picture.

The author mentions categories for where we may stand with respect to these abilities: These are :

Followers, Trend Hoppers, Historians, the visionary etc.  He warns however that we are not trying to predict the future. Instead we are developing an increased awareness to push the future in a direction different from the one we currently see.

The author developed his own technique called a “Future Priming” to help executives improve their ability to see things early. Its about writing our own “FutureFacts” which is a manifestation of a possible changing reality.

And he mentions four simple rules to do this practice:

Scope for relevant and time – it should be just wide enough to include relevant signals.

Don’t make your own company – part of your future fact.

Explore the area between the conventional and the absurd by asking more “what if”

Describe an event not a trend – it may have memorable hooks to news events that transpire.

The second aspect to vision other than seeing things clearly is to connect the dots.

To connect the dots means to frame a coherent story for the path ahead. We should avoid what the author calls as Frame blindness and overconfidence.  He says make uncertainity a part of your vision. Embrace it instead of trying to quell it or to get rid of it.

The final part is about our visionary self and how to improve it.

#codingexercise
Int flip_disks_around_circle(disk disks,  int start, int count){
If start > count  or one_black_left return 0;
If disks [i] .color == black flip_adjacents (i);
Return flip_disks_around_circle (start+1);
}

Sunday, September 27, 2015

In the previous post about the following question:
Let be a positive integer. At each of 2points around a circle we place a disk with one white side and one black side. We may perform the following move: select a black disk, and flip over its two neighbors. Find all initial configurations from which some sequence of such moves leads to a position where all disks but one are white. 
we proved the premise for an algorithm.
Now let us see the steps involved. 
When we select a disk O that is black, we want to convert it to white and proceed to the next one in a given direction say counterclockwise on the circle.
Let us say the neighbors of this selected disk O are X and Y. When we flip X and Y, both could have become black but we can ignore X since we move in the direction of Y leaving X to be the one to satisfy termination condition. O is unchanged and black.
Now Y is black, we proceed flipping, this will make O white while Y's neighbor in the chosen direction say Z could may also become black. Thus O has become white but Y and Z are black.  In order to flip Y we select Z and flip Y and the disk following Z thus making Y white.  This is acceptable since Y and Z are both black. but what if Z is white. In this case both O and Z as Y's neighbors are white and flipping Y would result in undoing what we did with O to begin with. But let us say this undoing O is ok given that Y has now become the new O. In other words we pushed O forward by one position while leaving blacks in our wake. So let us make O black again and Z black.
Now we have X O Y Z black
Now we know that O was not only black disk in the circle otherwise we would not have commenced flipping. Besides we let X be the termination condition should it have become black with our flipping.
Since we will have to skip Y if we don't want to undo O, we might as well have skipped O.
Therefore the only condition in which we can move forward is the configuration in which O and Z are both black.
Moreover since we want the propagation to finish at or before O, the neighbour before X must also be black. In other words,  the configuration where such moves can propagate and leave behind one black is one where black and white alternate.