Sunday, June 19, 2016

#codingexercise
Given an unsorted array, trim the array such that twice of minimum is greater than maximum in the trimmed array. Elements should be removed either end of the array. Print the trimmed Array
int minRemovals(List<int> nums, int start, int end)
{
if (start >= end) return 0;
var selection = nums.GetRange(start, end-start+1);
if (selection.min() * 2 > selection.max()){
   Console.Write(selection.toString());
  return 0;
}
return min( minRemovals(nums, start+1, end), 
                minRemovals(nums, start, end-1));
}

Find the minimum number of coins that make a given value with an infinite supply of each of the values
int getMinCoins(List<int> coins, int V)
{
var minCounts = new int[V+1];
minCounts[0] = 0;
for (int i = 1; i <= V, i++)
    minCounts[i] = INT_MAX;
for (int i =1; i <= V; i++)
{
   for (int j = 0; j < coins.Count; j++)
   {
     if (coins[j] <= i)
     {
          int prev = minCounts[i-coins[j]];
          if (prev != INT_MAX && prev+1 < minCounts[i])
             minCounts[i] = prev + 1;
     }
   } 
}
return minCounts[V];
}

Duplicity is  a backup tool that can read files and folders from different backends. Here is an example to backup VM instances using a backend that can read the image and disk files on the vcenter.
https://github.com/ravibeta/PythonExamples/tree/master/duplicity 


The same techniques can be applied to Openstack because images and volumes are available just as they are from VMWare.

No comments:

Post a Comment