    <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  :: The Model Student: A Game of Six Integers (Part 3)</title>
        <link>https://members.accu.org/index.php/articles/1635</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">Design of applications and programs + Overload Journal #97 - June 2010</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/c13/">Topics</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c67/">Design</a>
<br />

                                            <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/c78/">Overload</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c271/">97</a>
<br />

                                            <a href="https://members.accu.org/index.php/articles/c67-271/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/articles/c67+271/">All of these categories</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;The Model Student: A Game of Six Integers (Part 3)</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 13 June 2010 19:56:00 +01:00 or Sun, 13 June 2010 19:56:00 +01:00</p>
<p><strong>Summary:</strong>&nbsp;We now have the tools to analyse the Countdown Numbers Game. Richard Harris is ready to play.</p>
<p><strong>Body:</strong>&nbsp;<p>In the first part of this article we described the numbers game from that Methuselah of TV quiz shows, Countdown [<a href="#Countdown">Countdown</a>]. The rules of this game are that one of a pair of contestants chooses 6 numbers from a set of 4 large numbers and another of 20 small numbers, comprised respectively of the integers 25, 50, 75 and 100 and 2 of each of the integers from 1 to 10.
  </p><p> 
    Over the course of 30 seconds both contestants attempt to discover a formula using the 4 arithmetic operations of addition, subtraction, multiplication and division and, no more than once, each of the 6 integers that results in a randomly generated target between 1 and 999 that has no non-integer intermediate values.
  </p><h2>
    Reverse Polish Notation
  </h2><p> 
    Since we shall need to automatically generate formulae during any statistical analysis of the property of this game, we introduced Reverse Polish Notation, or RPN. Supremely well suited to computational processing, RPN places operators after the arguments to which they are applied, rather than between them as does the more familiar infix notation.
  </p><p> 
    RPN utilises a stack to keep track of intermediate values during the processing of a formula and in doing so removes the need for parentheses to determine the order in which operators should be applied. Whenever a number appears in the input sequence it is pushed on to the stack and whenever an operator appears it pops its arguments off of the stack and pushes its result back on to it.
  </p><h2>
    Formula templates
  </h2><p> 
    To simplify the enumeration of the set of possible formula, we introduced formula templates in which arguments are represented by <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">x</span> symbols and operators by <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">o</span> symbols. We described a scheme for recursively generating every possible formula template for up to a given number of arguments by repeatedly replacing <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">x</span> symbols with the sequence of symbols <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">xxo</span>.
  </p><p> 
    The declaration of our C++ implementation of this scheme (the <tt class="code">all_templates</tt> function) is:
  </p>
<pre class="programlisting">
      std::set&lt;std::string&gt; all_templates(  
         size_t arguments);  
</pre><p> 
    We concluded the first part of this article by implementing a mechanism with which we could evaluate formula template for a given set of operators and arguments.
  </p><p> 
    We began by implementing an abstract base class to represent arbitrary RPN operators for a given type of argument, as illustrated in listing 1 together with the declarations of the 4 operator classes that are derived from it.
  </p><p> 
<table class="sidebartable"><tr><td><pre class="programlisting">
template&lt;class T&gt;  
    class rpn_operator  
    {  
    public:  
      typedef   
         std::stack&lt;std::vector&lt;T&gt; &gt;  stack_type;  
      virtual ~rpn_operator();  
      virtual bool apply(stack_type &amp;stack) const = 0;  
    };  
    template&lt;class T&gt; class rpn_add;  
    template&lt;class T&gt; class rpn_subtract;  
    template&lt;class T&gt; class rpn_multiply;  
    template&lt;class T&gt; class rpn_divide;  
</pre></td></tr><tr><td class="title">Listing 1</td></tr></table>
  </p><p> 
    Note that the return value of the <tt class="code">apply</tt> member function indicates whether the result of the calculation has a valid value.
  </p><p> 
    The implementation of the <tt class="code">rpn_divide</tt> class is illustrated in listing 2. The remaining operators are implemented in much the same way, although divide is the only one that needs to check the validity, rather than just the availability, of its arguments and can therefore return <tt class="code">false</tt> from its <tt class="code">apply</tt> method. Specifically, it requires that for double arguments the second must not be equal to 0 and that for <tt class="code">long</tt> arguments it must also wholly divide the first.
  </p><p> 
<table class="sidebartable"><tr><td><pre class="programlisting">
template&lt;class T&gt;  
    class rpn_divide : public rpn_operator&lt;T&gt;  
    {  
    public:  
      virtual bool apply(stack_type &amp;stack) const;  
    };
</pre></td></tr><tr><td class="title">Listing 2</td></tr></table>
  </p><p> 
    Note that the operator classes themselves are responsible for checking that the correct number of arguments are available, since this allows us to implement operators taking any number of arguments, should we so desire.
  </p><p> 
    We then implemented the <tt class="code">rpn_result </tt>structure to represent both the validity and the value of the result of a formula, as illustrated in listing 3.
  </p><p> 
<table class="sidebartable"><tr><td><pre class="programlisting">
template&lt;class T&gt;  
    struct rpn_result  
    {  
      rpn_result();  
      explicit rpn_result(const T &amp;t);  
      bool valid;  
      T    value;  
    };  
</pre></td></tr><tr><td class="title">Listing 3</td></tr></table>
  </p><p> 
    Finally, we implemented a function that, given a <tt class="code">string</tt> representing a formula template, a container of pointers to <tt class="code">rpn_operator</tt> base classes and a container of arguments, yields the result of the formula generated by substituting the operators and arguments in sequence into the template. We plumped for the rather unimaginative name, <tt class="code">rpn_evaluate</tt>, whose declaration is illustrated in listing 4.
  </p><p> 
<table class="sidebartable"><tr><td><pre class="programlisting">
template&lt;class T&gt;  
    rpn_result&lt;T&gt;  
    rpn_evaluate(const std::string &amp;formula,  
                 const std::vector&lt;rpn_operator&lt;T&gt;  
                 const *&gt; &amp;operators,  
                 const std::vector&lt;T&gt; &amp;arguments);
</pre></td></tr><tr><td class="title">Listing 4</td></tr></table>
  </p><h2>
    Evaluating every formula for a given template
  </h2><p> 
    To examine the results of every possible formula in the Countdown numbers game we shall need to call the <tt class="code">rpn_evaluate</tt> function for every one of the templates we have for up to 6 arguments with every possible set of operators and arguments. Recalling the formula we deduced for the total number of possible formulae
  </p>
  <p>
  <img src="/content/images/journals/ol97/Overload%20WW%20XML%20and%20CSS-5-1-02.gif"/>
  </p>
  <p> 
    we concluded that we would need a mechanism of enumerating, for each <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">n</span> argument template, the 4<span style="  font-style: italic; font-weight: normal; vertical-align: super">n</span><span style="  font-style: normal; font-weight: normal; vertical-align: super">-1</span> choices of operators and the <span style="  font-style: normal; font-weight: normal; vertical-align: super">6</span><span style="  font-style: italic; font-weight: normal; vertical-align: baseline">P</span><span style="  font-style: italic; font-weight: normal; vertical-align: sub">n</span> permutations of arguments in addition to a mechanism for enumerating the <span style="  font-style: normal; font-weight: normal; vertical-align: super">24</span><span style="  font-style: italic; font-weight: normal; vertical-align: baseline">C</span><span style="  font-style: normal; font-weight: normal; vertical-align: sub">6</span> combinations of 6 from the 24 available numbers.
  </p><p> 
    You will no doubt recall that a permutation is the number of ways we can select a subset of elements from a set when order is important and that a combination is the number of ways that we can select such a subset when order <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">isn't</span> important.
  </p><p> 
    In the second part of this article we sought these mechanisms.
  </p><p> 
    Fortunately for us, we created the first of them during our study of knots [<a href="#Harris08">Harris08</a>]. The declaration of the <tt class="code">next_state</tt> function that enumerates every possible state of a collection of integer-like objects is given below:
  </p>
<pre class="programlisting">
      template&lt;class BidIt, class T&gt;  
      bool  
      next_stateFidIt first, BidIt last, const T &amp;ub,  
         const T &amp;lb = T());  
</pre><p> 
    Since the <tt class="code">next_state</tt> function is only applicable to iterator ranges of integer-like objects, we shall ultimately need to place our 4 operators in a container and use this function in conjunction with iterators ranging over it.
  </p><p> 
    Generating the set of permutations was a little more complicated since the standard <tt class="code">next_permutation</tt> function does not generate permutations of subsets. Fortunately, however, we were able to exploit the fact that it generates full sets of permutations in lexicographical order to trick it into generating permutations of subsets for us by reverse sorting the elements from <tt class="code">mid</tt> to <tt class="code">last</tt>. Our <tt class="code">next_permutation</tt> function enumerated the set of permutations of <tt class="code">mid</tt>-<tt class="code">first</tt> from <tt class="code">last</tt>-<tt class="code">first</tt> items in lexicographical order.
  </p>
<pre class="programlisting">
      template&lt;class BidIt&gt;  
      bool  
      next_permutation(BidIt first, BidIt mid,  
         BidIt last);  
</pre><p> 
    We then, rather tediously I suspect, devised our own algorithm for enumerating combinations in lexicographical order and finally, slightly less tediously I hope, implementing it. The declaration of the <tt class="code">next_combination</tt> function in which we implemented our algorithm is provided below.
  </p>
<pre class="programlisting">
      template&lt;class BidIt&gt;  
      bool  
      next_combination(BidIt first, BidIt mid,  
                       BidIt last);  
</pre><h2>
    Putting it all together again
  </h2><p> 
    We concluded by implementing a function to iterate over every possible numbers game and pass their results to a statistics gathering function. We first needed some functions to convert between the sequences of values and iterators that our <tt class="code">rpn_evaluate</tt> and argument and operator choice enumeration functions expected, as declared in listing 5.
  </p><p> 
<table class="sidebartable"><tr><td><pre class="programlisting">
template&lt;class FwdIt&gt; void  
    fill_iterator_vector(FwdIt first, FwdIt last,  
                         std::vector&lt;FwdIt&gt; &amp;vec);  
 
    template&lt;class FwdIt, class T&gt;  
    void  
    fill_dereference_vector(FwdIt first, FwdIt last,  
                            std::vector&lt;T&gt; &amp;vec);
</pre></td></tr><tr><td class="title">Listing 5</td></tr></table>
  </p><p> 
    We built the function to enumerate the possible games in two parts, the first of which iterated through the combinations of selections of numbers to work with, and the second of which iterated through every possible game that can be played with those numbers. The declarations of these two functions are illustrated in listing 6.
  </p><p> 
<table class="sidebartable"><tr><td><pre class="programlisting">
template&lt;class BidIt, class Fun&gt;  
    Fun  
    for_each_numbers_game(BidIt first, BidIt last,  
       size_t args, Fun f);  
    template&lt;class BidIt, class Fun&gt;  
    Fun  
    for_each_numbers_game(BidIt first_number_choice,  
       BidIt last_number_choice, Fun f);
</pre></td></tr><tr><td class="title">Listing 6</td></tr></table>
  </p><p> 
    We concluded that we were finally ready to begin analysing number games and we are indeed ready to do so.
  </p><h2>
    Counting the number of valid games
  </h2><p> 
    Since the Countdown numbers game does not allow fractions, our formula for counting the number of formulae is going to overestimate the total number of valid games. I'm reasonably confident that I won't be able to derive an explicit formula to take this into account, so propose instead that we count them using our <tt class="code">for_each_numbers_game</tt> functions.
  </p><p> 
    Recall that our calculation implied that the number of formulae that could be constructed from 6 arguments chosen from 24 numbers was equal to 4,531,228,985,976, somewhat larger than can be represented by a 32 bit unsigned integer. We shall therefore recruit our <tt class="code">accumulator</tt> class from our analysis of prime factorisations of integers [<a href="#Harris09">Harris09</a>], given again in listing 7
  </p><p> 
<table class="sidebartable"><tr><td><pre class="programlisting">
class accumulator  
    {  
    public:  
      accumulator();  
      accumulator &amp; operator+=(unsigned long n);  
      operator double() const;  
 
    private:  
      std::vector&lt;unsigned long&gt; n_;  
    };  
 
    accumulator::accumulator() : sum_(1, 0)  
    {  
    }  
 
    accumulator &amp;  
    accumulator::operator+=(unsigned long n)  
    {  
      assert(!sum_.empty());  
      sum_.front() += n;  
      if(sum_.front()&lt;n)  
      {  
        std::vector&lt;unsigned long&gt;::iterator first =  
           sum_.begin();  
        std::vector&lt;unsigned long&gt;::iterator last  =  
           sum_.end();  
        while(++first!=last &amp;&amp; ++*first==0);  
        if(first==last)  sum_.push_back(1);  
      }  
      return *this;  
    }
</pre></td></tr><tr><td class="title">Listing 7</td></tr></table>
  </p><p> 
    To check whether the result of an in-place addition requires additional storage we exploit the fact that in C++ unsigned integers don't overflow, but that it instead treats arithmetic using <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">n</span> bit unsigned integers as being modulo 2<span style="  font-style: italic; font-weight: normal; vertical-align: super">n</span> [<a href="#ANSI98">ANSI98</a>].
  </p><p> 
    We use the <tt class="code">accumulator</tt> class in a function object that counts the number of valid formulae by adding 1 to the count every time it is called with the result of a calculation, as shown in listing 8.
  </p><p> 
<table class="sidebartable"><tr><td><pre class="programlisting">
class  
    count_valid  
    {  
    public:  
      void operator()(long);  
      const accumulator &amp; count() const;  
 
    private:  
      accumulator count_;  
    };  
 
    void  
    count_valid::operator()(long)  
    {  
      count_ += 1;  
    }  
 
    const accumulator &amp;  
    count_valid::count() const  
    {  
      return count_;  
    }  
</pre></td></tr><tr><td class="title">Listing 8</td></tr></table>
  </p><p> 
    Unfortunately, a preliminary investigation suggested that the calculation of the total number of valid games would take the best part of <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">2 months</span> of CPU time using the admittedly rather outdated PC upon which I am writing this essay.
  </p><h2>
    Turbo-charging the stack
  </h2><p> 
    We can improve matters somewhat by abandoning the standard <tt class="code">stack</tt> and implementing our own. This will exploit the short string optimisation to keep the bottom of the stack on the much faster local store. If your STL implementation already uses the short string optimisation for its <tt class="code">vector</tt>s, then this won't really make much difference. Mine doesn't, so it will offer me an advantage, at least. The declaration of this class is given in listing 9.
  </p><p> 
<table class="sidebartable"><tr><td><pre class="programlisting">
template&lt;class T, size_t N,  
       class Cont=std::deque&lt;T&gt; &gt;  
    class rpn_stack  
    {  
    public:  
      typedef T      value_type;  
      typedef size_t size_type;  
 
      rpn_stack();  
 
      bool      empty() const;  
      size_type size() const;  
 
      const value_type &amp; top() const;  
      void push(const value_type&amp; x);  
      void pop();  
 
    private:  
      rpn_stack(const rpn_stack &amp;other);  
      //not implemented  
      rpn_stack &amp; operator=( const rpn_stack &amp;other);  
      //not implemented  
 
      std::stack&lt;T, Cont&gt; overflow_;  
      value_type          data_[N];  
      value_type *        top_;  
    };
</pre></td></tr><tr><td class="title">Listing 9</td></tr></table>
  </p><p> 
    Note that this isn't intended as a drop in replacement for the standard <tt class="code">stack</tt>, since it only implements the member functions we require for an RPN calculation.
  </p><p> 
    We use the trick of privately declaring, but not defining, the copy constructor and assignment operator to suppress the compiler generated defaults and ensure than an error will result if we accidentally use them. We don't ever need to copy stack objects during the evaluation of an RPN formula, and the defaults would leave them with pointers into each other's member arrays.
  </p><p> 
    We include a standard <tt class="code">stack</tt> to cope with values that drop off the end of our member array. The implementation of the member functions is fairly straightforward, as illustrated in listing 10.
  </p><p> 
<table class="sidebartable"><tr><td><pre class="programlisting">
template&lt;class T, size_t N, class Cont&gt;  
    rpn_stack&lt;T, N, Cont&gt;::rpn_stack() : top_(data_)  
    {  
    }  
 
    template&lt;class T, size_t N, class Cont&gt;  
    bool  
    rpn_stack&lt;T, N, Cont&gt;::empty() const  
    {  
      return top_==data_;  
    }  
 
    template&lt;class T, size_t N, class Cont&gt;  
    rpn_stack&lt;T, N, Cont&gt;::size_type  
    rpn_stack&lt;T, N, Cont&gt;::size() const  
    {  
      return (top_-data_) + overflow_.size();  
    }  
 
    template&lt;class T, size_t N, class Cont&gt;  
    const rpn_stack&lt;T, N, Cont&gt;::value_type &amp;  
    rpn_stack&lt;T, N, Cont&gt;::top() const  
    {  
      return overflow_.empty() ? *(top_-1) :  
         overflow_.top();  
    }  
 
    template&lt;class T, size_t N, class Cont&gt;  
    void  
    rpn_stack&lt;T, N, Cont&gt;::push(const value_type &amp;x)  
    {  
      if(top_!=data_+N)  *top_++ = x;  
      else               overflow_.push(x);  
    }  
 
    template&lt;class T, size_t N, class Cont&gt;  
    void  
    rpn_stack&lt;T, N, Cont&gt;::pop()  
    {  
      if(overflow_.empty())  --top_;  
      else                   overflow_.pop();  
    }
</pre></td></tr><tr><td class="title">Listing 10</td></tr></table>
  </p><p> 
    We are using the <tt class="code">data_</tt> member array to store the first <tt class="code">N</tt> values on the stack and so initialise the <tt class="code">top_</tt> pointer to the start of it during construction. It shall always point to the element immediately following the last value on the stack that is stored in the member array. Only when we have exhausted the array will we use <tt class="code">overflow_</tt>.
  </p><p> 
    The <tt class="code">empty</tt> member function therefore simply compares the <tt class="code">top_</tt> pointer to the start of the member array.
  </p><p> 
    Similarly, the <tt class="code">size</tt> member function simply adds the number of values we currently have in our member array to the size of <tt class="code">overflow_</tt>. If the former is full, the <tt class="code">top_</tt> pointer will be equal to <tt class="code">data_+N</tt> and so <tt class="code">size</tt> will correctly return the size of <tt class="code">overflow_</tt> plus <tt class="code">N</tt>. If not, the latter will be empty and <tt class="code">size</tt> will return the number of values currently in the member array.
  </p><p> 
    The <tt class="code">top</tt> member function defers to <tt class="code">overflow_</tt> if it is not empty, otherwise returns the value immediately before <tt class="code">top_</tt>. Note that, like the standard <tt class="code">stack</tt>, we do not check that there are any values currently on the stack.
  </p><p> 
    The <tt class="code">push</tt> member function assigns the pushed value to the element pointed to by <tt class="code">top_</tt> and increments <tt class="code">top_</tt> if it is not already at the end of the member array. If it is, the function simply defers to <tt class="code">overflow_</tt>.
  </p><p> 
    Similarly, if <tt class="code">overflow_</tt> is empty, the <tt class="code">pop</tt> member function simply decrements <tt class="code">top_</tt>. If it is not, the function defers to it instead. Note that this function, like <tt class="code">top</tt>, does not perform any check that there are any values currently on the stack.
  </p><p> 
    Finally, we should note that since the values stored in the member array are not destroyed until the <tt class="code">rpn_stack</tt> is, it is not particularly useful for values that consume lots of resources.
  </p><p> 
    Listing 11 shows the change that we need to make to the <tt class="code">rpn_operator </tt>class to use the <tt class="code">rpn_stack</tt>. Note that I'm only putting the first 6 values on the stack in local storage since during our analysis of the Countdown numbers game this will be the maximum number of arguments we shall use. Whilst this is clearly not a generally justifiable choice, I suspect that we'd be hard pushed to find another application for which we would really care quite this much about RPN formula calculation efficiency, so I figure it's probably OK.
  </p><p> 
<table class="sidebartable"><tr><td><pre class="programlisting">
template&lt;class T&gt;  
    class rpn_operator  
    {  
    public:  
      typedef rpn_stack&lt;T, 6&gt;  stack_type;  
      ...  
    };
</pre></td></tr><tr><td class="title">Listing 11</td></tr></table>
  </p><p> 
    Using our new stack brings the calculation time for counting every valid formula down to a little under 3 weeks. A fair bit better to be sure, but still not exactly tractable.
  </p><p> 
    Whilst I'm sure that we could find a yet more efficient approach with a little more work, I rather suspect that it wouldn't consist of such satisfyingly independent constructs. That said, if there's some blindingly obvious improvement that doesn't muddle up the responsibilities of our various functions and classes, I'd be more than happy to hear about it.
  </p><h2>
    The Countdown numbers game's little brothers
  </h2><p> 
    To keep the calculation manageable, I therefore suggest that we instead consider a cut down version of the numbers game; one in which we choose our 6 arguments from the set of 4 large numbers and half of the set of small numbers, or in other words 1 of each of the integers from 1 to 10.
  </p><p> 
    Another back of the envelope calculation suggests that this should take approximately 10 hours; hardly nippy, but not completely out of the question.
  </p><p> 
    Multiplying the number of formulae we can construct with up to 6 arguments by the number of ways in which we can select 6 arguments from 14 without taking order into account, or <span style="  font-style: normal; font-weight: normal; vertical-align: super">14</span><span style="  font-style: italic; font-weight: normal; vertical-align: baseline">C</span><span style="  font-style: normal; font-weight: normal; vertical-align: sub">6</span>, yields a total of 101,097,214,218 possible formulae, still a smidge out of the range of a 32 bit unsigned integer.
  </p><p> 
    The result of our calculation for this smaller numbers game shows that there are just 32,215,124,261 valid formulae, less than a third of the total number of formulae. The 68,882,089,957 invalid formulae must all involve division since that's the only operator that can have an invalid result. We can easily count the number of formulae involving division operations by subtracting from our total the number of formulae that involve only addition, subtraction and multiplication (we calculate this by replacing the 4 with a 3 in our formula). Doing so indicates that there are exactly 76,425,599,250 formulae involving division, of which over 90% are invalid.
  </p><p> 
    This leads me to wonder what might happen to the ratio between valid integer-only formulae and total formulae as we increase the number of arguments. This calculation will be more expensive still, so we shall examine games using 1 of each of the integers from 1 to 8 with from 1 to 8 arguments. The results of this calculation are given in figure 1.
    </p>
<table class="sidebartable"><tr><td align="center">The proportion of valid formulae of all formulae and formulae involving division</td></tr><tr><td>
<img src="/content/images/journals/ol97/Overload%20WW%20XML%20and%20CSS-5-1-03.gif"/>
</td></tr><tr><td class="title">Figure
1</td></tr></table>
    <p> 
    As fascinating as this almost is, it's high time we got around to investigating the statistical properties of the game. Specifically, I should like to know what the distribution of the results of every valid numbers game looks like.
  </p><h2>
    Building a histogram of numbers game results
  </h2><p> 
    Since the results of the numbers game formulae are integers, their distribution will be discrete and hence naturally represented with a histogram. Listing 12 provides the declaration of the <tt class="code">histogram</tt> class we shall use.
  </p><p> 
<table class="sidebartable"><tr><td><pre class="programlisting">
class game_histogram  
    {  
    public:  
      game_histogram();  
      game_histogram(long lower_bound,  
                     long upper_bound);  
 
      long   lower_bound() const;  
      long   upper_bound() const;  
      double samples() const;  
 
      double operator[](long i) const;  
      void   operator()(long i);  
 
    private:  
      typedef accumulator             value_type;  
      typedef std::vector&lt;value_type&gt; histogram_type;  
 
      long           lower_bound_;  
      value_type     samples_;  
      histogram_type histogram_;  
    };
</pre></td></tr><tr><td class="title">Listing 12</td></tr></table>
  </p><p> 
    It is a little less fully featured than the histograms we have implemented for previous studies, although since it uses our <tt class="code">accumulator</tt> class to keep count of the samples it can deal with much larger numbers.
  </p><p> 
    We can afford a reduced interface since the sample values will be integers and will thus serve perfectly well as indices into the histogram. Note that the function call operator overload is used to add samples since this enables us to use the <tt class="code">game_histogram</tt> class as the function object expected by our <tt class="code">for_each_numbers_game</tt> function.
  </p><p> 
    Listing 13 illustrates the definitions of the member functions. These are reasonably straightforward, with the only real gotcha being that the <tt class="code">lower_bound</tt> and <tt class="code">upper_bound</tt> are inclusive bounds of the histogram.
  </p><p> 
<table class="sidebartable"><tr><td><pre class="programlisting">
    game_histogram::game_histogram() : lower_bound_(0)  
    {  
    }  
 
    game_histogram::game_histogram(long lower_bound,  
                                   long upper_bound) :  
             lower_bound_(std::min(lower_bound,  
                                   upper_bound)),  
             histogram_(size_t(labs(  
                        upper_bound-lower_bound)+1))  
    {  
    }  
 
    long  
    game_histogram::lower_bound() const  
    {  
      return lower_bound_;  
    }  
 
    long  
    game_histogram::upper_bound() const  
    {  
      return lower_bound_ + (  
         long(histogram_.size()) - 1);  
    }  
 
    double  
    game_histogram::samples() const  
    {  
      return samples_;  
    }  
 
    double  
    game_histogram::operator[](long i) const  
    {  
      if(i&lt;lower_bound() || i&gt;upper_bound())  
         return 0.0;  
      return histogram_[size_t(i-lower_bound_)];  
    }  
 
    void  
    game_histogram::operator()(long i)  
    {  
      samples_ += 1;  
      if(i&gt;=lower_bound() &amp;&amp; i&lt;=upper_bound())  
      {  
        histogram_[size_t(i-lower_bound_)] += 1;  
      }  
    }
</pre></td></tr><tr><td class="title">Listing 13</td></tr></table>
  </p><p> 
    When trying to read values outside of the stored range we simply return 0, and when trying to add them the histogram entry is quietly dropped and only the count of the number of samples is increased.
  </p><p> 
    The histogram generated with this class enumerated over every game with the 4 large numbers and the 10 small numbers with results ranging from -2000 to +2000, grouped into buckets of 20 results to smooth out the graph a little, is shown in figure 2.
    </p>
<table class="sidebartable"><tr><td>
<img src="/content/images/journals/ol97/Overload%20WW%20XML%20and%20CSS-5-1-04.gif"/>
</td></tr><tr><td class="title">Figure
2</td></tr></table>
    
    <p> 
    There are clearly more positive results than negative, which should be expected since we can only generate a negative result by subtracting some formula from 1 of the 6 selected numbers, leaving that formula with only 5 or fewer arguments.
  </p><p> 
    It is worth noting that the formulae with results in the range of our histogram account for just a little over 70% of the valid games.
  </p><p> 
    I must admit that I'm a little surprised by the shape of the histogram. I was expecting it to look like a discretisation of the normal distribution since that, as you will remember from our previous studies, is the statistical distribution of sums of random numbers.
  </p><p> 
    Any formula can be recast as a sum of terms involving just multiplication and division by expanding out any terms in brackets, something known as the distributive law of arithmetic. For example, we can expand the formula
  </p><p class="indented"> <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">a</span><span style=" font-style: normal; font-weight: normal; vertical-align: baseline">&times;</span> (<span style="  font-style: italic; font-weight: normal; vertical-align: baseline">b</span> + <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">c</span>)
  </p><p> 
    into
  </p><p class="indented"> 
    (<span style="  font-style: italic; font-weight: normal; vertical-align: baseline">a</span><span style=" font-style: normal; font-weight: normal; vertical-align: baseline">&times;</span><span style="  font-style: italic; font-weight: normal; vertical-align: baseline">b</span>) + (<span style="  font-style: italic; font-weight: normal; vertical-align: baseline">a</span><span style=" font-style: normal; font-weight: normal; vertical-align: baseline">&times;</span><span style="  font-style: italic; font-weight: normal; vertical-align: baseline">c</span>)
  </p><p> 
    With an admittedly rather hand-waving argument I had imagined that these terms could be thought of as random variables in their own right. Whilst the terms would clearly not be independent in general, I believed that assuming that they were would yield a reasonable approximation.
  </p><p> 
    The average, or mean, of our truncated histogram is approximately 100, whilst its standard deviation (the square root of the average squared difference from the mean) is approximately 600. The histogram that would result from a normal distribution with these parameters is shown in figure 3 for comparison with our histogram of numbers game results.</p>
    <p>
<table class="sidebartable"><tr><td>
<img src="/content/images/journals/ol97/Overload%20WW%20XML%20and%20CSS-5-1-05.gif"/>
</td></tr><tr><td class="title">Figure
3</td></tr></table>
    </p>
    <p> 
    Clearly I was very much mistaken.
  </p><p> 
    So what kind of distribution do the results of the numbers games exhibit?
  </p><h2>
    The histogram of the absolute values of numbers game results
  </h2><p> 
    In pursuit of a statistical distribution that might describe the numbers game, I suggest that we allow the result of a formula to be negated. There are trivially twice as many formulae that can be constructed and the distribution of the results must be symmetric about 0. We can therefore simply study the histogram of the absolute results (i.e. ignoring the sign) which we can build by adding together the histogram value for each positive result to the value for its negation, and from which we can easily construct the full distribution.
  </p><p> 
    Figure 4 illustrates the histogram of the absolute results, also constructed with buckets of 20 results.</p>
    <p>
<table class="sidebartable"><tr><td>
<img src="/content/images/journals/ol97/Overload%20WW%20XML%20and%20CSS-5-1-06.gif"/>
</td></tr><tr><td class="title">Figure
4</td></tr></table>
    </p>
    <p> 
    The fact that this distribution falls away to 0 so slowly is highly suggestive of the class of distributions it falls into; the power law distributions.
  </p><h2>
    Power law distributions
  </h2><p> 
    Power law distributions have the probability density functions of the form
  </p>
  <p>
  <img src="/content/images/journals/ol97/Overload%20WW%20XML%20and%20CSS-5-1-07.gif"/>
  </p>
  <p> 
    where <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">L</span> is a slowly varying function, or in other words has the limiting behaviour
  </p>
  <p>
  <img src="/content/images/journals/ol97/Overload%20WW%20XML%20and%20CSS-5-1-08.gif"/>
  </p>
  <p> 
    for constant <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">t</span> [<a href="#Clauset09">Clauset09</a>]. The lim term on the left hand side of the fraction stands for the limit as <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">x</span> grows ever larger of the term to its right. We can interpret the equation as meaning that the function <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">L</span> should get closer and closer to a constant as <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">x</span> grows larger and larger.
  </p><p> 
    Probability density functions, or PDFs, are identical to histograms when describing discrete random variables. PDFs are more general, however, in that they can also describe continuous random variables.
  </p><p> 
    Power law distributions are notable because their PDFs decay to 0 very slowly as <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">x</span> increases and are hence associated with processes which display extreme behaviour with surprisingly high probability. The stock market, with its relatively frequent and all too hastily dismissed crashes, is one example that depressingly springs to mind [<a href="#Ormerod05">Ormerod05</a>].
  </p><p> 
    To determine whether a variable has a power law distribution, we can plot the logarithm of its PDF against the logarithm of <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">x</span>. If it follows a power law distribution then for large <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">x</span> this graph will be close to a straight line since
  </p>
<p>  
  <img src="/content/images/journals/ol97/Overload%20WW%20XML%20and%20CSS-5-1-09.gif"/>
  </p>
  <p> 
    for some constant <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">c</span>.
  </p><p> 
    For sample data, in which there will inevitably be some loss of information, be it noise or gaps in the distribution, we instead sort the <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">n</span> samples in ascending order and, treating the first as having an index of 0, plot (<span style="  font-style: italic; font-weight: normal; vertical-align: baseline">n</span>-<span style="  font-style: italic; font-weight: normal; vertical-align: baseline">i</span>)/<span style="  font-style: italic; font-weight: normal; vertical-align: baseline">n</span> against the <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">i</span><span style="  font-style: normal; font-weight: normal; vertical-align: super">th</span> value. This is the discrete equivalent of another test based on the integral of the PDF.
  </p><p> 
    Unfortunately, neither of these tests is particularly accurate. Worse still, accurately determining whether a sample is consistent with a power law distribution is something of an open question with the most reliable current techniques relying upon barrages statistical tests that are far beyond the scope of this article.
  </p><h2>
    Are the absolute numbers games power law distributed?
  </h2><p> 
    Our distribution seems to have a lot of little spikes in its tail and furthermore has an upper bound of
  </p><p class="indented"> 
    100 <span style=" font-style: normal; font-weight: normal; vertical-align: baseline">&times;</span> 75 <span style=" font-style: normal; font-weight: normal; vertical-align: baseline">&times;</span> 50 <span style=" font-style: normal; font-weight: normal; vertical-align: baseline">&times;</span> 25 <span style=" font-style: normal; font-weight: normal; vertical-align: baseline">&times;</span> 10 <span style=" font-style: normal; font-weight: normal; vertical-align: baseline">&times;</span> 9 = 843,750,000
  </p><p> 
    beyond which the probability of observing a result is trivially 0. It is therefore certainly not exactly power law distributed, although it is possible that it follows one approximately.
  </p><p> 
    Using the sample data approach of identifying power law behaviour figure 5 plots every 500<span style="  font-style: normal; font-weight: normal; vertical-align: super">th</span> of the sorted results from 0 to 32,000 against the function of their positions in the list together with a straight line drawn through every 500<span style="  font-style: normal; font-weight: normal; vertical-align: super">th</span> of the 24,000<span style="  font-style: normal; font-weight: normal; vertical-align: super">th</span> to the 32,000<span style="  font-style: normal; font-weight: normal; vertical-align: super">th</span> point.</p>
<p>    
<table class="sidebartable"><tr><td>
<img src="/content/images/journals/ol97/Overload%20WW%20XML%20and%20CSS-5-1-10.gif"/>
</td></tr><tr><td class="title">Figure
5</td></tr></table>
</p>    
    <p> 
    Well, it certainly <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">looks</span> very much like a straight line, and with a root mean square error between the line and the points it was drawn through of a little over 0.00025 we can probably conclude that it is at least quite close to one.
  </p><p> 
    Despite this not being a particularly good test for power law behaviour, the cumulative histogram of the numbers game can be approximated for every result in this range by that of a power law with a root mean square error of approximately 0.0003. Statistically speaking, this is actually a fairly significant difference since the histogram is constructed from a huge number of results. Nevertheless, as an approximation it predicts the proportion of results falling below a given value within this range with an error that is everywhere less than a not too shabby 0.061%.
  </p><p> 
    Since we cannot swiftly enumerate every possible formula in the full Countdown numbers game, we shall instead have to randomly sample them if we wish to check whether or not their absolute results are similarly approximated by a power law distribution.
  </p><h2>
    Sampling the Countdown numbers game
  </h2><p> 
    To implement a scheme for randomly sampling numbers games, we take similar steps to those we took when implementing a function to enumerate them. Specifically we need a mechanism for the random generation of permutations, of combinations and of operator choices.
  </p><p> 
    Just as our previously implemented <tt class="code">next_state</tt> function solved the problem of enumerating operator choices, so the <tt class="code">random_state</tt> function implemented as part of the same article solves the problem of randomly generating them. Implemented in listing 14 together with a random number generator, <tt class="code">rnd</tt>, it was inspired by the standard <tt class="code">random_shuffle</tt> function and, like it, does not place many restrictions upon the values on which it operates. This means that we shall not need to use iterators into a container of operators, but will instead be able to use the container directly.
  </p><p> 
<table class="sidebartable"><tr><td><pre class="programlisting">
    double  
    rnd(double x)  
    {  
      return x * double(  
         rand())/(double(RAND_MAX)+1.0);  
    }  
 
    template&lt;class FwdIt, class States&gt;  
    void  
    random_state(FwdIt first, FwdIt last,  
                 const States &amp;states)  
    {  
      while(first!=last)  
      {  
        *first++ = states[size_t(  
           rnd(double(states.size())))];  
      }  
    }
</pre></td></tr><tr><td class="title">Listing 14</td></tr></table>
  </p><p> 
    To generate a random permutation, we can exploit the fact that the standard <tt class="code">random_shuffle</tt> function has an equal probability of leaving any value in any position. We can therefore simply use it and then just examine the part of the iterator range that we're interested in.
  </p><p> 
    If we then sort that part of the iterator range, we have effectively implemented an algorithm for generating random combinations.
  </p><p> 
    Our scheme shall therefore proceed as follows:
  </p>
		<ol><li> 
    Pick a formula template at random.
  </li><li> 
    Pick a set of operators at random.
  </li><li> 
    Pick a combination of the available numbers at random.
  </li><li> 
    Pick a permutation of arguments from these at random.
  </li></ol><p> 
    Hang on a sec, those last 2 steps look a bit dodgy to me.
  </p><p> 
    We're picking a sorted random combination of numbers and then an unsorted random permutation of arguments from them. Our algorithms for generating random combinations and permutations require that we apply <tt class="code">random_shuffle</tt> to the whole range from which each is generated and then ignore those elements we're not interested in. In other words, we shall be sorting the selected numbers to create the combination and then immediately afterwards randomly shuffling them again to generate our permutation of arguments. Isn't this ever so slightly a complete and utter waste of time?
  </p><p> 
    Well, yes it is; we can combine both steps by instead generating a random permutation of the arguments we require from the full set of available numbers:
  </p>
		<ol><li> 
    Pick a formula template at random.
  </li><li> 
    Pick a set of operators at random.
  </li><li> 
    Pick a permutation of arguments from the available numbers at random.
  </li></ol><p> 
    So why did we spend so much time mucking about with combinations when permutations seem to do the job perfectly adequately?
  </p><p> 
    The answer lies in a subtle difference between the mechanics of sampling and those of enumeration. For a given formula template and set of operators, enumerating the permutations of 6 numbers from the 24 available will result in us counting some functions many times over. Specifically, for templates with less than 5 arguments there will be multiple permutations for which those arguments will be identical, as illustrated in figure 6.</p>
    <p>
<table class="sidebartable" cellpadding="10"><tr><td>
1  2  3  |  4  5  6<br/>
1  2  3  |  4  6  5<br/>
1  2  3  |  5  4  6<br/>
1  2  3  |  5  6  4<br/>
1  2  3  |  6  4  5<br/>
1  2  3  |  6  5  4
</td></tr><tr><td class="title">Figure
6</td></tr></table>
    </p>
    <p> 
    This isn't an issue when sampling since the order of the unused numbers has no bearing whatsoever on the result of the formula. Since each ordering has exactly the same probability, the statistical distribution of the results is unaffected.
  </p><p> 
    That settled, the function for randomly sampling numbers games is given in listing 15. This is a relatively straightforward implementation of our algorithm; we first randomly select a formula template, we then randomly generate a correctly sized vector of operators to substitute into it and we finally generate a random permutation of arguments. Note that we still have to copy the arguments into an appropriately sized <tt class="code">vector</tt> since this is what our <tt class="code">rpn_evaluate</tt> function expects. Figure 7 gives the power law graph of a sample of 40,000,000,000, or roughly 1%, of the Countdown numbers games. Once again, it looks like it tends to a straight line and the root mean square error between the line and the graph from the 24,000th to the 32,000th point of approximately 0.00035 supports this.
  </p><p> 
<table class="sidebartable"><tr><td><pre class="programlisting">
    template&lt;class Fun&gt;  
    Fun  
    sample_numbers_games(size_t samples,   
                         std::vector&lt;long&gt; numbers,  
                         size_t args,    Fun f)  
    {  
      typedef rpn_operator&lt;long&gt;  
         const * operator_type;  
      typedef std::vector&lt;operator_type&gt;  
         operators_type;  
      typedef std::vector&lt;long&gt; arguments_type;  
 
      if(args&gt;numbers.size())   
         throw std::invalid_argument(&quot;&quot;);  
 
      operators_type operators(4);  
      const rpn_add&lt;long&gt; add;  
         operators[0] = &amp;add;  
      const rpn_subtract&lt;long&gt; subtract;  
         operators[1] = &amp;subtract;  
      const rpn_multiply&lt;long&gt; multiply;   
         operators[2] = &amp;multiply;  
      const rpn_divide&lt;long&gt; divide;   
         operators[3] = &amp;divide;  
      const std::set&lt;std::string&gt;  
         templates(all_templates(args));  
      operators_type used_operators;  
      arguments_type used_arguments;  
 
      while(samples--)  
      {  
        std::set&lt;std::string&gt;::const_iterator t   
           = templates.begin();  
        std::advance(t,  
           size_t(rnd(templates.size())));  
        const size_t t_args = (t-&gt;size()+1)/2;  
        used_operators.resize(t_args-1);  
        random_state(used_operators.begin(),  
           used_operators.end(), operators);  
 
        std::random_shuffle(numbers.begin(),  
           numbers.end());  
        used_arguments.assign(numbers.begin(),  
           numbers.begin()+t_args);  
        const rpn_result&lt;long&gt; result   
           = rpn_evaluate(*t, used_operators,  
                              used_arguments);  
        if(result.valid)  f(result.value);  
      }  
      return f;  
    }
</pre></td></tr><tr><td class="title">Listing 15</td></tr></table>
</p>
<p>
<table class="sidebartable"><tr><td>
<img src="/content/images/journals/ol97/Overload%20WW%20XML%20and%20CSS-5-1-12.gif"/>
</td></tr><tr><td class="title">Figure
7</td></tr></table>
</p>
<h2>
    A theoreticalish justification
  </h2><p> 
    Mucking about with graphs and tests is all well and good, but it doesn't really provide any insight into the statistical behaviour of numbers games. What we really need is a theoretical justification as to why power law distributions might be reasonable approximations of them.
  </p><p> 
    We shall begin by introducing yet another numbers game. In this new game we shall begin by picking, at random, a real number between 1 and 2. We shall then toss a coin; if it comes up tails the games is over and the number we picked is the result and if it comes up heads we double the number and toss the coin again, treating the doubled result as our starting point.
  </p><p> 
    This game has a 1 in 2 chance of a result between 1 and 2, a 1 in 4 chance of a result between 2 and 4, a 1 in 8 chance of a result between 4 and 8 and so on. The probability density function of the results of this game, being the continuous limit of a histogram and for which the area under the curve between 2 values gives the probability that a result in that range will be observed, is given in figure 8. This curve is bounded by the inequality
  </p>
  <p>
   <img src="/content/images/journals/ol97/Overload%20WW%20XML%20and%20CSS-5-1-13.gif"/>
   </p>
   <p> 
    as is illustrated by the dotted lines.</p>
    <p>
<table class="sidebartable"><tr><td>
<img src="/content/images/journals/ol97/Overload%20WW%20XML%20and%20CSS-5-1-14.gif"/>
</td></tr><tr><td class="title">Figure
8</td></tr></table>
    </p>
    <p> 
    Clearly this is approximately an inverse square power law distribution. This fact is demonstrated even more clearly by the cumulative distribution function; the function that yields the area under the curve between 0 and any given value and hence the probability that we should observe a result less than or equal to that value, as illustrated in figure 9. The dotted line in this graph is the cumulative distribution function of a quantity exactly obeying an inverse square power law distribution.</p>
    <p>
<table class="sidebartable"><tr><td>
<img src="/content/images/journals/ol97/Overload%20WW%20XML%20and%20CSS-5-1-15.gif"/>
</td></tr><tr><td class="title">Figure
9</td></tr></table>
    </p>    
    <p> 
    This result can be generalised in that a game in which we pick a real number between 1 and <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">n</span> and with probability <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">p</span> choose to multiply the current result by <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">n</span> rather than quit the game must also be similarly approximated by a power law distribution. Furthermore, we needn't specify which statistical distribution governs the choice of the first number for this to hold.
  </p><p> 
    We can identify the first number as the relatively small result of a formula involving the addition and multiplication of relatively small numbers in the Countdown numbers game. The successive multiplications can be similarly identified with multiplying these small results by the large numbers.
  </p><p> 
    Note that for each formula with <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">n</span> arguments, there is a formula with <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">n</span>+1 arguments that equates to multiplying the former by the final argument. The proportion of such formulae to all formulae with <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">n</span>+1 arguments is equal to
  </p>
  <p>
  <img src="/content/images/journals/ol97/Overload%20WW%20XML%20and%20CSS-5-1-16.gif"/>
  </p>
  <p> 
    For sufficiently large <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">n</span> this is approximately constant, so the probability of multiplying an <span style="  font-style: italic; font-weight: normal; vertical-align: baseline">n</span> argument formula by a large number is also approximately constant.
  </p><p> 
    Subsequent divisions, should they be valid, can be thought of as reducing the probability of a multiplication, and subsequent additions will affect the larger results by orders of magnitude less than the multiplications.
  </p><p> 
    It doesn't seem entirely unreasonable therefore to accept this latest game as an approximate model for the Countdown numbers game and that the latter can therefore be well approximated by a power law distribution.
  </p><p> 
    Whilst the game is certainly not exactly governed by a power law, I believe that we can conclude with some confidence that we can reasonably approximate it with one and that there is therefore a surprising relationship between the Countdown numbers game and the recent economic meltdown.
  </p><p> 
    Who'd have thunk it?</p><h2>
    Acknowledgements
  </h2><p> 
    With thanks to Keith Garbutt for proof reading this article.
  </p><h2>
    References and further reading
  </h2><p class="bibliomixed"><a name="ANSI98"></a> 
    [ANSI98]  The C++ Standard, American National Standards Institute, 1998.
  </p><p class="bibliomixed"><a name="Clauset09"></a> 
    [Clauset09]  Clauset, A. et al, Power Law Distributions in Empirical Data, arXiv:0706.1062v2, <a href="http://www.arxiv.org">www.arxiv.org</a>, 2009.
  </p><p class="bibliomixed"><a name="Countdown"></a> 
    [Countdown]  <a href="http://www.channel4.com/programmes/countdown">http://www.channel4.com/programmes/countdown</a>
    </p><p class="bibliomixed"><a name="Harris08"></a> 
    [Harris08]  Harris, R., The Model Student: A Knotty Problem, Part 1, Overload 84, 2008.
  </p><p class="bibliomixed"><a name="Harris09"></a> 
    [Harris09]  Harris, R., The Model Student: A Primal Skyline, Part 2, Overload 93, 2009.
  </p><p class="bibliomixed"><a name="Ormerod05"></a> 
    [Ormerod05]  Ormerod, P., Why Most Things Fail, Faber and Faber, 2005.
  </p>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
