Monday, August 15, 2016


Steps to join a Linux computer to Active Directory using AD are as follows:
First, the benefits of using SSSD:
  • ·         Reduced load on authentication servers.
  • ·         Option for offline authentication
  • ·         Single user account


Steps:
1)  Make sure that both the Active Directory and Linux systems have a properly configured environment
2)  On the Linux client, add the Active Directory domain to the client's DNS configuration so that it can resolve the domain's SRV records.
Search adserver.example.com
Nameserver 192.168.1.1
3) Set up the linux system as an AD client and enroll it within the AD domain.
   1) set up the kerberos to use AD realm
         1) vim /etc/krb5.conf
         2) configure the logging and libdefaulrs section
              [Logging]
               FILE: /var/logs/krb5libs.log
               [Libdefaults]
               Default_realm=example.com
               Dns_lookup_realm=true
               Dns_lookup_kdc = true
               Ticket_lifetime=24h
               Renew_lifetime=7d
               Rdns = false
               Forwardable = yes
     2) Configure the samba server to connect to AD server
           1) vim /etc/samba/smb.conf
           2) configure [globals]
[global]
workgroup = EXAMPLE
client signing = yes
client use spnego = yes
kerberos method = secrets and
keytab log file = /var/log/samba/%m.log password server = AD.EXAMPLE.COM
realm = EXAMPLE.COM
security = ads

3)  add the linux machine to the AD domain.
Kinit Adninistrator
Net ads join -k
Klist -k

4) configure sssd
[sssd]
 config_file_version = 2
 domains = ad.example.com
 services = nss, pam, pac

Create a new domain section at the bottom of the file for the Active Directory domain. This section has the format domain/NAME, such as domain/ad.example.com. For each provider, set the value to ad, and give the connection information for the specific Active Directory instance to connect to.
[domain/ad.example.com]
 id_provider = ad
 auth_provider = ad
chpass_provider = ad
 access_provider = ad


#codingexercise
Find the maximum width of a binary tree where the width is the count of nodes at a given level
int GetMaxWidth(Node root)
{
int max  = 0;
for (int i =l; i < height(root); i++){
      int count = GetWidth(root, i);
      if (count > max)
           max = count;
}
return root;
}
int GetWidth(Node root, int level)
{
 if (root == null) return 0;
 if (level == 1) return 1;
 if (level > 1){
        return GetWidth(root.left, level -1) + GetWidth(root.right, level-1);
}
return 0;
}

#monty hall problem
 A tv show host gives you the option to open one of three doors behind one of which is a car and the others have goats. You pick a door and the tv show host picks another. His door has goat. Do you want to switch doors ?
Solution to the above problem is that you should switch because the probability that the second door hides the car has increased to 2/3.
Previously, the two remaining doors haf a combined probability of 2/3 but with the hosts choice, that probability has now become entirely that of one unopened door to switch to

An employee works for an employer for 7 days. The employer has a gold rod of 7 units. How does the employer pays to the employee so that the employee gets 1 unit at the end of everyday.The employer can make at most 2 cuts in rod.
Solution : the rod should be cut in 4,2,1 length pieces.

A box contains n coins, of which 7 of them are counterfeit with tails on both sides and the rest are fair coins. If one coin is selected from the bag and tossed, the probability of getting a tail is 17/20. Find the value of ‘n’.
N = 2. Working backwards from the last pèrson.
7/n x 1 + (n-7)/n x 1/2 = 17/20
N = 10 

A boy goes to 20 of his friend’s houses with ‘n’ number of newly purchased marbles in his hands. At every house he visits , he gives away half of marbles he have and take one of his friend’s marble’s and adds it with the one’s he is left with , he never had a problem of dividing an odd number of marbles left and finally after leaving the his 20th friends house, he is left with 2 marbles, can you guess the ‘n’ value?



Steps to join a linux computer to Active Directory using  AD.
Benefits of using SSSD:
Reduced load on authentication servers.
Option for offline authentication
Single user account

Steps:
1)Make sure that both the Active Directory and Linux systems have a properly configured environment
2)
On the Linux client, add the Active Directory domain to the client's DNS configuration so that it can resolve the domain's SRV records.
Search adserver.example.com
Nameserver 192.168.1.1

3)set up the linux system as an AD client and enroll it within the AD domain.
   1) set up the kerberos to use AD realm
         1) vim /etc/krb5.conf

          2) configure the logging and libdefaulrs section 
              [Logging]
               FILE: /var/logs/krb5libs.log
               [Libdefaults]
               Default_realm=example.com
               Dns_lookup_realm=true
               Dns_lookup_kdc = true
               Ticket_lifetime=24h
               Renew_lifetime=7d
               Rdns = false
               Forwardable = yes


Steps to join a linux computer to Active Directory using  AD.
Benefits of using SSSD:
Reduced load on authentication servers.
Option for offline authentication
Single user account

Steps:
1)Make sure that both the Active Directory and Linux systems have a properly configured environment
2)
On the Linux client, add the Active Directory domain to the client's DNS configuration so that it can resolve the domain's SRV records.
Search adserver.example.com
Nameserver 192.168.1.1

3)set up the linux system as an AD client and enroll it within the AD domain.
   1) set up the kerberos to use AD realm
         1) vim /etc/krb5.conf

          2) configure the logging and libdefaulrs section 
              [Logging]
               FILE: /var/logs/krb5libs.log

Sunday, August 14, 2016

Today we continue with a few more puzzles.
 A blind man is handed a deck of 52 cards and told that exactly 10 of these cards are facing up. How can he divide the cards into two piles, not necessarily of equal size, with each pile having the same number of cards facing up?

The blind man splits the cards into two piles of 10 and 42. The pile of ten may have k cards placing up. The pile of 42 may have 10 - k cards. Then he flips over the pile of ten cards so that it has 10 - k face up cards.

A lab test for a disease has an accuracy of 99%. If it tests positive for a disease that affects 1 in 10000, what is the chance that the disease is present.
By Bayes theorem, this is equal to 
P(A/B)P(B) + P(A/ not B) P(not B)
= 0.99 × 0.0001 + 0.01× 0.9999
= 0.01

A and B play a number game. Either of them can start playing. They choos a number between one and ten both inclusive. And increment the choice to the last number uttered. Can A have a winning strategy ?
Yes as long as there is a sum available to reach the destination say 11,  A wins. Working backwards, A starts from 2.

Tom and Jerry race along a circular track. Jerry has a head start of 1/8 before Tom starts. Jerry is at the start when Tom covers 1/6 th. How much faster does Tom need to run to win the race.
Jerry has a head start of 3/24
Jerry covers an additional 7/8 - 1/6 = 17/24
Jerry is faster than Tom by 17/4.
Tom has to move 5/6 while Jerry has to move 1/6
Therefore Tom must travel 5 times faster which is 85/4

A chooses a number between 1 and 10000. B must guess it in as few chances as possible. On each guess B is told whether it is less or more. If B's guess exceeds A's choice two or more times, he loses. What strategy could B have.

B chooses squares. 1, 4,9, 16, ... if the number exceeds once, he goes sequential from the previous square. 

#codingexercise
Find the number of islands in a binary matrix. 
This could be generalized to a connected components in a graph problem.

int GetCountIslands(Int [, ] board, int row, int col)
{
int count = 0;
bool visited = new int[row, col]();
for (int i = 0; i < row; i ++)
    for (int j = 0; j < col; j++)
        if (board[i,j] && !visited(i,j))
         {
           count++;
            DFS(board,row, col, i, j, ref visited);
          }
}
return count;
}

void DFS(int[,] board, int row, int col, int i, int j, ref int[,] visited)
{
  var rows = {-1, -1, -1, 0, 0, 1,1,1};
  var cols = {-1, 0, 1, -1, 1, -1, 0, 1};
  visited[i,j] = true;
  for (int k =0; k < 8; k++)
       if (isSafe(board, i + rows[k], j + cols[k], ref visited))
           DFS(board, row, col, i+rows[k], j+cols[k], ref visited);
}

Find the maximum width of a binary tree where the width is the count of nodes at a given level
int GetMaxWidth(Node root)
{
int max  = 0;
for (int i =l; i < height(root); i++){
      int count = GetWidth(root, i);
      if (count > max)
           max = count;
}
return root;
}
int GetWidth(Node root, int level)
{
 if (root == null) return 0;
 if (level == 1) return 1;
 if (level > 1){
        return GetWidth(root.left, level -1) + GetWidth(root.right, level-1);
}
return 0;
}

Saturday, August 13, 2016

Today we cover some interesting puzzles.
100 people standing in a circle in an order 1 to 100. No. 1 has a sword. He kills the next person (i.e. No. 2) and gives the sword to the next (i.e. No. 3). All people do the same until only 1 survives. Which number survives at the last?
There are 100 people starting from 1 to 100
Solution:
If we start out with an array of 100 numbers labeled 1 to 100 and sorted,
Then in the first round all even numbers are eliminated from the starting point
In the second round, all odd numbers distance four apart are eliminated from the ending point of the previous round. Since even number of elements were removed and this is an even number of rounds, this is the starting point of the first round again.
In the third round, all odd numbers distance eight apart are removed including the number 1. This leaves the starting point as 9. This leaves 9, 25,41,57,73,89.
In the fourth round, all elements distance sixteen are eliminated. This leaves 9, 41, 73.
In the next round all numbers distance 32 are eliminated. This leaves 9, 73.
In the next round all numbers distance 64 are eliminated. This leaves 73.

What is the smallest perfect square which when turned upside down is another perfect square?
The digits which can be turned upside down and still be readable 0,1,6,8,9. The squares with these digits are 1, 9, 16, 81, 100, 169, 196...
The answer is therefore 196


A Police officer caught four criminals. He plays a game with these four men. He lines up three of the prisoners (A, B, C) in one room and the fourth prisoner(D) is placed in a separate room.
Each prisoner is given a hat to wear. The officer tells them that there are in total two blue hats and two red hats. If any of them can guess the color of the hat they are wearing right, he promises to set all four of them free. They cannot communicate with each other, the only information is that

The prisoner A can see the colors of hats worn by prisoner B and prisoner C.
Prisoner B can ONLY see the color of hat worn by prisoner C.
If A sees B and C and if they are wearing the same hat, then he knows the remaining hats and he succeeds.
If he is silent then B can use this information to know that he is wearing a hat different from C, so all hats are known and he escapes.

4) A climber has a stash of chocolates. He climbs five buildings of 100 stairs each and loses one chocolate on every step whether climbing up or down. At the top of each building, he offloads half of his stash. After descending the last building, he has none left. How many did he start with ?
If we start out with an equation in x as the number of chocolates in the beginning, it gets complicated:

((X - (x-100)/2) -100 -100 - (
(X - (x-100)/2) -100 -100)/2) - ... = 0

On the other hand if we start from the end and calculate backwards, we solve it easier
End # = 0
Top of bldg 5 200, bottom of bldg 5 300
Top of bldg 4 800, bottom of bldg 4 900
Top of bldg 3 2000, bottom of building 3 2100,
Top of bldg 2 4400, bottom of bldg 2 4500
Top of bldg 1 9200, bottom of bldg 1 9300

Smoe ideas on Combination Puzzles

Friday, August 12, 2016

Today we continue our discussion of the  paper titled "Pelican: a  building block for exascale cold data storage". Pelican treats a group of disks as a single schedulable unit. Resource restrictions such as power consumption, vibrations and failure domains are expressed as constraints over these units.
With the help of resource constraints and scheduling units, Pelican aims to be better than its over provisioned counterpart racks using computations in software stacks.
We were discussing the evaluation of Pelican and listing out the metrics chosen. To compare the evaluations, a simulator was used in addition to the Pelican hardware rack and the simulator and the rack were cross validated. It was configured in such a way that the prototype Pelican rack hardware matched the simulator. We were discussing the metrics and the Pelican performance against metrics. These included completion time, time to first byte, service time, average request rate and throughput.
The actual throughput of disks in a quiescent system is measured and the simulator is configured with an average throughput of 105 MB/s Seeks are simulated using a constant latency of 4.2ms for all disk accesses. This has negligible effect on performance. Reads are for large blobs with a stripe forming a single contiguous file on disk 
Pelican was compared with an ideal system - one where there is full provisioning of power and cooling, which we denote as FP. In the FP, configuration disks are never spun down, but the same physical internal topology is used as in Pelican. In FP, however, all 48 groups can be accessed concurrently. The maximum queue depth per scheduler for both is set to 1000 requests and the maximum reordering allowance is set to 500 GB. For the cross validation configuration, all four schedulers are run by a single server with one 10 Gbps NIC.  In the rest of the evaluation, the rack has two servers such that the servers such hat each server runs two schedulers.
The first set of experiments measured the base performance of both the systems. The scheduler does poorly with a straw man algorithm but does very well with the Pelican scheduling.
#puzzle
Joey has to arrange 2N sandwiches which are wrapped by different color wrapper in N pairs such that he can feed his N girlfriends (A hypothetical situation it is where we have to ignore the fact “JOEY DOESN’T SHARE FOOD ”). He has to serve them for 2N-1 Days. Girls don’t like repeated pair of color wrapper of their sandwiches.
Design an algorithm for joey so that for 2N-1 days no pair would be same.
Solution: This problem is solved by keeping a 2N table with numbers ranging from 1 to 2N-1. The pairs are given by the column of the table.  Each day all the entries except one are rotated in a clockwise manner ensuring different color wrapper for the girls sandwiches.
2) There was a prison consisting of 1000 cells numbered from 1 to 1000.
Each cell can be marked with ‘+’ or ‘-‘sign. Initially, all cells were marked with ‘-‘ sign.
From days 1 to 1000,the jailor toggles marks on the cell from + to – or vice versa.
On the i-th day ,the signs on cells that are multiples of i get toggled.
Now in the process of verification on 1001-th day, all cells marked with + signs are opened.
Can you identify the cell numbers with ‘+’ sign?
Solution: When we toggle 1000 times we are toggling even number of times. All multiples are formed from odd and even or odd and odd or even and even. And since they are two times odd and even, most multiples will reset back to original state. This is true for almost all multiples except perfect squares. Therefore perfect squares form the answer.
#another puzzle
Two friends A and B play a game with 9 cards lying face up and labeled 1 to 9. They take turns to draw a card and the first person to collect three cards that totals fifteen wins. A is given the first chance to play. Does he have a winning strategy ?
Solution : There are eight subsets that sum up to 15. These are :
{1,5,9}, {2,8,5}, {3,5,7}, {4,5,6}, {1,6,8}, {2,4,9}, {2,7,6} and {3,8,4}
These can be arranged in a magic square as
8 1 6
3 5 7
4 9 2
where the horizontal, vertical and diagonal form the required sum.  Since this is a game of Tic Tac Toe, there is no winning strategy.

Thursday, August 11, 2016

Yesterday we were describing a solution to 15-puzzle using a real time algorithm as described by Ian Parberry
Move_the_blank_to _right_adjacent(di, dj, si, sj) used in the algorithm above is a combination of the following 

1) Move_shaded_tile_one_place_diagonally(di, dj, si, sj, n) // di, dj  => destination, si, sj=> source, n = number of squares on any side 
{ 
GoClockWise(si, sj, n, 4); // Move blank to top left of tile to move 
Swap(si-1,sj-1, si, sj); // exchange tile with blank 
} 

2) Move_shaded_tile_one_place_vertically(di, dj, si, sj, n) // di, dj  => destination, si, sj=> source, n = number of squares on any side 
{ 
GoClockWise(si, sj, n, 3); // Move blank to top left of tile to move 
Swap(si-1,sj, si, sj); // exchange tile with blank 
GoClockWise(si-1,sj, 2); // total five moves 
} 

3) Move_shaded_tile_one_place_horizontally(di, dj, si, sj, n) // di, dj  => destination, si, sj=> source, n = number of squares on any side 
{ 
GoClockWise(si, sj, n, 5); // Move blank to top left of tile to move 
Swap(si,sj-1, si, sj); // exchange tile with blank 
} 

In a way, this algorithm mimics how a human would solve the 15-puzzle.

For example, In order to move a blank to diagonally top left one square, we would do
Move(di, dj, si, sj, n) // di, dj  => destination, si, sj=> source, n = number of squares on any side 
{
Swap(si-1,sj, si, sj);
Swap (si-1,sj-1, si-1,sj);
assert (si-1 == di);
assert(sj-1 == dj);
}