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. 

Saturday, September 26, 2015

[Japan 1998] 
Let n be a positive integer. At each of 2n points 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. 

If we can find a move that progressively converts one disk after the other to the desirable color, then we can go around the circle and stop at the one with the black. Why do we want a progression because we are only allowed to select one disk at a time and our goal is to ensure the same snd state configuration all around the circle. Moreover, if we are able to achieve a progression, then we don't have to concern the direction we traverse around the circle or the number of times we go around the circle, reassuring ourselves that each disk can be visited and tested.

Also note that while the question asks for all initial configuration, we can generalize it to saying if we can tackle one with an arbitrary number of disks that we can select to perform flips, then the strategy of using a progression will work for any number of such disks, in this case, black disks, around the circle.

Finally the termination condition is given by the fact that we stop short when there is only one black disk around the circle. If we had started out with all white, then there are no moves possible and would not contribute to the end goal, hence our assumption that there are arbitrary number of black disks around the circle to begin with holds true.

With the initial condition established, the progression required and the same final goal, we have the premise for an algorithm that can steadily decrease the number of blacks around the circle proving that such an algorithm will work.

All that the algorithm needs to focus on now is to make sure that each disk traversed in one direction  around the circle is flipped to white if it is not already white and stopping when there is only one black.

Friday, September 25, 2015


[Origin unknown]

Given 2n points in the plane with no three collinear, show that it is possible to pair them up in such a way that the n line segments joining paired points do not intersect.

Since the n line segments joining the paired points are not intersecting, let us draw n horizontal lines. They could be n vertical lines too but we pick horizontal so that it is easier to visualize.

Next assume that the linear segments are of equal lengths, then we have all the n points on one side collinear and all their paired counterpart also collinear.  This forms a ladder.

Since the points are not supposed to be collinear, we increase the distance between each pair gradually as we go up from the bottom of the n pairs to the top leading to a two divergent curves that are narrower at the bottom and flared up at the top. We can adjust the shape of the curve depending by evenly distributing the range between the n-points. If the curves flare up too apart, they tend to form semicircles. Instead we take the curves as divergent quarter circles and then space the n points on them.

Clearly we can picture the solution so the proof exists.

[Russia 2005]

100 people from 25 countries, four from each country, sit in a circle. Prove that one may partition them onto 4 groups in such way that no two countrymen, nor two neighboring people in the circle, are in the same group.

If no two countrymen are in the same group, then they are each in each group. That means that each group has one member for each country. Therefore all the four groups are identical

Now we arrange the four groups one after the other as a quarter circle to form a circle, no two countrymen are in the same group. However, no two neighboring people in the circle should be in the same group.

Assume that each group consists of members 1 through 25  where each number belongs to a country.

Then we interleave twelve from one group with twelve from a reversed group and leave the number 13 from one group at one end.

1 14 2 15 …12 25 13

Now we can create another similar group with the remaining halves and ending with 1 and 13.

We can do the same for the other two groups as we did with this pair. Now the ends of the semi-circles will be 1 and 13 for the group pairs

Now we connect the two pairs into a circle with the 1 and the 13 together thus leading to a solution.

Wednesday, September 23, 2015

[Bulgaria 2001] 

Problem: Given a permutation of the numbers 1, 2, …, n, one may interchange two consecutive blocks to obtain a new permutation. For instance, 3 5 4 8 9 7 2 1 6 can be transformed to 3 9 7 2 5 4 8 1 6 by swapping the consecutive blocks 5 4 8 and 9 7 2. Find the least number of changes required to change n, n-1, n-2, …, 1 to 1, 2, …, n
Solution: One way to do this would be to 
take the tail of the given descending series and start the block swapping
For eg. seq = 4321
Iteration 1: From tail, block size = 2 ^ 0 = 1
     4321
-> 4312
Interation 2 From tail, block size = 2 ^ 1 = 2
-> 1243
-> -> Repeated nested Iteration 1 1234
Similarly for 87654321
Iteration 3,  From tail, block size = 2 ^ 2 = 4
we start from above 87651234
-> Then we would get 12348765
->-> Repeat nested iteration 1 12348756
->-> ->Repeat nested iteration 2 12345678

This works well for even numbers. For odd numbers we would have one digit on the left still remaining to move over to the last. Therefore we will have to additionally swap it with one number each to the right until the last

Note that we are not able to apply the increasing subsequence dynamic programming to the above. That technique relies on the presence of an increasing subsequence in the given permutation so that those elements that participate in the increasing subsequence need not be moved at all and can remain in their positions while the others are exchanged to arrive in sequence with them.  In the above, every element is not at the  position it should be in and therefore has to move. Hence the minimum number of moves must be the length of the given sequence - 0 since there are no elements in increasing subsequence. But we are allowed to move as part of blocks. So we do this in a greedy way
The number initially moves by itself but after the first swap, it becomes part of an increasing sequence and hops the number of elements equal to the length of its current block.
Since the blocks can be formed only with the exchange of two adjacent sub-blocks, each hop is a multiple of two. This gives an increasing sequence of block lengths to hop and reduces the number of linear individual moves to the correct position.
The last element that remains is however a single element on the left that has to move all the way to the right when the sequence is odd. For this the last element the block size is unfortunately one and has to exchange positions with at most one element.

The total number of moves for any element is therefore a logarithm of the length of the sequence of elements

[Russia Olympiad 1961]
Real numbers are written in an m × n table. It is permissible to reverse the signs of all the numbers in any row or column. Prove that after a number of these operations, we can make the sum of the numbers along each line (row or column) nonnegative.

Real numbers can be positive, negative or just about any number that is not imaginary or hold special meaning such as infinity.

We make the following observations:
1) Note that the size of the board is not a square. So the conclusion doesn't depend on the size of the rows or the columns to be equal. In other words, the sum of the elements along each line can be assumed far greater than any one element.

2)When we pick a row and reverse its sign, one cell of all column changes sign. After this turn, each column sum still remains positive because the sum of the elements of the other cells is still positive
If we repeat this operation twice, the cells are returned to their original sign leaving the sum positive.
The same holds true if we substitute the column for the row in above. Even if the values changing sign is the largest in their respective orthogonal lines, the sum along these lines does not change sign from 1) above
So any number of operations on the same line does not alter the sign of the sum of the numbers along each line.

3)When a row or a column is picked alternatively and reversed once there is only one element that returns to the sign of its original. If the same row and column is reversed again and again only the sign of this element changes to negative. If we repeat this N times for this row or column pair, the sum will be greater than zero when N is even.

4) When we pick different rows incrementally and flip their signs, the sum of the numbers along each line becomes negative but as we do a number of these operations, the rows wraparound and we have all the rows positive again

5) when all the rows and columns both change , after every alternate turn at most 2m elements such as from the diagonals  will have flipped their sign unfavorably where m > n. Therefore, we will have the board again favorably 

Tuesday, September 22, 2015

A marker is placed at the origin of an integer lattice. Calvin and Hobbes play the following game. Calvin starts the game and each of them takes turns alternatively. At each turn, one can choose two (not necessarily distinct) integers a and b, neither of which was chosen earlier by any player and move the marker by a units in the horizontal direction and b units in the vertical direction. Hobbes wins if the marker is back at the origin any time after the first turn. Determine whether Calvin can prevent Hobbes from winning. 

Here Hobbes can return to the origin at any time by 'undoing' the displacements from the origin.
Suppose Calvin can moves include (a,b), followed by (-c,-d) by Hobbes and (e,f) by Calvin again . Then Hobbes can move back to the origin by (a+e-c, b+f-d).
We observe the following:
 1) the Hobbes tries to move back towards origin while Calvin tries to move away.
 2) none of the moves repeat that is a, e, c are all distinct and so are b, d, f
 3) for every positive move that Calvin makes, there is a negative move that Hobbes can make which is distinct and non-repeating. Hence the origin is a P-Position. A P-position is one where the player who has just played can force a win. A position is called an N-position if the player whose turn it is can force a win and Hobbes uses it to his advantage. Therefore Calvin must find a P position other than the origin.
 4) when the moves are strictly horizontal or strictly vertical, Hobbes cannot reset back to the origin because one of the co-ordinates is 0 and it will have to be repeated to get back to the P-position.
Therefore Calvin can find P-positions by either moving horizontally only or vertically only
For example, Calvin can move (1,0) in the first move and Hobbes is forced to move  in the vertical direction, say (-1, -1), then Calvin can undo the vertical direction by flipping the marker to the opposite side with (2,-2) In other words Calvin forces two of the diagonals to be P-positions and maintains his moves to these diagonals with non-repeating numbers.
5) Since the numbers are incrementing by 1 and Calvin uses up both the positive and negative of the same integer, Calvin has a winning strategy.
6) the axes can be the players N positions since moving to the axes can let them use the diagonal.
7) once both players arrive at the diagonal they can remain on the diagonal  by alternating