<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ankur Soni</title>
    <description>The latest articles on DEV Community by Ankur Soni (@anksoni).</description>
    <link>https://dev.to/anksoni</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1168856%2F6228ffa4-826d-4066-b368-d7fd019593c5.png</url>
      <title>DEV Community: Ankur Soni</title>
      <link>https://dev.to/anksoni</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anksoni"/>
    <language>en</language>
    <item>
      <title>find the shortest substring in a string c#</title>
      <dc:creator>Ankur Soni</dc:creator>
      <pubDate>Sun, 24 Sep 2023 12:17:12 +0000</pubDate>
      <link>https://dev.to/anksoni/find-the-shortest-substring-in-a-string-c-59kk</link>
      <guid>https://dev.to/anksoni/find-the-shortest-substring-in-a-string-c-59kk</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;static void Main(string[] args)
        {
            Program program = new Program();
            int totalStudent = 3;
            int totalSubject = 5;
            int[,] marks = {{75,76,65,87,87},
                            {78,76,68,56,89},
                            {67,87,78,77,65}};

            string firstString = "this is a test string";
            string secondString = "tist";

            program.Shortest(firstString, secondString);

        }

        public void Shortest(string input1, string input2)
        {
            int minLength = input1.Length;
            string smallestSubstring = string.Empty;

            for (int i = 0; i &amp;lt; input1.Length; i++)
            {
                for(int j = i; j &amp;lt; input1.Length; j++)
                {
                    string substr = input1.Substring(i, j - i + 1);
                    if (ContainsAllCharacters(substr, input2))
                    {
                        int currentLength = substr.Length;
                        if (currentLength &amp;lt; minLength)
                        {
                            minLength = currentLength;
                            smallestSubstring = substr;
                        }
                    }
                }
            }
            Console.WriteLine(smallestSubstring);

        }

        private bool ContainsAllCharacters(string input1, string input2) 
        {
            int[] count = new int[256];

            foreach (char ch in input2)
                count[ch]++;

            foreach (char ch in input1)
            {
                if (count[ch] &amp;gt; 0)
                    count[ch]--;
            }

            foreach (int val in count)
            {
                if (val &amp;gt; 0)
                    return false;
            }

            return true;
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>student subject marks are lowest marks (C#)</title>
      <dc:creator>Ankur Soni</dc:creator>
      <pubDate>Sun, 24 Sep 2023 10:51:07 +0000</pubDate>
      <link>https://dev.to/anksoni/student-subject-marks-are-lowest-marks-c-3anj</link>
      <guid>https://dev.to/anksoni/student-subject-marks-are-lowest-marks-c-3anj</guid>
      <description>&lt;p&gt;&lt;strong&gt;Statement :-&lt;/strong&gt;&lt;br&gt;
Given a list of N students, every student is marked for M subjects. Each student is denoted by an index value. Their teacher Ms. Margaret must ignore the marks of any 1 subject for every student. For this she decides to ignore the subject which has the lowest class average.&lt;br&gt;
Your task is to help her find that subject, calculate the total marks of each student in all the other subjects and then finally return the array of the total marks scored by each student.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Input Specification:&lt;/strong&gt;&lt;br&gt;
input1:&lt;br&gt;
An integer value N denoting number of students&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;input2:&lt;/strong&gt;&lt;br&gt;
An integer value M denoting number of subjects&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;input3:&lt;/strong&gt;&lt;br&gt;
A 2-D integer array of size N'M containing the marks of all students in each subject.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output Specification:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Return an integer array of size N containing the total marks of each student after deducting the score for that one subject.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Answer: *&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;static void Main(string[] args)
        {
            Program program = new Program();
            int totalStudent = 3;
            int totalSubject = 5;
            int[,] marks = {{75,76,65,87,87},
                            {78,76,68,56,89},
                            {67,87,78,77,65}};

            var totalValueArray = program.avgValue(totalStudent, totalSubject, marks);
            foreach (var i in totalValueArray)
            {
                Console.WriteLine(i);
            }
        }
        public int[] avgValue(int input1, int input2, int[,] input3)
        {
            double[] avgSubjectMarks = new double[input2];
            for (int j = 0; j &amp;lt; input2; j++)
            {
                avgSubjectMarks[j] = 0;
                for (int i = 0; i &amp;lt; input1; i++)
                {
                    avgSubjectMarks[j] += input3[i, j];
                }
                avgSubjectMarks[j] = avgSubjectMarks[j] / input1;
            }
            double[] avgSubjectMarksSorted = new double[input2];
            for (int i = 0; i &amp;lt; input2; i++)
            {
                avgSubjectMarksSorted[i] = avgSubjectMarks[i];
            }
            Array.Sort(avgSubjectMarksSorted);
            int shortestSubjectArrayIndex = Array.IndexOf(avgSubjectMarks, avgSubjectMarksSorted[0]);
            int[] result = new int[input1];
            for (int i = 0; i &amp;lt; input1; i++)
            {
                result[i] = 0;
                for (int j = 0; j &amp;lt; input2; j++)
                {
                    if (j != shortestSubjectArrayIndex)
                    {
                        result[i] += input3[i, j];
                    }
                }
            }
            return result;
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
