    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: Report on Challenge 2</title>
        <link>https://members.accu.org/index.php/articles/2474</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>




<div class="xar-mod-head"><span class="xar-mod-title">CVu Journal Vol 30, #1 - March 2018</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="https://members.accu.org/index.php/articles/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c76/">Journals</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c77/">CVu</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c383/">301</a>
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;Report on Challenge 2</h1>
<p><strong>Author:</strong>&nbsp;Bob Schmidt</p>
<p>
<strong>Date:</strong> 02 March 2018 15:47:19 +00:00 or Fri, 02 March 2018 15:47:19 +00:00</p>
<p><strong>Summary:</strong>&nbsp;Francis Glassborow presents the answers to his last challenge and gives us a new one.</p>
<p><strong>Body:</strong>&nbsp;<p class="EditorIntro">There was a gratifyingly varied set of solutions offered. Some were ingenious and surprised me. Here are the ones I received together with my comments. At the end you will find my decision as to the â€˜winnerâ€™ along with my next challenge.</p>

<h2>From Alex Kumaila</h2>

<pre class="programlisting">
// Casting to long to avoid assigning a sum that is
// larger than the max signed integer, to a signed
// integer.
long sumInts(const int x, const int y){
  return (long)x + (long)y;
}

void add(const int a, const int b, long *const c){
  if(a&lt;0 &amp;&amp; b&lt;0) { // Both negative,

                   // therefore decrement.
    do {
      (*c)--;
    } while(*c &gt; sumInts(a,b));
  } else if((a&lt;0 &amp;&amp; b&gt;0)||(a&gt;0 &amp;&amp; b&lt;0)) {
// Different signs, therefore decrement to the 
// negative value, and then increment to the 
// positive.
    do {
      (*c)--;
    } while(*c &gt; std::min(a,b)); 
// min(a,b) returns the negative value, 
// given the above predicate.
    do {
      (*c)++;
    } while(*c &lt; sumInts(a,b));
  } else {
// Both positive, including both zero, 
// therefore increment.
    while(*c &lt; sumInts(a,b)){
      (*c)++;
    };
  }
}

int main() {
  static long c;
//Static long initialises to zero.
//Test cases assuming a 4 byte signed integer.
std::cout 
  &lt;&lt; &quot;Integer size on repl.it (should be 4): &quot;
  &lt;&lt; sizeof(int) &lt;&lt; &quot;\n&quot;;
//endl doesn't appear to work on repl.it
  add(0,0,&amp;c);
std::cout &lt;&lt; &quot;Both zero: &quot; &lt;&lt; c &lt;&lt; &quot;\n&quot;;
  add(1,2,&amp;c);
std::cout &lt;&lt; &quot;Sum of two small (+ve) numbers: &quot;
&lt;&lt; c &lt;&lt; &quot;\n&quot;;
  add(-2147483647,-2147483647,&amp;c);
std::cout &lt;&lt; &quot;Both lower (-ve) bound: &quot; &lt;&lt; c 
  &lt;&lt; &quot;\n&quot;;
  add(2147483647,2147483647,&amp;c);
std::cout &lt;&lt; &quot;Both upper (+ve) bound: &quot; &lt;&lt; c 
  &lt;&lt; &quot;\n&quot;;
  add(-2147483647,2147483647,&amp;c);
std::cout 
  &lt;&lt; &quot;Different signs at lower/upper bound: &quot;
  &lt;&lt; c &lt;&lt; &quot;\n&quot;;
  add(2147483647,-2147483647,&amp;c);
std::cout 
  &lt;&lt; &quot;Different signs at upper/lower bound: &quot;
  &lt;&lt; c &lt;&lt; &quot;\n&quot;;
}</pre>

<p class="EditorIntro"><strong>FG:</strong> The odd reference to <em>repl.it</em> is because the code is loaded there so that you can test it. The link is https://repl.it/repls/WideeyedRepulsiveHoatzin. I leave it to the reader to discover what a Hoatzin is (there really is such a beast).</p>

<p class="EditorIntro"><strong>FG: </strong>The code in <code>main</code> tests several corner cases as well as one straight forward addition.</p>

<p class="EditorIntro"><strong>FG: </strong>As you can see, this solution is a pure solution that avoids any form of assignment though that is rather severe (and was not intended). It also results in rather long run times for large absolute values of the operands.</p>

<p class="EditorIntro">Note that the basic solution will work in C if the output lines are rewritten to use <code>printf</code>.</p>

<p class="EditorIntro"><strong>FG: </strong>However, the code can have undefined behaviour on any platform where <code>int</code> and <code>long</code> have the same range (allowed by the standard)</p>

<h2>From Silas Brown</h2>

<p>Hi Francis, please find a response below.</p>

<p>Thanks.</p>

<p>Silas</p>

<p class="EditorIntro"><strong>FG:</strong> A great pleasure to see a contribution from you. (For readers who do not know, Silas joined ACCU whilst he was still at school and served as our disabilities officer for many years.)</p>

<p>One obvious way to do assignment without <code>=</code> is to use constructors in C++:</p>

<pre class="programlisting">
  #include &lt;iostream&gt;
  using namespace std;
  int main() {
    int a(1),b(2);
    int c(a+b);
    cout &lt;&lt; c &lt;&lt; endl;
  }</pre>
  
<p>Apart from that, C++ before C++17 also supports <code>or_eq</code> as a â€˜trigraphâ€™ [<em>
<strong>FG:</strong> No, that is an alternative token, not a trigraph</em>] for <code>|=</code>, which Iâ€™m not sure should qualify for the challenge, because itâ€™s technically the same as using <code>|=</code>, itâ€™s just representing it differently in the source file:</p>
 
<pre class="programlisting">
  static int c;
  c or_eq (a+b);</pre>
  
<p class="EditorIntro"><strong>FG:</strong> Using the alternative tokens is fine and is one of the solutions I expected someone would come up with. These are still valid in C++ 17. What has been removed is the trigraphs. Those were a ghastly fix C invented to deal with some keyboards that lacked some keys for characters C uses. I heard one person opine that it would have been cheaper to give them all new keyboards than the cost of supporting those rarely used alternatives.</p>

<p>This relies on <code>static</code> being initialised to <code>0</code> by default. Without the <code>static</code>, it might work anyway but this is not guaranteed (and it also might result in reformatting your hard drive). The above will not work if the code is called more than once in the same program, unless you first clear <code>c</code> by calling <code>memset()</code> or similar.</p>

<p class="EditorIntro"><strong>FG:</strong> Actually you can set a variable to zero by using <code>xor_eq</code> (<code>a xor_eq a</code> will set <code>a</code> to zero). The problem is that you need to initialise variables before use or suffer the potential for undefined behaviour. Static and global variables get default initialised to zero.</p>

<p class="EditorIntro"><strong>FG: </strong>Note that what had to be avoided was the <code>=</code> symbol.</p>

<p>In C, you could use simple counting, but itâ€™s inefficient and it destroys the values of <code>a</code> and <code>b</code>:</p>

<pre class="programlisting">
  #include &lt;stdio.h&gt;
  int main() {
    static int a, b, c;
    a++; b++; b++;  /* so a is 1 and b is 2 */


    /* addition starts here;
       we assume a and b are both &gt; 0 */
    while (a--) c++;
    while (b--) c++;

    printf(&quot;%d\n&quot;,c);
  }</pre>
  
<p>(The same considerations as above apply re the use of <code>static</code>.)</p>

<p>But I very much prefer a method that does not deconstruct the addition into increments and decrements. You didnâ€™t say if we can use any standard libraries for the addition code; there are two approaches there that spring to mind. One is <code>memset()</code> which Iâ€™ve already alluded to: if we are dealing with small numbers that fit into a <code>char</code>, then itâ€™s trivial:</p>

<pre class="programlisting">
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  int main() {
    char a, b, c;
    memset(&amp;a, 1, 1);
    memset(&amp;b, 2, 1);
    memset(&amp;c,a+b,1);
    printf(&quot;%d\n&quot;,c);
  }</pre>
  
<p>But you never said the integers wonâ€™t overflow the bounds of <code>char</code>. We could extend the above to larger numbers if we know how the platform represents integers, e.g. on a 32-bit little-endian system:</p>

<pre class="programlisting">
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  int main() {
    int a,b,c;
    /* ... set a and b ... */
    memset(&amp;c,(a+b)&amp;0xFF,1);
    memset(((char*)(&amp;c))+1,((a+b)&gt;&gt;8)&amp;0xFF,1);
    memset(((char*)(&amp;c))+2,((a+b)&gt;&gt;16)&amp;0xFF,1);
    memset(((char*)(&amp;c))+3,((a+b)&gt;&gt;24)&amp;0xFF,1);
    printf(&quot;%d\n&quot;,c);
  }</pre>
  
<p>But I donâ€™t like introducing this dependency on the underlying hardware, nor repeating the addition so much (although an optimising compiler would likely re-use the intermediate result).</p>
<p>The other â€˜standard libraryâ€™ approach that springs to mind is using <code>sprintf</code> and <code>sscanf</code>:</p>

<pre class="programlisting">
  #include &lt;stdio.h&gt;
  int main() {
    int a,b,c;
    sscanf(&quot;1&quot;,&quot;%d&quot;,&amp;a);
    sscanf(&quot;2&quot;,&quot;%d&quot;,&amp;b);

    char buf[22]; /* sufficient for 64-bit */

    sprintf(buf,&quot;%d&quot;,a+b);
    sscanf(buf,&quot;%d&quot;,&amp;c);

    printf(&quot;%d\n&quot;,c);
  }</pre>
  
<p>But that has the disadvantage of converting to and from a string at runtime (not quite as bad as the counting approach, but not as fast as the C++ solutions).</p>

<p>Finally I have a â€˜cheatâ€™ answer, which is to write the C file in the UTF-7 character set, which (similar to the <code>or_eq</code> trigraph) lets you write <code>= </code>without using the <code>'='</code> byte:</p>

<pre class="programlisting">
  +ACM include +ADw stdio.h +AD4
  int main() +AHs
    int a +AD0 1 +ADs
    int b +AD0 2 +ADs
    int c +ADs
    c +AD0 a +- b +ADs
    printf ( +ACIAJQ-d+AFw-n+ACI, c) +Ads
  +AH0</pre>
  
<p>This can be compiled with GCC using the <code>-finput-charset=UTF-7</code> option [<strong>FG:</strong><em> Oh! Dear! You can write it but not compile it without using the 
<code>=</code> key</em>] but only if your GCC has been compiled with the <em>iconv</em> library (which is not the case as standard on every GNU/Linux distribution), and itâ€™s certainly not Standard C, so it ought to be disqualified.</p>

<p class="EditorIntro"><strong>FG:</strong> I had wondered about whether something along the lines of your last solution was possible. Thanks for demonstrating that it is, at least using GCC.</p>

<p>Incidentally, this kind of challenge now has a real application in computer museums. For example, the Computing History Museum at Cambridge has a BBC Micro with a broken â€˜Fâ€™ key. Well, you could exploit a bug in its operating system to program all 10 of its extra function keys to â€˜Fâ€™ in just 12 keystrokes (type !2832=17937 and press Return), but other machines from the era didnâ€™t have function keys, and if you want to do a live programming demonstration on a restored mainframe with a terminal from the period, itâ€™s entirely possible youâ€™ll have to work around certain keys not working on its keyboard.</p>

<p class="EditorIntro"><strong>FG:</strong> Thank you Silas for a comprehensive set of solutions as well as a reason that one might actually need to do something like this (apart from doing exam questions from the dawn of computing)</p>

<h2>From Hubert Mathews</h2>

<p>Assigning the sum of two integer variables to a third variable without using <code>=</code> is easy in languages that donâ€™t use <code>=</code> for assignment. For instance in R:</p>

<pre class="programlisting">
  a &lt;- 10 
  b &lt;- 25 
  c &lt;- a+b 
  sprintf(&quot;%d + %d is %d&quot;, a, b, c) </pre>
  
<p>or even in COBOL:</p>

<pre class="programlisting">
  IDENTIFICATION DIVISION.
  PROGRAM-ID. HELLO-WORLD.
  DATA DIVISION.
    WORKING-STORAGE SECTION.
      77 A PIC 99.
      77 B PIC 99.
      77 C PIC 99.
  PROCEDURE DIVISION.
    SET A TO 10.
    SET B TO 25.
    ADD A B GIVING C.
    DISPLAY A &quot; + &quot; B &quot; IS &quot; C.
  STOP RUN.</pre>
  
<p>C++ has ways of initialising variables without using <code>=</code>, specifically using direct initialisation (either the C++98 version with parentheses or the C++11 uniform initialisation syntax with braces):</p>

<pre class="programlisting">
  #include &lt;iostream&gt;
  int main()
  {
    int a(10);
    int b(25);
    int c(a+b);
    std::cout &lt;&lt; a &lt;&lt; &quot; + &quot; &lt;&lt; b &lt;&lt; &quot; is &quot;
              &lt;&lt; c &lt;&lt; std::endl;
  }</pre>
  
<p>Since these examples use facilities built into the language it hardly seems worth writing tests for them.</p>

<p>Things get more interesting for languages like C that have no obvious way of initialising variables without <code>=</code>:</p>

<pre class="programlisting">
  #include &lt;assert.h&gt;
  #include &lt;string.h&gt;
  #define SET_VALUE(x, value)       \
    memset(&amp;x, 0, sizeof((x)));     \
    while ((x) &lt; (value)) (x)++;    \
    while ((x) &gt; (value)) (x)--;
  int main()
  {
    int a, b, c;
    SET_VALUE(a, -4);
    SET_VALUE(b, 7);
    SET_VALUE(c, a+b);
    printf(&quot;%d + %d is %d\n&quot;, a, b, c);
    assert(!(a &lt; -4) &amp;&amp; !(a &gt; -4));
    assert(!(b &lt; 7) &amp;&amp; !(b &gt; 7));
    assert(!(c &lt; 3) &amp;&amp; !(c &gt; 3));
    assert(!(a+b &lt; c) &amp;&amp; !(a+b &gt; c));
    return 0;
  }</pre>
  
<p>This sort of code definitely requires tests as it is easy to get wrong. Tests without using <code>=</code> are even more fun and the above code uses the same technique as used by C++â€™s <code>std::map</code> for determining equality (not less than and not greater than). Using a macro means that thereâ€™s no need to worry about accessibility of variables as there would be if using a function.</p>

<p>Which leads to the contortions that are necessary when trying the same in Java:</p>

<pre class="programlisting">
  public class Add {
    int a, b, c;
    public void calculate() {
      while (a &lt; 6) a++;
      while (a &gt; 6) a--;
      while (b &lt; 7) b++;
      while (b &gt; 7) b--;
      while (c &lt; a+b) c++;
      while (c &gt; a+b) c--;
      System.out.println(String.format(
        &quot;%d + %d is %d&quot;, a, b, c));
      assert !(a &lt; 6) &amp;&amp; !(a &gt; 6);
      assert !(b &lt; 7) &amp;&amp; !(b &gt; 7);
      assert !(c &lt; a+b) &amp;&amp; !(c &gt; a+b);
    }
    public static void main(String... args) {
      new Add().calculate();
    }
  }</pre>
  
<p>The variables have to be fields in order that they will be initialised to zero.  There is no obvious way of encapsulating the initialisation code into a function as <code>int</code>s are primitives and are passed and returned by value in Java, thus requiring an assignment and so an equals sign. Using boxed <code>java.lang.Integer</code> instead doesnâ€™t help as that would still require an assignment statement.</p>

<p class="EditorIntro"><strong>FG:</strong> Thanks for the language tour. I have to confess that I do not understand the Java solution.</p>

<h2>From Pete Disdale</h2>

<p>Hello Francis,</p>

<p>I will be very interested to see the â€˜several simple solutionsâ€™ to this challenge â€“ I have thought a fair bit about this and can come up with no more than 3 using only C! And of those, only 1 is a â€˜pureâ€™ solution inasmuch as the other 2 likely depend on <code>=</code> somewhere inside the library code. I also excluded <code>asm { .... }</code> code as itâ€™s not in the spirit of the challenge (and itâ€™s not C/C++ either). Perhaps there are more â€˜simpleâ€™ solutions in C++?</p>

<p>Please see the attached <span class="filename">test.c</span>: <code>add1()</code> takes advantage of <code>sscanf</code> by storing the result in an <code>int*</code>, <code>add2()</code> is the â€˜pureâ€™ C solution and works because there is no mandate to initialise a variable before use (bad, of course!) and <code>add3()</code> requires a support function, <code>foo()</code>.</p>

<p>Out of curiosity, I compiled this with and without optimisation, and whilst I was pleasantly reassured that the expression (a + b) was cached in the optimised code, I was really impressed that the optimiser had completely optimised away the call to <code>memcpy()</code> in <code>foo()</code>! The plain version (expected) is:</p>

<pre class="programlisting">
  _foo:    pushl    %ebp
    movl    %esp, %ebp
    subl    $24, %esp
    movl    $4, 8(%esp)
    leal    8(%ebp), %eax
    movl    %eax, 4(%esp)
    movl    12(%ebp), %eax
    movl    %eax, (%esp)
    call    _memcpy
    leave 
    ret</pre>
	
<p>whilst the optimised version is:</p>

<pre class="programlisting">
  _foo:    pushl    %ebp
    movl    %esp, %ebp
    movl    8(%ebp), %edx
    movl    12(%ebp), %eax
    movl    %edx, (%eax)
    popl    %ebp
    ret</pre>
	
<p>(This with a fairly ancient version of gcc too.)</p>

<p>I look forward to reading all the other contributions in the next CVu.</p>

<p>ps. did anybody manage to find a single solution using Java? </p>

<p><span class="filename">  test.c</span></p>

<pre class="programlisting">
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;

  int add1(int, int);
  int add2(int, int);
  int add3(int, int);

  int main (int argc, char *argv[])
  {
    /* int a, b; unused */
    if (argc &gt; 2)
    {
      printf (&quot;add1(%s, %s) gives %d\n&quot;, argv[1],
        argv[2], add1 (atoi (argv[1]), 
        atoi (argv[2])));
      printf (&quot;add2(%s, %s) gives %d\n&quot;, argv[1],
        argv[2], add2 (atoi (argv[1]), 
        atoi (argv[2])));
      printf (&quot;add3(%s, %s) gives %d\n&quot;, argv[1],
        argv[2], add3 (atoi (argv[1]), 
        atoi (argv[2])));
    }
    return 0;
  }
  int add1 (int a, int b)
  {   /* use hex for fixed length string, 

         2 chars per byte, no Â±, plus 1 for '\0' */

    char s[sizeof(int)*2 + 1];
    int c;
    
    snprintf (s, sizeof(s), &quot;%x&quot;, a + b);
    sscanf (s, &quot;%x&quot;, &amp;c);
    
    return c;
  }
  int add2 (int a, int b)
  {
    int c;
    
    if (c &gt; a + b)
        while (--c &gt; a + b);
    else if (c &lt; a + b)
        while (++c &lt; a + b);
    return c;
  }
  void foo (int x, int *y)
  {
    // memmove ((unsigned char *) y,
    //(unsigned char *) &amp;x, sizeof(int));
    memcpy (y, &amp;x, sizeof(int));
  }
  int add3 (int a, int b)
  {
    int c;
    foo (a + b, &amp;c);
    return c;
  }</pre>
  
<p class="EditorIntro"><strong>FG:</strong> It is amazing what modern optimisers are able to do. With a bit of AI perhaps we can get them to rewrite our entire code to run more efficiently even if the resulting source code is completely incomprehensible to humans. Just joking (or am I?)</p>

<h2>From James Holland</h2>

<p>Francis uses the word â€˜assignâ€™ and so I assume initialisation doesnâ€™t count. Thatâ€™s a pity because statements something like <code>int c{a + b}</code> would fit the bill. Furthermore, when Francis says â€œ<em>without using the </em> <code>=</code><em> symbol</em>â€, I assume I canâ€™t use <code>|=</code> and its like. This is also a pity because I could have used two statements such as <code>c ^= c; c |= a + b;</code> to assign the sum of <code>a</code> and <code>b</code> to <code>c</code>. This gives me an idea, however. I could use the C++ â€˜alternative tokensâ€™.</p>

<pre class="programlisting">
  c xor_eq c;
  c or_eq a + b;
  c xor_eq ~c;
  c and_eq a + b;</pre>
  
<p>There are other ways of assigning the sum to the variable without using the <code>=</code> symbol, some more useful than others. We can ask the computer user for help.</p>

<pre class="programlisting">
  while (a + b - c)
  {
    std::cout 
      &lt;&lt; &quot;Please type the number followed by Enter&quot;
      &lt;&lt; a + b &lt;&lt; ' ';
    std::cin &gt;&gt; c;
  }</pre>
  
<p>Possibly not the most efficient method but at least the result can be checked. Instead of using a person, letâ€™s use the file system.</p>

<pre class="programlisting">
  std::ofstream out_file(&quot;file.dat&quot;);
  out_file &lt;&lt; a + b;
  out_file.close();
  std::ifstream in_file(&quot;file.dat&quot;);
  in_file &gt;&gt; c;</pre>
  
<p>This is an improvement over the previous attempt, but we need not use the file system. We can use a string stream.</p>

<pre class="programlisting">
  std::stringstream ss;
  ss &lt;&lt; a + b;
  ss &gt;&gt; c;</pre>
  
<p>Another way is to make use of <code>sscanf()</code> as shown below.</p>

<pre class="programlisting">
  std::string s(std::to_string(a + b));
  sscanf(s.c_str(), &quot;%d&quot;, &amp;c);</pre>
  
<p>Perhaps we could keep incrementing the variable until it becomes the required value. This could take quite a while for a variable with a large number of bits!</p>

<pre class="programlisting">
  while (a + b - c) ++c;</pre>
  
<p>Lastly, many of the standard library algorithms can be persuaded to do the job as well.</p>

<pre class="programlisting">
  int d{a + b};
  std::swap(c, d);
  
  std::fill(&amp;c, &amp;c + 1, a + b);
  
  std::fill_n(&amp;c, 1, a + b);
  
  int d{a + b};
  std::copy(&amp;d, &amp;d + 1, &amp;c);
  
  std::generate(&amp;c, &amp;c + 1, [a, b](){
    return a + b;});
  
  std::iota(&amp;c, &amp;c + 1, a + b);</pre>
  
<p class="EditorIntro"><strong>FG:</strong> I am not sure that any of these are more in the spirit of assignment without using an equals sign than just the simple <code>int c{a+b};</code>.</p>

<p class="EditorIntro">That said it is remarkable how many standard library functions can be subverted into storing the result of <code>a+b</code> in <code>c</code>.</p>

<h2>The Winner isâ€¦</h2>

<p>Well I am stuck because each of the entrants have strong positives.</p>

<ul>
	<li>Alex took time to consider the corner cases and write a test to ensure they worked and then placed the test where anyone can see that it works.</li>
	<li>Silas walked us through several solutions and then added a motivation for this kind of problem.</li>
	<li>Hubert gave us a language tour and even provided a solution for Java.</li>
	<li>Pete demonstrated that optimisers can produce something respectable even when our code is pretty crude.</li>
	<li>James offered us a smorgasbord of ways to achieve our objective and actually came up with an effective solution without using initialisation.</li>
</ul>

<p>So which do you like best? I am going to cheat (like James, asking the user to provide the answer) and ask you, the reader to email me with your choice. I will publish the voting figures in my next Challenge column.</p>

<h2>Challenge 3</h2>

<p>Here is an old problem that might just be new to some of you. Write a program that outputs its own source code. Please attempt this in C++. There are two categories of solution:</p>

<ol>
	<li>A solution that will run on your computer</li>
	<li>A solution that will run on my computer.</li>
</ol>

<p>In each case you are allowed to use standard library functions but everything but the output directed to a file must compile to produce the same executable. The first should be easy; the second may prove more challenging.</p>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
