Wednesday, October 7, 2015

[IMO Shortlist 2013, C3] 
A crazy physicist discovered a new kind of particle which he called an imon. Some pairs of imons in the lab can be entangled, and each imon can participate in many entanglement relations. The physicist has found a way to perform the following two kinds of operations with these particles, one operation at a time. 
(i) If some imon is entangled with an odd number of other imons in the lab, then the physicist can destroy it. 
(ii) At any moment, he may double the whole family of imons in the lab by creating a copy I’ of each imon I. During this procedure, the two copies I’ and J’ become entangled if and only if the original imons I and J are entangled, and each copy I’ becomes entangled with its original imon I; no other entanglements occur or disappear at this moment.  
Show that after a finite number of operations, he can ensure that no pair of particles is entangled. 

The imons and their cloning are better visualized with a  data structure that represents the entanglements and the imons. We therefore use a graph with vertices as imons and edges as entanglements. Further, in order to differentiate every imon, we color them each differently. From graph coloring we know that a graph with n vertices can be colored with n colors so that every two connected vertices have different colors. 
Now if we could reduce these colors to just one it would mean a graph with no  edges – our desired goal. 
In other words, our strategy is to assume a graph G that admits proper coloring for n colors so that no two connected vertices have different colors and then show that a sequence of operations can result in a graph which admits coloring of n-1.  
To show this we do the following: 
We repeatedly apply operation 1 to any appropriate vertices  until there are no more. This  reduces the number of vertices and results in a graph with all even edges. Since this is a subset, it will still honor a proper coloring in n colors. We fix the colorings. 
Now we apply the second operation to the graph. This doubles the vertices but now we can still color them differently using n colors because for the new vertices around an original vertex of color k,  we color them with  k+1 mod n. The original vertices have different colors. Their clones also have different colors from the original now. Furthermore between the clones the coloring will be different because n > 1.  And finally all the vertices have now od d number of edges. Therefore those vertices that have the color n can now be destroyed leaving the graph with coloring in n – 1 colors. 
When we repeatedly reduce the colors with the above strategy, we are left with vertices and no edges as required. 
#codingexercise
Print count of headers listed in a file

#include "stdafx.h"
#include "stdio.h"
#include "string.h"

static int Hash (const char * pSrc, size_t len);

int main(int argc, char* argv[])
{
static const char filename[] = "foo.txt";

static const int MAX_COUNT = 255;

static int frequency[MAX_COUNT] = {0};

FILE* fd = fopen(filename, "r");

if ( fd != NULL )
{
char line[MAX_COUNT + 1];

while ( fgets(line, sizeof line, fd) != NULL )
{
char* p = strchr(line, ':');

if (p != NULL)
{
frequency[Hash(_strlwr(line), (size_t)(p-line))%MAX_COUNT] += 1;
}
}

fclose(fd);

char header[MAX_COUNT + 1] = {0};

printf( "Enter the header:\n " );

scanf("%255s", header);

header[MAX_COUNT] = '\0';

printf( "%s occurs %d times.\n", header, frequency[Hash(_strlwr(header), strlen(_strlwr(header)))%MAX_COUNT] );
}

return 0;
}

static int Hash (const char * pSrc, size_t len)
{
  size_t res = 0;

  while (len--) res = (res << 1) ^ *pSrc++;

  return (int)res;
}


If we want to print all headers by sorted order, we could do something like this:
#dirty
typedef struct _headers {
char header[MAX_COUNT+1];
int hash;
int frequency;
} headers;
int comp (const header * elem1, const header * elem2)
{
    int f = elem1->frequency;
    int s = elem2->frequency;
    if (f > s) return  1;
    if (f < s) return -1;
    return 0;
}
int main(int argc, char* argv[])
{
    headers* x  = (header*) malloc(MAX_COUNT * sizeof(headers));
    memset((void*)x, 0, sizeof headers);
    
    qsort (x, sizeof(x)/sizeof(*x), sizeof(*x), comp);

    for (int i = 0 ; i < MAX_COUNT ; i++){
        headers[i] = malloc(sizeof(struct headers));
        // populate header and frequency
    }
    qsort (x, sizeof(x)/sizeof(*x), sizeof(*x), comp);
    // print headers encountered in sorted order
    for (int i = 0 ; i < MAX_COUNT ; i++){
        if (x[i]){
           printf("%s",x[i]->header);
        }
    }     
    return 0;

}

Tuesday, October 6, 2015

[Bulgaria 2005]

For positive integers t, a, b, a (t, a, b)-game is a two player game defined by the following rules. Initially, the number t is written on a blackboard. In his first move, the first player replaces t with either t – a or t – b. Then, the second player subtracts either a or b from this number, and writes the result on the blackboard, erasing the old number. After this, the first player once again erases either a or b from the number written on the blackboard, and so on. The player who first reaches a negative number loses the game. Prove that there exist infinitely many values of t for which the first player has a winning strategy for all pairs (a, b) with (a + b) = 2005.

Note that the players subtract a or b from the given number so if they were to alternate the number would keep reducing by 2005 each time. Its easy for any player to know whether the number substracted was a or b because the previous number and the new number are both on the board one after the other. The winning player has to ensure that the number reduces by 2005 by alternating a or b as per the previous move of the opponent.

In other words, if the winning player has a strategy for x then he has a winning strategy for x + 2005k
Since k can be a multiple of 2005, there are infinitely many numbers possible for this player with the above winning strategy.

The players reduce the numbers by a or b so ultimately there is a value v1 or v2 possible before the number becomes negative. Every other number on the board is therefore a multiple of v1 + a , v1 + b, v1 + a+ b or v2 +a , v2 + b and v2 +a + b.

If it is v2, we call it a favorable position and the first player wins for v2. we say that the strategy works for him.

If it is v1 then the first player. he will win only if v1 +a + b = v2 and v1+a and v1+b are not favorable but that means v1 + a - b and v1 + b - a are favorable but that means v1 + a and v1 + b are favorable which is a contradiction.

Monday, October 5, 2015

C6 BGR (Bulgaria)
On a 999x 999 board a limp rook can move in the following way: From any square it can move
to any of its adjacent squares, i.e. a square having a common side with it, and every move
must be a turn, i.e. the directions of any two consecutive moves must be perpendicular. A non-
intersecting route of the limp rook consists of a sequence of pairwise di fferent squares that the
limp rook can visit in that order by an admissible sequence of moves. Such a non-intersecting
route is called cyclic, if the limp rook can, after reaching the last square of the route, move
directly to the fi rst square of the route and start over.
How many squares does the longest possible cyclic, non-intersecting route of a limp rook
visit?

Let us color the cells with four colors A, B, C and D in the following way
for (i,j) equivalent to (0,0) mod 2 use A
for (i,j) equivalent to (0,1) mod 2 use B
for (i,j) equivalent to (1,0) mod 2 use C
for (i,j) equivalent to (1,1) mod 2 use D

From an A-cell, the rook has to visit a B-cell or a C-cell. In the first case, the order of the colors of the cells visited is given by A, B, D, C, A, B, D, C ... and in the second case the order is given by A, D, B, A, C, D, B ... Since the route is closed it must contain the same number of cells of each color.
There are only 499^2 A-cells.It can be shown that the rook cannot visit all A cells on its route and hence the maximum possible number of cells in a route is 4( 499 ^2 -1). The four squares deducted from the total happen to be the four corners of the board.

Assume that the route passes through every single A cell. Color the A cells in black and white in a chessboard manner. A cells that are two cells apart are different colors. Since the number of A cells is odd, the rook cannot always alternate between black and white A cells. Let the two A cells of the same color which are four rook steps apart be (a,b) and (a+2, b+2) respectively.

There is only one path to take between these two squares. Let this path be (a,b), (a,b+1), (a+1,b+1), (a+1,b+2) and (a+2,b+2) we can say (a,b+1) is B otherwise we can interchange the rows and columns to be such that it is B.
Now let us look at the A cell vertically above which is (a,b+2) The only way the rook passes through it is via (a-1,b+2), (a,b+2) and(a,b+3) in this order. Hence to connect these two parts of the path, there must be  a path connecting the cell (a,b+3) and (a,b) and also a path connecting (a+2,b+2) and (a-1,b+2)
But these are opposite vertices of a quadrilateral and paths are outside so they must interesect. But an intersection is only possible if a cell is visited twice and this is a contradiction.
Hence the number of cells must be at most 4. (499^2 -1)

Sunday, October 4, 2015

[IMO Shortlist 2009, C1] 
Consider 2009 cards, each having one gold side and one black side, lying on parallel on a long table. Initially all cards show their gold sides. Two players, standing by the same long side of the table, play a game with alternating moves. Each move consists of choosing a block of 50 consecutive cards, the leftmost of which is showing gold, and turning them all over, so those which showed gold now show black and vice versa. The last player who can make a legal move wins. 
a) Does the game necessarily end? 
b) Does there exist a winning strategy for the starting player? 
If the players start from left, their set of flipped cards don't overlap and they can take turns to reach 2000. During each turn 50 more cards are converted to black starting from the left. After that the player turning the remaining nine cards wins. Since 50 * 40 = 2000, the player starting first has a wining strategy and wins. This method and outcome assumes that none of the cards flipped once already are flipped again. Even if the non-starting player choose to play from the right or overlaps the cards he plays with the ones he played earlier, the starting player has pushed the leftmost possible card towards the right and reduced the window to play in and since he is left with turning the nine cards wherever they may occur, he can win. 
If the game is played from right to left, the player going first converts fifty cards from the right to black. The player going second can undo almost all of this except one by choosing just one more card to the left of this fifty and converting them back to gold again. The first card on the right is now black and left out as the game progresses towards the left.In a subsequent move, the second card from the right which is now gold is left out as the fifty cards to its left are flipped. Thus the game inches one by one to the left, leaving a trail of alternate black and gold. Since there are odd number of cards to begin with there are odd number of moves possible. After each odd number of moves, the player who doesn't start first always finds a gold card to make a move. Therefore this player always win and the starting player doesn't.
Note there is an official answer that there is no winning strategy for the starting player. This we have shown is not necessarily the case because it does not consider the starting player to play from the left.
The official answer however does prove that the game will end by saying that each card can have two states only and so they represent a binary notation of 2009 1s or 0s  and this number reduces on each move. If 0s represent black and leading 0s are allowed and because a black card is a final state in that it cannot be used to start a move, each move decreases the current number and therefore the game must end.
Since there are forty turns minimum, we can reduce the game to playing the forty cards without any consecutive cards to be flipped.
#codingexercise
Flip_gold_and_black_cards(ref Cards[] cards)
{
var index = get_first_gold_card_from_left(ref cards);
flip_next_fifty_cards_at(ref cards, index);
}
int get_first_gold_card_from_left(ref cards)
{
for (int I=0; I <cards.length; I++)
     if (cards[I].color == gold) return I;
return cards.length;
}
void flip_next_fifty_cards_at(ref cards, int start)
{
for (int I = start; I < cards.length; I++)
  cards[I]. color = cards[I].color == gold ? black:gold;
}
}
#BookReview
We review the book "The Responsible Entrepreneur" written by Carol Sanford.
She introduces us to the entrepreneur who is responsible - a special breed who challenge and refine cultural assumptions, laws and regulations and even the process of governance. As Kevin Jones, founder of SoCap said, this book is about being courageous and in fact he dares the readers to read and implement the bold useful advice.
Let us take a look at what Carol means by Responsible Entrepreneurs and what they achieve. She says these entrepreneurs are required to do and think far beyond what is usually required of business leaders. The Responsible Entrepreneurs offers us this 'blueprint'. By understanding the archetype  most aligned with their goals, entrepreneurs will learn how to grow their business and even change the game.
In this book she includes the following:
Some extraordinary people have changed the game for the better.
How modern archetypes are altering the future.
Why new measures of accomplishment are based on the success of the whole.

She says such entrepreneurs have the courage to take on what they don't yet know how to do and the dedication to build the capability to do it. These entrepreneurs are driven by the realization that the society and the planet need something big from them and that, if they don't rise to the challenge, the work may not get done.
Entrepreneuralism is about personal agency and the development of the will. While entrepreneurs are inventing new products, industries, sources of capital and models of enterprise, the responsible entrepreneurs are doing that and more because they want to create the right platform and support an ecosystem.  They run successful business while deeply caring about the innovation that can not only help them secure their business but also transform the world.
They enjoy developing the acumen needed to work on all parts of the business.
They maintain their own motivation, getting stimulus, training and innovation when they need it. They hold a positive attitude.
They are willing to take on big challenges that stretch them beyond what they currently know how to do and to ride the roller coaster of needing to continually rise to the occassion.
They tend to focus the game changing aspirations in one of four distinct domains
Industries - where the work is to disrupt and replace the automatic patterns
Social systems - where the work is to move upstream to the causes of social problems and address them at their source.
Cultural paradigms - where the enhance the belief systems into something more holistic and embracing
Foundational agreements - where the work is to renew and vitalize the deeper intention behind the governing documents, such as a corporate charter.

From these four domains she draws parallels to four archetypes
Warrior - The warrior protects the values of a community. In the business world, this work takes place within the industry.
Clown - The clown pokes fun at collective self-centeredness and unconsciousness, opening space for humility and heartfelt appreciation of others.
Hunter - The hunter perpetuates life by strengthening the mutual exchange between the tribe and the natural world.
Headman - The headman awakens the individuals to their potential and inspires them to work with others in order to contribute to something larger than themselves.

The four archetypes are all necessary to the healthy functioning of the society. In fact if any one of them is missing, the society becomes vulnerable.

To the entreprenueur, these archetypes translate into four unique roles as follows:
The warrior who changes an industry is the realization entrepreneur. He is driven by the vision of an improved reality.
The clown who changes social systems is the reconnection entrepreneur. She reveals the gap in our cognition regarding the impact of existing social systems
The hunter who changes cultural paradigms is the reciprocity entrepreneur. She tries to strike a balance between what is taken and what is given.
The headman or headwoman who changes the connection to foundation agreements is the regenerative entrepreneur.  She seeks to reveal and evolve the inherent potential of founding agreements that create the accepted structures within which the society operates.

The four roles do different work. For each of them the author takes examples and the principles or pillars that they operate on. 

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.