Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h1>Perl, <strike>235 211 225 211 207 196 179 177 175 168 160 156</strike> 146 chars</h1> <pre><code>&lt;&gt;=~/-\d+/;for$y(@a=-$'..$'){print+(map$_|$y?!($t=8*($y&gt;0)+atan2(-$y,$_)/atan2 1,1)&amp;-$&amp;/45==8|$t&gt;=$`/45&amp;$t&lt;=-$&amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/} </code></pre> <p><br /></p> <h1>Perl using say feature, <strike>161 149</strike> 139 chars</h1> <pre><code>$ echo -n '&lt;&gt;=~/-\d+/;for$y(@a=-$'"'"'..$'"'"'){say map$_|$y?!($t=8*($y&gt;0)+atan2(-$y,$_)/atan2 1,1)&amp;-$&amp;/45==8|$t&gt;=$`/45&amp;$t&lt;=-$&amp;/45?qw(- / | \\)[$t%4]:$":o,@a}' | wc -c 139 $ perl -E '&lt;&gt;=~/-\d+/;for$y(@a=-$'"'"'..$'"'"'){say map$_|$y?!($t=8*($y&gt;0)+atan2(-$y,$_)/atan2 1,1)&amp;-$&amp;/45==8|$t&gt;=$`/45&amp;$t&lt;=-$&amp;/45?qw(- / | \\)[$t%4]:$":o,@a}' </code></pre> <p><br /></p> <h1>Perl without trailing newline, <strike>153</strike> 143 chars</h1> <pre><code>&lt;&gt;=~/-\d+/;for$y(@a=-$'..$'){print$/,map$_|$y?!($t=8*($y&gt;0)+atan2(-$y,$_)/atan2 1,1)&amp;-$&amp;/45==8|$t&gt;=$`/45&amp;$t&lt;=-$&amp;/45?qw(- / | \\)[$t%4]:$":o,@a} </code></pre> <p><br /> Original version commented:</p> <pre><code>$_=&lt;&gt;;m/(\d+)-(\d+) (\d+)/;$e=$1/45;$f=$2/45; # parse angles and radius, angles are 0-8 for$y(-$3..$3){ # loop for each row and col for$x(-$3..$3){ $t=atan2(-$y,$x)/atan2 1,1; # angle of this point $t+=8if($t&lt;0); # normalize negative angles @w=split//,"-/|\\"x2; # array of ASCII symbols for enclosing lines $s.=!$x&amp;&amp;!$y?"o":$t==$e||$t==$f?$w[$t]:$t&gt;$e&amp;&amp;$t&lt;$f?"x":$"; # if it's origin -&gt; "o", if it's enclosing line, get symbol from array # if it's between enclosing angles "x", otherwise space } $s.=$/; } print$s; </code></pre> <p><br /> <strong>EDIT 1:</strong> Inlined sub, relational and equality operators return 0 or 1. <br /> <strong>EDIT 2:</strong> Added version with comments. <br /> <strong>EDIT 3:</strong> Fixed enclosing line at 360º. Char count increased significantly. <br /> <strong>EDIT 4:</strong> Added a shorter version, bending the rules. <br /> <strong>EDIT 5:</strong> Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/ <br /> <strong>EDIT 6:</strong> Removed unneeded <code>m</code> from match operator. Removed some semicolons. <br /> <strong>EDIT 7:</strong> Smarter regexp. Under 200 chars! <br /> <strong>EDIT 8:</strong> Lots of small improvements:</p> <ul> <li>Inner for loop -> map (1 char)</li> <li>symbol array from <code>split</code> string -> qw (3 chars)</li> <li>inlined symbol array (6 chars, together with the previous improvement 9 chars!)</li> <li>Logical or -> bitwise or (1 char)</li> <li>Regexp improvement (1 char)</li> <li>Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)</li> </ul> <p><br /> <strong>EDIT 9:</strong> A little reordering in the conditional operators saves 2 chars. <br /> <strong>EDIT 10:</strong> Use barewords for characters. <br /> <strong>EDIT 11:</strong> Moved print inside of loop, inspired by Lowjacker's answer. <br /> <strong>EDIT 12:</strong> Added version using <code>say</code>. <br /> <strong>EDIT 13:</strong> Reuse angles characters for fill character, as Gwell's answer does. Output isn't as nice as Gwell's though, that would require 5 additional chars :) Also, .. operator doen't need parentheses. <br /> <strong>EDIT 14:</strong> Apply regex directly to &lt;>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated <code>say</code> version. <br /> <strong>EDIT 15:</strong> More inlining. map{block}@a -> map expr,@a.</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