Monday, April 24, 2017

This article is a continuation of some more stories on Software Engineering incidents as shared here:
6) Got sick – Hackers let loose virus and other malware programs for the general public to run on their computers but none was more widespread as the Blaster virus which proved a wake up call for Microsoft.  The blaster was so named because it set a registry key with the “msblast.exe” so that it launched everytime Windows starts.
7) Data too -  Following close on heel to Windows, SQL Server was also affected by the Slammer worm. The Slammer worm is a computer worm that caused denial of service on some hosts and slowed down the general traffic. It exploited a buffer overflow bug in Microsoft SQL Server.
8) Cascading failure – Networks are formed by interconnected nodes that talk to one another. As nodes start failing, it might proceed progressively to take the network down. Internet happens to be a network and ISPs are responsible for the bulk of the traffic to route through this network. Many ISPs have experienced outages when their edge routers failed.
9)What’s in a date – The Year 2000 problem was  a computer bug that related to how date was stored where the four digit year was abbreviated to the last two digits and rollover to 2000 meant the clock was reset to 1900.Companies worldwide anticipated and moved quickly to prempt a widespread failure and were large successful.

10) for a Penny – Pennies are very small amount in transactions worldwide and are often rounded resulting in either money gained or lost. When the rounding is done to make a profit and repeated endlessly, it can amount to quite a substantial sum. This may even be noticeable to the human eyes but it is certainly not when the transactions happen between computers and in the background by code that does validation which may be rigged. To the gasoline industry however, the pennies may be very important. In fact gasoline has been sold at a price that ends with 9/10ths of a cent, with retailers rounding up the cost of a gallon to the next penny. But even this is sufficient for the oil industry to rake in millions of dollars in extra profit each month.
#codingexercise
Find the count of numbers formed by subsequences of the digits of a given number n that are greater than a given value m
Void  Combine(List<int> digits, int m, ref List<int> b, int start, int level,  ref List<List<int>> combinations)  
{  
for (int I =start; I < digits.length; I++)  
{   
  if (b.contains(digits[i])== false){  
    b[level] = digits[i];  

    combinations.Add(b);
    if (I < digits.length)  
        Combine(ref digits, ref b, m, start+1, level+1, ref combinations);  
    b[level] = 0;  
}
}

int CountSubsequencesWithValueGreaterThanM(List<int>digits, int m)
{
var b = new List<int>();
digts.ForEach(X => b.Add(0));
int start = 0;
int level = 0;
var combinations = new List<List<int>>();
Combine(digits, m, ref b, start, level, ref combinations);
int count = 0;
var permutations = new List<List<int>>();
Combinations.forEach(x => {
      int i = 0;
      var used = new bool[x.Count];
      var candidate = new List<int>();
      Permute(x, ref candidate, ref used,  ref permutations);
 });
permutations.ForEach(x => {
  if (x.value > m)
     count++;
}
return count;

}

No comments:

Post a Comment