On 7/15/07, <b class="gmail_sendername">Hugh Perkins</b> &lt;<a href="mailto:hughperkins@gmail.com">hughperkins@gmail.com</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<span class="q">On 7/15/07, <b class="gmail_sendername">Hugh Perkins</b> &lt;<a href="mailto:hughperkins@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">hughperkins@gmail.com</a>&gt; wrote:
<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<span></span><div><span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I&#39;d have a go in C# at &#39;chameneos&#39;, a concurrency
<br>benchmark,<br><br>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="http://shootout.alioth.debian.org/gp4/benchmark.php?test=chameneos&amp;lang=all" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://shootout.alioth.debian.org/gp4/benchmark.php?test=chameneos&amp;lang=all
</a><br></blockquote></span></div><br></blockquote></div><br></span>Errr this is kindof a strange problem, the answer is always N * 2?<br><br>And there we see why I dislike shootout ;-)<br><br>
</blockquote></div><br>By the way, sortof felt guilty for not really creating imaginary Chameneos, and there&#39;s also the race condition to think about.<br><br>Race condition<br>===========<br><br>(or: why is it N * 2)
<br><br>There is an insane race condition in the question, which really renders the question rather uncool, but let&#39;s accept for now that it&#39;s ok to have insane race conditions in our programs.&nbsp; There are two possibilities:
<br><br>1. The insane race condition means that each test condition produces a different output, and the question is entirely invalid<br>2. The race condition has no affect on the output<br><br>If 1 is true, the question is entirely invalid.&nbsp; We&#39;re going to assume that the question is valid, which means the race condition has no affect on the result.
<br><br>That means that we can imagine the chaemeneos meeting in any order we like.<br><br>So we send c1 then c2.&nbsp; That&#39;s one meeting, and each chameneos has met other other chameneos.<br><br>We iterate N times, so C1 and c2 both met another chameneos N times, giving a total of N * 2.
<br><br>The colors are entirely irrelevant, and do not have any affect on the meetings, because they do not affect whether meetings take place or not.<br><br>Imaginary Chameneos<br>================<br><br>The question asks us to imagine N chameneos of different colors meeting.&nbsp; Chameneos do not really exist, they&#39;re an imaginary creation.&nbsp; So we have to imagine N imaginary chameneos meeting imaginarily.
<br><br>Rest assured, as I pressed the &quot;Enter&quot; key I did duly imagine the 100 chameneos in many colors all meeting and changing colors and becoming faded.<br><br>Oh, you want the computer to imagine the imaginary chameneos meeting and changing colors?&nbsp; Well now, a computer doesnt really imagine anything, we ascribe meaning to arbitrary symbols in our code.
<br><br>So, just to put your mind at rest,&nbsp; the function &quot;Chameneos.Go( int N )&quot; in my code represents N chameneos in many colors meeting and changing colors, so to the extent that a computer can imagine things, the computer really did imagine imaginary chameneos imaginarily meeting :-D
<br><br>