Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h1>C++, 647 chars</h1> <p>I don't expect to score highly by using C++, but nevermind that. I'm pretty sure it hits all the requirements. Note that I used the C++0x <code>auto</code> keyword for variable declaration, so adjust your complier appropriately if you decide to test my code.</p> <p><strong>Minimised version</strong></p> <pre><code>#include &lt;iostream&gt; #include &lt;cstring&gt; #include &lt;map&gt; using namespace std; #define C string #define S(x)v=F/a,cout&lt;&lt;#x&lt;&lt;C(v,'_') #define F t-&gt;first #define G t-&gt;second #define O &amp;&amp;F!= #define L for(i=22;i--&gt;0;--t) int main(){map&lt;C,int&gt;f;char d[230];int i=1,v;for(;i&lt;256;i++)d[i&lt;123?i-1:i-27]=i;d[229]=0;char w[99];while(cin&gt;&gt;w){for(i=0;w[i];i++)w[i]=tolower(w[i]);char*p=strtok(w,d);while(p)++f[p],p=strtok(0,d);}multimap&lt;int,C&gt;c;for(auto t=f.end();--t!=f.begin();)if(F!="the"O"and"O"of"O"to"O"a"O"i"O"it"O"in"O"or"O"is")c.insert(pair&lt;int,C&gt;(G,F));auto t=--c.end();float a=0,A;L A=F/(76.0-G.length()),a=a&gt;A?a:A;t=--c.end();S( );L S(\n|)&lt;&lt;"| "&lt;&lt;G;} </code></pre> <p>Here's a second version that is more "C++" by using <code>string</code>, not <code>char[]</code> and <code>strtok</code>. It's a bit larger, at <strong>669 (+22 vs above)</strong>, but I can't get it smaller at the moment so thought I'd post it anyway.</p> <pre><code>#include &lt;iostream&gt; #include &lt;map&gt; using namespace std; #define C string #define S(x)v=F/a,cout&lt;&lt;#x&lt;&lt;C(v,'_') #define F t-&gt;first #define G t-&gt;second #define O &amp;&amp;F!= #define L for(i=22;i--&gt;0;--t) #define E e=w.find_first_of(d,g);g=w.find_first_not_of(d,e); int main(){map&lt;C,int&gt;f;int i,v;C w,x,d="abcdefghijklmnopqrstuvwxyz";while(cin&gt;&gt;w){for(i=w.size();i--&gt;0;)w[i]=tolower(w[i]);unsigned g=0,E while(g-e&gt;0){x=w.substr(e,g-e),++f[x],E}}multimap&lt;int,C&gt;c;for(auto t=f.end();--t!=f.begin();)if(F!="the"O"and"O"of"O"to"O"a"O"i"O"it"O"in"O"or"O"is")c.insert(pair&lt;int,C&gt;(G,F));auto t=--c.end();float a=0,A;L A=F/(76.0-G.length()),a=a&gt;A?a:A;t=--c.end();S( );L S(\n|)&lt;&lt;"| "&lt;&lt;G;} </code></pre> <p>I've removed the full version, because I can't be bothered to keep updating it with my tweaks to the minimised version. See edit history if you're interested in the (possibly outdated) long version.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload