title: The Coursera autograder gives me Unknown Signal 11
body: <p>I'm in a class in Algorithms and now we are taking Greedy Algorithms.
  Two of my solutions output "Uknown Signal 11" on some of the test cases.</p>
  
  <p>However, I drove my program to the limit with the largest inputs possible.
  It works just fine on my PC. However on Coursera's grader, it throws tgghis cryptic message of Unknown Signal 11.</p>
  
  <p>Will this go away if I change to Python for example?</p>
  
  <p>Here's the first code exhibiting the problem: </p>
  
  <pre><code> #include &lt;iostream&gt;
   #include &lt;utility&gt;
   #include &lt;algorithm&gt;
   using namespace std;
  
  bool sortAlg(pair&lt;double, pair&lt;uint64_t,uint64_t&gt;&gt; item1, pair&lt;double, 
  pair&lt;uint64_t,uint64_t&gt;&gt; item2)
  {
  return (item1.first &gt;= item2.first);
  }
  int main()
  {
  uint64_t n, index = 0;
  double W, val;
  cin &gt;&gt; n &gt;&gt; W;
  pair&lt;double, pair&lt;uint64_t,uint64_t&gt;&gt; items[n];
  for (int i=0; i &lt;n; i++)
  {
      cin &gt;&gt; items[i].second.first &gt;&gt; items[i].second.second;
      items[i].first =  (double)items[i].second.first / (double)items[i].second.second;
  }
  sort(items,items+n, sortAlg);
  
  while(W &gt; 0 &amp;&amp; n &gt; 0)
  {
      if (items[index].second.second &lt;= W)
      {
  
          val += items[index].second.first;
          W -= items[index].second.second;
          index++;
          n--;
      }
      else
      {
          val += items[index].first * W;
          W = 0;
          index++;
          n--;
      }
  }
  printf("%.4f",val);
  return 0;
  }
  </code></pre>
  
  <p>I think this has to do with the while loop, but I can't think of anything where the program will make an out of bounds array call using index.</p>
  
  <p>Anyways it is a fractional knapsack implementation.</p>
  
  <p>Here's the second code which also gives unknown signal 11:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include&lt;vector&gt;
  #include &lt;algorithm&gt;
  #include &lt;utility&gt;
  using namespace std;
  
  bool sortAlg(string num1, string num2)
  {
      if (num1[0] &gt; num2[0]) return true;
      else if (num1[0] &lt; num2[0]) return false;
      else
  {
      if (num1.size() == 1 &amp;&amp; (num1[0] &gt; num2[1])) return true;
      else if (num1.size() == 1 &amp;&amp; (num1[0] &lt; num2[1])) return false;
      else if (num2.size() == 1 &amp;&amp; (num1[1] &gt; num2[0])) return true;
      else if (num2.size() == 1 &amp;&amp; (num1[1] &lt; num2[0])) return false;
      else if (num1 == "1000" || num2 == "1000") return (num1 &lt; num2);
      else
      {
          if (num1.size() == num2.size()) return (num1 &gt; num2);
          else
          {
              return (num1[1] &gt; num2[1]);
          }
      }
  }
  }
  
  int main()
  {
  string num;
  int n, n2 = 1;
  cin &gt;&gt; n;
  //int numbers[n];
  vector&lt;string&gt; numbers2;
  for (int i =0; i &lt;n; i++)
  {
      num = to_string(n2);
      cout &lt;&lt; num &lt;&lt; endl;
      numbers2.push_back(num);
      n2 += 10;
  }
  sort(numbers2.begin(), numbers2.end(), sortAlg);
  
  for (auto number : numbers2)
  {
      cout &lt;&lt; number;
  }
  return 0;
  }
  </code></pre>
  
  <p>I suspect the sortAlg function used in sort function, but on my PC it is relatively fast. And the problem statement required some weird sorting.</p>
  
  <p>The problem was given a set of numbers, arrange them to make thebiggest number possible.</p>
  
  <p>If given 9, 98, 2, 23, 21 for example it should give me 99823221.
  (9 > 98 > 23 > 2 > 21)
  So I sort by the first digit then the next and so on.</p>