Magic Square – IEEXtreme 8.0


Johnny designed a magic square (square of numbers with the same sum for all rows, columns and diagonals i.e. both the main diagonal – meaning the diagonal that leads from the top-left corner towards bottom-right corner – and the antidiagonal – meaning the diagonal that leads from top-right corner towards bottom-left corner). Write a program to test it.

Write a program that will check if the given square is magic (i.e. has the same sum for all rows, columns and diagonals).

Continue reading “Magic Square – IEEXtreme 8.0”

Sum It Up – IEEXtreme 8.0


Minka is very smart kid who recently started learning computer programming.
His coach gave him a cyclic array A having N numbers, and he has to perform Q operations on this array.
In each operation the coach would provide him with a number X. After each operation, every element of the cyclic array would be replaced by the sum of itself and the element lying X positions behind it in the cyclic array. All these replacements take place simultaneously.
For example, if the cyclic array was [a, b, c, d], then after the operation with X = 1, the new array would be [a+d, b+a, c+b, d+c].
He needs to output the sum of the elements of the final array modulus 10^9+7.
He made a program for it but it’s not very efficient. You know he is a beginner, so he wants you to make an efficient program for this task because he doesn’t want to disappoint his coach.

Continue reading “Sum It Up – IEEXtreme 8.0”

Back to Square 1 – IEEEXtreme 8.0

The game “Back to Square 1” is played on a board that has n squares in a row and n-1 probabilities. Players take turns playing. On their first turn, a player advances to square 1.After the first turn, if a player is on square i , the player advances to square i + 1 with probability p(i) , and returns to square 1 with probability 1-p(i) .The player is finished upon reaching square n .


Write a program that determines the expected number of turns needed for a player to reach the final square.For example, consider the board below with n = 3 and p(1) = 0.5 and p(2) = 0.25. A player moves to square 1 on their first turn. With probability p(1) , they move to square 2 on their second turn, but with probability 1- p(1) , they remain on square 1. If they were lucky and made it to square 2 on their second turn, they advance to square 3 on their third turn with probability p(2) , but they would go back to square 1 with probability 1- p(2) . Thus, a really lucky player could finish is 3 turns. However, on average, it would take 13 turns for a player to make it to square 3.


Continue reading “Back to Square 1 – IEEEXtreme 8.0”

Configuring Network for Solaris 11 in Virtual Box

Hi all, recently I tried Solaris for some tasks at work. Installing Solaris on VirtualBox was not so difficult and there were quite a few resources in the internet. I used the following.

However for configuring the network it was not the same. So here I will note down a few things which I believe might be useful when configuring network for Solaris 11 in Virtual Box.

In Solaris 11 configuring network is not editing few files, unlike in most other operating systems. There are a set of commands we can to create those configurations for us.

We will go through configuring NAT, HostOnly and Bridged Adaptors. First we have to go to Setting for the Solaris VM in VirtualBox and from there to the Network Tab.
Even though eventually we will add three network adaptors, I suggest we start by enabling only one adaptor as it might be hard to figure out which is which inside Solaris one we enable several network adaptors at once and try to configure them inside Solaris.

Continue reading “Configuring Network for Solaris 11 in Virtual Box”