代码高尔夫:为我打造弧线

发布于 2024-09-12 05:01:23 字数 1461 浏览 4 评论 0 原文

挑战

按字符数计算最短的程序,接受 XY R 形式的标准输入,并具有以下保证:

  • R 是小于或等于 8 的非负十进制数
  • XY 是以十进制形式给出的非负角度,为 45° 的倍数(045、< code>90、135 等)
  • X 小于 Y
  • Y 不 < code>360 如果 X0

并在标准输出上生成从起始角度 X 到结束角度的 ASCII“弧”半径 R 的角度 Y,其中:

  • 圆弧的顶点由 o 表示
  • 0 和 0 的角度code>180 用 - 表示
  • / 表示
  • 45225的角度 90270| 表示
  • 135315 的角度由\
  • 两条线围成的多边形区域用非空白字符填充。

如果给出无效输入,程序不需要产生有意义的输出。任何语言的解决方案都是允许的,当然,专门为此挑战编写的语言或不公平使用外部实用程序的语言除外。只要输出格式保持正确,输出中就允许出现多余的水平和垂直空格

快乐高尔夫!

大量示例

输入:

0-45 8

输出:

        /
       /x
      /xx
     /xxx
    /xxxx
   /xxxxx
  /xxxxxx
 /xxxxxxx
o--------

输入:

0-135 4

输出:

\xxxxxxxx
 \xxxxxxx
  \xxxxxx
   \xxxxx
    o----

输入:

180-360 2

输出:

--o--
xxxxx
xxxxx

输入:

45-90 0

输出:

o

输入:

0-315 2

输出:

xxxxx
xxxxx
xxo--
xxx\
xxxx\

Challenge

The shortest program by character count that accepts standard input of the form X-Y R, with the following guarantees:

  • R is a non-negative decimal number less than or equal to 8
  • X and Y are non-negative angles given in decimal as multiples of 45° (0, 45, 90, 135, etc.)
  • X is less than Y
  • Y is not 360 if X is 0

And produces on standard output an ASCII "arc" from the starting angle X to the ending angle Y of radius R, where:

  • The vertex of the arc is represented by o
  • Angles of 0 and 180 are represented by -
  • Angles of 45 and 225 are represented by /
  • Angles of 90 and 270 are represented by |
  • Angles of 135 and 315 are represented by \
  • The polygonal area enclosed by the two lines is filled with a non-whitespace character.

The program is not required to produce meaningful output if given invalid input. Solutions in any language are allowed, except of course a language written specifically for this challenge, or one that makes unfair use of an external utility. Extraneous horizontal and vertical whitespace is allowed in the output provided that the format of the output remains correct.

Happy golfing!

Numerous Examples

Input:

0-45 8

Output:

        /
       /x
      /xx
     /xxx
    /xxxx
   /xxxxx
  /xxxxxx
 /xxxxxxx
o--------

Input:

0-135 4

Output:

\xxxxxxxx
 \xxxxxxx
  \xxxxxx
   \xxxxx
    o----

Input:

180-360 2

Output:

--o--
xxxxx
xxxxx

Input:

45-90 0

Output:

o

Input:

0-315 2

Output:

xxxxx
xxxxx
xxo--
xxx\
xxxx\

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

二智少女 2024-09-19 05:01:23

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

<>=~/-\d+/;for$y(@a=-

Perl 使用 say 功能,161 149 139 个字符

$ echo -n '<>=~/-\d+/;for$y(@a=-

Perl 不带尾随换行符, 153 143 个字符

<>=~/-\d+/;for$y(@a=-

原版评论:

$_=<>;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<0);                # normalize negative angles
            @w=split//,"-/|\\"x2;         # array of ASCII symbols for enclosing lines
            $s.=!$x&&!$y?"o":$t==$e||$t==$f?$w[$t]:$t>$e&&$t<$f?"x":$";
            # if it's origin -> "o", if it's enclosing line, get symbol from array
            # if it's between enclosing angles "x", otherwise space
    }
    $s.=$/;
}
print$s;

编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

..

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

"'"'..

Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

..

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

"'"'){say map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

<>=~/-\d+/;for$y(@a=-

Perl 使用 say 功能,161 149 139 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a}' | wc -c
139
$ perl -E '<>=~/-\d+/;for$y(@a=-

Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

..

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

"'"'..

Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

..

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

"'"'){say map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

<>=~/-\d+/;for$y(@a=-

Perl 使用 say 功能,161 149 139 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a}'

Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

..

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

..

原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

..

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

"'"'..

Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

..

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

"'"'){say map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

<>=~/-\d+/;for$y(@a=-

Perl 使用 say 功能,161 149 139 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a}' | wc -c
139
$ perl -E '<>=~/-\d+/;for$y(@a=-

Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

..

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

"'"'..

Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

..

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

"'"'){say map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

<>=~/-\d+/;for$y(@a=-

Perl 使用 say 功能,161 149 139 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a}'

Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

..

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

){print$/,map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

<>=~/-\d+/;for$y(@a=-

Perl 使用 say 功能,161 149 139 个字符

$ echo -n '<>=~/-\d+/;for$y(@a=-

Perl 不带尾随换行符, 153 143 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a}

原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

..

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

"'"'..

Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

..

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

"'"'){say map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

<>=~/-\d+/;for$y(@a=-

Perl 使用 say 功能,161 149 139 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a}' | wc -c
139
$ perl -E '<>=~/-\d+/;for$y(@a=-

Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

..

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

"'"'..

Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

..

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

"'"'){say map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

<>=~/-\d+/;for$y(@a=-

Perl 使用 say 功能,161 149 139 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a}'

Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

..

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 个字符

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl 使用 say 功能,161 149 139 个字符


Perl 不带尾随换行符, 153 143 个字符


原版评论:


编辑 1: 内联子运算符、关系运算符和相等运算符返回 0 或 1。

编辑2:添加了带有评论的版本。

编辑 3: 修复了 360° 的封闭线。字符数显着增加。

编辑4:添加了一个较短的版本,改变了规则。

编辑 5: 更智能地修复 360° 包围线。另外,使用数字作为填充。这两件事都是显而易见的。嗯,我应该多睡一点:/

编辑6:从匹配运算符中删除了不需要的m。删除了一些分号。

编辑7:更智能的正则表达式。少于200个字符!

编辑 8: 很多小改进:

  • 内部 for 循环 -> 从 split 字符串映射(1 个字符)
  • 符号数组 -> qw (3 个字符)
  • 内联符号数组 (6 个字符,加上之前的改进 9 个字符!)
  • 逻辑或 ->按位或(1 个字符)
  • 正则表达式改进(1 个字符)
  • 使用算术测试负角,灵感来自 Jacob 的答案(5 个字符)

编辑 9: 对条件运算符进行一点重新排序可以节省 2 个字符。

编辑10:使用裸字作为字符。

编辑11:将打印移到循环内部,受到Lowjacker答案的启发。

编辑12:使用say添加版本。

编辑13:重复使用角度字符作为填充字符,就像Gwell的答案一样。不过,输出不如 Gwell 的那么好,这需要 5 个额外的字符:) 另外,.. 运算符不需要括号。

编辑14:将正则表达式直接应用于<>。根据 Adrian 对 bta 答案的建议,将范围运算符分配给变量。添加没有最后换行符的版本。更新了 say 版本。

编辑15:更多内联。地图{块}@a ->映射 expr,@a。

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

<>=~/-\d+/;for$y(@a=-

Perl using say feature, 161 149 139 chars

$ echo -n '<>=~/-\d+/;for$y(@a=-

Perl without trailing newline, 153 143 chars

<>=~/-\d+/;for$y(@a=-

Original version commented:

$_=<>;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<0);                # normalize negative angles
            @w=split//,"-/|\\"x2;         # array of ASCII symbols for enclosing lines
            $s.=!$x&&!$y?"o":$t==$e||$t==$f?$w[$t]:$t>$e&&$t<$f?"x":$";
            # if it's origin -> "o", if it's enclosing line, get symbol from array
            # if it's between enclosing angles "x", otherwise space
    }
    $s.=$/;
}
print$s;

EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

..

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

"'"'..

Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

..

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

"'"'){say map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

<>=~/-\d+/;for$y(@a=-

Perl using say feature, 161 149 139 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a}' | wc -c
139
$ perl -E '<>=~/-\d+/;for$y(@a=-

Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

..

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

"'"'..

Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

..

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

"'"'){say map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

<>=~/-\d+/;for$y(@a=-

Perl using say feature, 161 149 139 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a}'

Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

..

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

..

Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

..

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

"'"'..

Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

..

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

"'"'){say map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

<>=~/-\d+/;for$y(@a=-

Perl using say feature, 161 149 139 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a}' | wc -c
139
$ perl -E '<>=~/-\d+/;for$y(@a=-

Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

..

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

"'"'..

Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

..

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

"'"'){say map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

<>=~/-\d+/;for$y(@a=-

Perl using say feature, 161 149 139 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a}'

Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

..

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

){print$/,map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

<>=~/-\d+/;for$y(@a=-

Perl using say feature, 161 149 139 chars

$ echo -n '<>=~/-\d+/;for$y(@a=-

Perl without trailing newline, 153 143 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a}

Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

..

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

"'"'..

Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

..

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

"'"'){say map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

<>=~/-\d+/;for$y(@a=-

Perl using say feature, 161 149 139 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a}' | wc -c
139
$ perl -E '<>=~/-\d+/;for$y(@a=-

Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

..

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

"'"'..

Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

..

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

"'"'){say map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

<>=~/-\d+/;for$y(@a=-

Perl using say feature, 161 149 139 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a}'

Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

..

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-
amp;/45==8|$t>=

Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars

/45&$t<=-
amp;/45?qw(- / | \\)[$t%4]:$":o,@a),$/}

Perl using say feature, 161 149 139 chars


Perl without trailing newline, 153 143 chars


Original version commented:


EDIT 1: Inlined sub, relational and equality operators return 0 or 1.

EDIT 2: Added version with comments.

EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.

EDIT 4: Added a shorter version, bending the rules.

EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/

EDIT 6: Removed unneeded m from match operator. Removed some semicolons.

EDIT 7: Smarter regexp. Under 200 chars!

EDIT 8: Lots of small improvements:

  • Inner for loop -> map (1 char)
  • symbol array from split string -> qw (3 chars)
  • inlined symbol array (6 chars, together with the previous improvement 9 chars!)
  • Logical or -> bitwise or (1 char)
  • Regexp improvement (1 char)
  • Use arithmethic for testing negative angles, inspired by Jacob's answer (5 chars)

EDIT 9: A little reordering in the conditional operators saves 2 chars.

EDIT 10: Use barewords for characters.

EDIT 11: Moved print inside of loop, inspired by Lowjacker's answer.

EDIT 12: Added version using say.

EDIT 13: 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.

EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian's suggestion to bta's answer. Add version without the final newline. Updated say version.

EDIT 15: More inlining. map{block}@a -> map expr,@a.

执着的年纪 2024-09-19 05:01:23

Lua,259 个字符

稍微滥用了非空白字符子句,以产生令人眼花缭乱的显示,更重要的是节省笔划。

m=math i=io.read():gmatch("%d+")a=i()/45 b=i()/45 r=i()for y=r,-r,-1 do for x=-r,r do c=m.atan2(y,x)/m.pi*4 c=c<0 and c+8 or c k=1+m.modf(c+.5)io.write(x==0 and y==0 and'o'or c>=a and c<=b and('-/|\\-/|\\-'):sub(k,k)or c==0 and b==8 and'-'or' ')end print()end

输入:45-360 4

\\\|||///
\\\|||// 
\\\\|//  
--\\|/   
----o----
--//|\\--
////|\\\\
///|||\\\
///|||\\\

能够处理奇数角度

输入:15-75 8

           |/////
          |//////
          |//////
          |//////
          ///////
         |//////-
         ////--- 
         //-     
        o        
                 
                 
                 
                 
                 
                 
                 
                 

Lua, 259 characters

Slightly abuses the non-whitespace character clause to produce a dazzling display and more importantly save strokes.

m=math i=io.read():gmatch("%d+")a=i()/45 b=i()/45 r=i()for y=r,-r,-1 do for x=-r,r do c=m.atan2(y,x)/m.pi*4 c=c<0 and c+8 or c k=1+m.modf(c+.5)io.write(x==0 and y==0 and'o'or c>=a and c<=b and('-/|\\-/|\\-'):sub(k,k)or c==0 and b==8 and'-'or' ')end print()end

Input: 45-360 4

\\\|||///
\\\|||// 
\\\\|//  
--\\|/   
----o----
--//|\\--
////|\\\\
///|||\\\
///|||\\\

Able to handle odd angles

Input: 15-75 8

           |/////
          |//////
          |//////
          |//////
          ///////
         |//////-
         ////--- 
         //-     
        o        
                 
                 
                 
                 
                 
                 
                 
                 
兲鉂ぱ嘚淚 2024-09-19 05:01:23

MATLAB,188 个字符 :)

input '';[wxr]=strread(ans,'%d-%d%d');l='-/|\-/|\-';[XY]= meshgrid(-r:r);T=atan2(-Y,X)/pi*180;T=T+(T<=0)*360;T(T>w&T

注释代码:

%%# Get the string variable (enclose in quotes, e.g. '45-315 4')
input ''
%%# Extract angles and length
[w x r]=strread(ans,'%d-%d%d');
%%# Store characters
l='-/|\-/|\-';
%%# Create the grid
[X Y]=meshgrid(-r:r);
%%# Compute the angles in degrees
T=atan2(-Y,X)/pi*180;
%%# Get all the angles
T=T+(T<=0)*360;
%# Negative numbers indicate valid characters
%%# Add the characters
T(T>w&T<x)=-42;
T(T==w)=-l(1+w/45);
T(T==x)=-l(1+x/45);
%%# Add the origin
T(r+1,r+1)=-'o';
%%# Display
char(-T)

MATLAB, 188 chars :)

input '';[w x r]=strread(ans,'%d-%d%d');l='-/|\-/|\-';[X Y]=meshgrid(-r:r);T=atan2(-Y,X)/pi*180;T=T+(T<=0)*360;T(T>w&T<x)=-42;T(T==w)=-l(1+w/45);T(T==x)=-l(1+x/45);T(r+1,r+1)=-'o';char(-T)

Commented code:

%%# Get the string variable (enclose in quotes, e.g. '45-315 4')
input ''
%%# Extract angles and length
[w x r]=strread(ans,'%d-%d%d');
%%# Store characters
l='-/|\-/|\-';
%%# Create the grid
[X Y]=meshgrid(-r:r);
%%# Compute the angles in degrees
T=atan2(-Y,X)/pi*180;
%%# Get all the angles
T=T+(T<=0)*360;
%# Negative numbers indicate valid characters
%%# Add the characters
T(T>w&T<x)=-42;
T(T==w)=-l(1+w/45);
T(T==x)=-l(1+x/45);
%%# Add the origin
T(r+1,r+1)=-'o';
%%# Display
char(-T)
高速公鹿 2024-09-19 05:01:23

Mathematica 100 Chars

由于图形太完美而退出竞赛 :)

  f[x_-y_ z_]:=Graphics@Table[
                 {EdgeForm@Red,Disk[{0,0},r,{x °,y °}],{r,z,1,-1}]
                 SetAttributes[f,HoldAll]

调用
f[30-70 5]

结果

替代文本http://a.imageshack.us/img80/4294/angulosgolf。 png

替代文本 http://a.imageshack.us/img59/7892/angulos2.png

注意

>
SetAttributes[f, HoldAll];

是必需的,因为输入

    f[a-b c] 

否则被解释为

    f[(a-b*c)]

Mathematica 100 Chars

Out of competition because graphics are too perfect :)

  f[x_-y_ z_]:=Graphics@Table[
                 {EdgeForm@Red,Disk[{0,0},r,{x °,y °}],{r,z,1,-1}]
                 SetAttributes[f,HoldAll]

Invoke with
f[30-70 5]

Result

alt text http://a.imageshack.us/img80/4294/angulosgolf.png

alt text http://a.imageshack.us/img59/7892/angulos2.png

Note

The
SetAttributes[f, HoldAll];

is needed because the input

    f[a-b c] 

is otherwise interpreted as

    f[(a-b*c)]
嗼ふ静 2024-09-19 05:01:23

GNU BC,339 个字符

Gnu BC 因为 read()else 和逻辑运算符。

scale=A
a=read()/45
b=read()/45
c=read()
for(y=c;y>=-c;y--){for(x=-c;x<=c;x++){if(x==0)if(y<0)t=-2else t=2else if(x>0)t=a(y/x)/a(1)else if(y<0)t=a(y/x)/a(1)-4else t=a(y/x)/a(1)+4
if(y<0)t+=8
if(x||y)if(t==a||t==b||t==b-8){scale=0;u=(t%4);scale=A;if(u==0)"-";if(u==1)"/";if(u==2)"|";if(u==3)"\"}else if(t>a&&t<b)"x"else" "else"o"};"
"}
quit

GNU BC, 339 chars

Gnu bc because of read(), else and logical operators.

scale=A
a=read()/45
b=read()/45
c=read()
for(y=c;y>=-c;y--){for(x=-c;x<=c;x++){if(x==0)if(y<0)t=-2else t=2else if(x>0)t=a(y/x)/a(1)else if(y<0)t=a(y/x)/a(1)-4else t=a(y/x)/a(1)+4
if(y<0)t+=8
if(x||y)if(t==a||t==b||t==b-8){scale=0;u=(t%4);scale=A;if(u==0)"-";if(u==1)"/";if(u==2)"|";if(u==3)"\"}else if(t>a&&t<b)"x"else" "else"o"};"
"}
quit
笛声青案梦长安 2024-09-19 05:01:23

MATLAB 7.8.0 (R2009a) - 168 163 162 个字符

雅各布的回答,灵感来自gwell 使用任何非空白字符来填充弧线,我管理了以下解决方案:

[w x r]=strread(input('','s'),'%d-%d%d');
l='o -/|\-/|\-';
X=meshgrid(-r:r);
T=atan2(-X',X)*180/pi;
T=T+(T<=-~w)*360;
T(T>x|T<w)=-1;
T(r+1,r+1)=-90;
disp(l(fix(3+T/45)))

以及一些测试输出:

>> arc
0-135 4
\||||////
 \|||///-
  \||//--
   \|/---
    o----

我可以通过删除将其进一步减少到156个字符disp 的调用,但这会在输出之前添加额外的 ans = (这可能违反输出格式规则)。

尽管如此,我还是觉得有一些方法可以进一步减少这种情况。 ;)

MATLAB 7.8.0 (R2009a) - 168 163 162 characters

Starting from Jacob's answer and inspired by gwell's use of any non-whitespace character to fill the arc, I managed the following solution:

[w x r]=strread(input('','s'),'%d-%d%d');
l='o -/|\-/|\-';
X=meshgrid(-r:r);
T=atan2(-X',X)*180/pi;
T=T+(T<=-~w)*360;
T(T>x|T<w)=-1;
T(r+1,r+1)=-90;
disp(l(fix(3+T/45)))

And some test output:

>> arc
0-135 4
\||||////
 \|||///-
  \||//--
   \|/---
    o----

I could reduce it further to 156 characters by removing the call to disp, but this would add an extra ans = preceding the output (which might violate the output formatting rules).

Even still, I feel like there are some ways to reduce this further. ;)

执妄 2024-09-19 05:01:23

Ruby,292 276 186 个字符

x,y,r=gets.scan(/\d+/).map{|z|z.to_i};s=(-r..r);s.each{|a|s.each{|b|g=Math::atan2(-a,b)/Math::PI*180/1%360;print a|b==0?'o':g==x||g==y%360?'-/|\\'[g/45%4].chr: (x..y)===g ?'*':' '};puts}

更好的格式版本:

x, y, r = gets.scan(/\d+/).map{|z| z.to_i}
s = (-r..r)
s.each {|a|
    s.each {|b|
        g = (((Math::atan2(-a,b) / Math::PI) * 180) / 1) % 360
        print ((a | b) == 0) ? 'o' :
            (g == x || g == (y % 360)) ? '-/|\\'[(g / 45) % 4].chr :
                ((x..y) === g) ? '*' : ' '
    }
    puts
}

我确信有人比我睡得更多可以压缩这个更多...

编辑 1: 已切换内循环中的 if 语句要嵌套 ? :运算符

编辑2:将范围存储到中间变量(感谢Adrian),使用stdin而不是CLI参数(感谢Jon的澄清),消除数组以支持直接输出,修复错误其中 360 度的结束角度不会显示一条线,删除了一些不需要的括号,使用除法进行舍入而不是 .round,使用模而不是条件加法

Ruby, 292 276 186 chars

x,y,r=gets.scan(/\d+/).map{|z|z.to_i};s=(-r..r);s.each{|a|s.each{|b|g=Math::atan2(-a,b)/Math::PI*180/1%360;print a|b==0?'o':g==x||g==y%360?'-/|\\'[g/45%4].chr: (x..y)===g ?'*':' '};puts}

Nicer-formatted version:

x, y, r = gets.scan(/\d+/).map{|z| z.to_i}
s = (-r..r)
s.each {|a|
    s.each {|b|
        g = (((Math::atan2(-a,b) / Math::PI) * 180) / 1) % 360
        print ((a | b) == 0) ? 'o' :
            (g == x || g == (y % 360)) ? '-/|\\'[(g / 45) % 4].chr :
                ((x..y) === g) ? '*' : ' '
    }
    puts
}

I'm sure someone out there who got more sleep than I did can condense this more...

Edit 1: Switched if statements in inner loop to nested ? : operator

Edit 2: Stored range to intermediate variable (thanks Adrian), used stdin instead of CLI params (thanks for the clarification Jon), eliminated array in favor of direct output, fixed bug where an ending angle of 360 wouldn't display a line, removed some un-needed parentheses, used division for rounding instead of .round, used modulo instead of conditional add

止于盛夏 2024-09-19 05:01:23

Ruby,168 个字符

需要 Ruby 1.9 才能工作

s,e,r=gets.scan(/\d+/).map &:to_i;s/=45;e/=45;G=-r..r;G.map{|y|G.map{|x|a=Math.atan2(-y,x)/Math::PI*4%8;print x|y!=0?a==s||a==e%8?'-/|\\'[a%4]:a<s||a>e ?' ':8:?o};puts}

可读版本:

start, _end, radius = gets.scan(/\d+/).map &:to_i
start /= 45
_end /= 45

(-radius..radius).each {|y|
    (-radius..radius).each {|x|
        angle = Math.atan2(-y, x)/Math::PI * 4 % 8
        print x|y != 0 ? angle==start || angle==_end%8 ? '-/|\\'[angle%4] : angle<start || angle>_end ? ' ' : 8 : ?o
    }
    puts
}

Ruby, 168 characters

Requires Ruby 1.9 to work

s,e,r=gets.scan(/\d+/).map &:to_i;s/=45;e/=45;G=-r..r;G.map{|y|G.map{|x|a=Math.atan2(-y,x)/Math::PI*4%8;print x|y!=0?a==s||a==e%8?'-/|\\'[a%4]:a<s||a>e ?' ':8:?o};puts}

Readable version:

start, _end, radius = gets.scan(/\d+/).map &:to_i
start /= 45
_end /= 45

(-radius..radius).each {|y|
    (-radius..radius).each {|x|
        angle = Math.atan2(-y, x)/Math::PI * 4 % 8
        print x|y != 0 ? angle==start || angle==_end%8 ? '-/|\\'[angle%4] : angle<start || angle>_end ? ' ' : 8 : ?o
    }
    puts
}
妄断弥空 2024-09-19 05:01:23

Perl - 388 个字符

由于提出一个我自己无法解决的挑战是不公平的,这里有一个解决方案,它使用字符串替换而不是三角函数,并大量利用您友好的邻居 Perl 将裸字视为字符串的能力。它必然有点长,但为了独特性也许很有趣:

($x,$y,$r)=split/\D/,<>;for(0..$r-1){$t=$r-1-$_;
$a.=L x$_.D.K x$t.C.J x$t.B.I x$_."\n";
$b.=M x$t.F.N x$_.G.O x$_.H.P x$t."\n"}
$_=$a.E x$r.o.A x$r."\n".$b;$x/=45;$y/=45;$S=' ';
sub A{$v=$_[0];$x==$v||$y==$v?$_[1]:$x<$v&&$y>$v?x:$S}
sub B{$x<=$_[0]&&$y>$_[0]?x:$S}
@a=!$x||$y==8?'-':$S;
push@a,map{A$_,'\\'.qw(- / | \\)[$_%4]}1..7;
push@a,!$x?x:$S,map{B$_}1..7;
eval"y/A-P/".(join'',@a)."/";print

所有换行符都是可选的。这相当简单:

  • 获取用户输入。
  • 构建图案的顶部 ($a) 和底部 ($b) 部分。
  • 构建完整的模式 ($_)。
  • 定义一个sub A来获取角度的填充字符。
  • 定义一个sub B来获取区域的填充字符。
  • 使用 AB 构建替换字符数组 (@a)。
  • 执行替换并打印结果。

生成的格式如下所示,对于 R = 4:

DKKKCJJJB
LDKKCJJBI
LLDKCJBII
LLLDCBIII
EEEEoAAAA
MMMFGHPPP
MMFNGOHPP
MFNNGOOHP
FNNNGOOOH

其中 AH 表示角度,IP 表示区域。

(诚​​然,这可能会进一步解决。当写成一个列表时,@a 上的操作给了我不正确的输出,大概与 mapmap 的播放方式有关。代码>$_。)

Perl - 388 characters

Since it wouldn't be fair to pose a challenge I couldn't solve myself, here's a solution that uses string substitution instead of trigonometric functions, and making heavy use of your friendly neighbourhood Perl's ability to treat barewords as strings. It's necessarily a little long, but perhaps interesting for the sake of uniqueness:

($x,$y,$r)=split/\D/,<>;for(0..$r-1){$t=$r-1-$_;
$a.=L x$_.D.K x$t.C.J x$t.B.I x$_."\n";
$b.=M x$t.F.N x$_.G.O x$_.H.P x$t."\n"}
$_=$a.E x$r.o.A x$r."\n".$b;$x/=45;$y/=45;$S=' ';
sub A{$v=$_[0];$x==$v||$y==$v?$_[1]:$x<$v&&$y>$v?x:$S}
sub B{$x<=$_[0]&&$y>$_[0]?x:$S}
@a=!$x||$y==8?'-':$S;
push@a,map{A$_,'\\'.qw(- / | \\)[$_%4]}1..7;
push@a,!$x?x:$S,map{B$_}1..7;
eval"y/A-P/".(join'',@a)."/";print

All newlines are optional. It's fairly straightforward:

  • Grab user input.
  • Build the top ($a) and bottom ($b) parts of the pattern.
  • Build the complete pattern ($_).
  • Define a sub A to get the fill character for an angle.
  • Define a sub B to get the fill character for a region.
  • Build an array (@a) of substitution characters using A and B.
  • Perform the substitution and print the results.

The generated format looks like this, for R = 4:

DKKKCJJJB
LDKKCJJBI
LLDKCJBII
LLLDCBIII
EEEEoAAAA
MMMFGHPPP
MMFNGOHPP
MFNNGOOHP
FNNNGOOOH

Where A-H denote angles and I-P denote regions.

(Admittedly, this could probably be golfed further. The operations on @a gave me incorrect output when written as one list, presumably having something to do with how map plays with $_.)

时光病人 2024-09-19 05:01:23

C# - 325 319 个

using System;class P{static void Main(){var s=Console.ReadLine().Split(' ');
var d=s[0].Split('-');int l=s[1][0]-48,x,y,r,a=int.Parse(d[0]),b=int.Parse(d[1]);
for(y=l;y>=-l;y--)for(x=-l;x<=l;)Console.Write((x==0&&y==0?'o':a<=(r=((int)
(Math.Atan2(y,x)*57.3)+360)%360)&&r<b||r==b%360?
@"-/|\"[r/45%4]:' ')+(x++==l?"\n":""));}}

字符 换行符不重要。

输入/输出示例

45-180 8
\||||||||////////
\\|||||||///////
\\\||||||//////
\\\\|||||/////
\\\\\||||////
\\\\\\|||///
\\\\\\\||//
\\\\\\\\|/
--------o
135-360 5
\
\\
\\\
\\\\
\\\\\
-----o-----
----/|\\\\\
---//||\\\\
--///|||\\\
-////||||\\
/////|||||\

C# - 325 319 chars

using System;class P{static void Main(){var s=Console.ReadLine().Split(' ');
var d=s[0].Split('-');int l=s[1][0]-48,x,y,r,a=int.Parse(d[0]),b=int.Parse(d[1]);
for(y=l;y>=-l;y--)for(x=-l;x<=l;)Console.Write((x==0&&y==0?'o':a<=(r=((int)
(Math.Atan2(y,x)*57.3)+360)%360)&&r<b||r==b%360?
@"-/|\"[r/45%4]:' ')+(x++==l?"\n":""));}}

Newlines not significant.

Sample input/output

45-180 8
\||||||||////////
\\|||||||///////
\\\||||||//////
\\\\|||||/////
\\\\\||||////
\\\\\\|||///
\\\\\\\||//
\\\\\\\\|/
--------o
135-360 5
\
\\
\\\
\\\\
\\\\\
-----o-----
----/|\\\\\
---//||\\\\
--///|||\\\
-////||||\\
/////|||||\
挽清梦 2024-09-19 05:01:23

Java - 304 个字符


class A{public static void main(String[]a){String[]b=a[0].split("-");int e=new Integer(b[1]),r=new Integer(a[1]),g,x,y=r;for(;y>=-r;y--)for(x=-r;x<=r;)System.out.print((x==0&y==0?'o':new Integer(b[0])<=(g=((int)(Math.atan2(y,x)*57.3)+360)%360)&g<e|g==e%360?"-/|\\".charAt(g/45%4):' ')+(x++<r?"":"\n"));}}

更可读的版本:

class A{
 public static void main(String[]a){
  String[]b=a[0].split("-");
  int e=new Integer(b[1]),r=new Integer(a[1]),g,x,y=r;
  for(;y>=-r;y--)for(x=-r;x<=r;)System.out.print((
   x==0&y==0
    ?'o'
    :new Integer(b[0])<=(g=((int)(Math.atan2(y,x)*57.3)+360)%360)&g<e|g==e%360
     ?"-/|\\".charAt(g/45%4)
     :' '
   )+(x++<r?"":"\n"));
 }
}

Java - 304 chars


class A{public static void main(String[]a){String[]b=a[0].split("-");int e=new Integer(b[1]),r=new Integer(a[1]),g,x,y=r;for(;y>=-r;y--)for(x=-r;x<=r;)System.out.print((x==0&y==0?'o':new Integer(b[0])<=(g=((int)(Math.atan2(y,x)*57.3)+360)%360)&g<e|g==e%360?"-/|\\".charAt(g/45%4):' ')+(x++<r?"":"\n"));}}

More readable version:

class A{
 public static void main(String[]a){
  String[]b=a[0].split("-");
  int e=new Integer(b[1]),r=new Integer(a[1]),g,x,y=r;
  for(;y>=-r;y--)for(x=-r;x<=r;)System.out.print((
   x==0&y==0
    ?'o'
    :new Integer(b[0])<=(g=((int)(Math.atan2(y,x)*57.3)+360)%360)&g<e|g==e%360
     ?"-/|\\".charAt(g/45%4)
     :' '
   )+(x++<r?"":"\n"));
 }
}
苦笑流年记忆 2024-09-19 05:01:23

C(902 字节)

这不使用三角函数(像原始的 perl 版本),所以它相当“臃肿”。无论如何,这是我的第一个代码高尔夫提交:

#define V(r) (4*r*r+6*r+3)
#define F for(i=0;i<r;i++)
#define C ;break;case
#define U p-=2*r+2,
#define D p+=2*r+2,
#define R *++p=
#define L *--p=
#define H *p='|';
#define E else if
#define G(a) for(j=0;j<V(r)-1;j++)if(f[j]==i+'0')f[j]=a;
#define O(i) for(i=0;i<2*r+1;i++){
main(int i,char**v){char*p,f[V(8)];
int j,m,e,s,x,y,r;p=*++v;x=atoi(p);while(*p!=45)p++;
char*h="0123";y=atoi(p+1);r=atoi(*++v);
for(p=f+2*r+1;p<f+V(r);p+=2*r+2)*p=10;
*(p-2*r-2)=0;x=x?x/45:x;y/=45;s=0;e=2*r;m=r;p=f;O(i)O(j)
if(j>e)*p=h[0];E(j>m)*p=h[1];E(j>s)*p=h[2];else*p=h[3];p++;}
if(i+1==r){h="7654";m--;e--;}E(i==r){s--;}E(i>r){s--;e++;}
else{s++;e--;}p++;}for(p=f+V(r)/2-1,i=0;i<r;i++)*++p=48;
for(i=0;i<8;i++)if(i>=x&&i<y){G(64);}else G(32);
y=y==8?0:y;q:p=f+V(r)/2-1;*p='o';switch(x){
C 0:F R 45 C 1:F U R 47 C 2:F U H C 3:F U L 92
C 4:F L 45 C 5:F D L 47 C 6:F D H C 7:F D R 92;}
if(y!=8){x=y;y=8;goto q;}puts(f);}

另外,#define 看起来相当丑陋,但它们节省了大约 200 个字节,所以无论如何我都保留了它们。它是有效的 ANSI C89/C90,编译时几乎没有警告(两个关于 atoiputs 以及两个关于 main 的残缺形式)。

C (902 byte)

This doesn't use trigonometric functions (like the original perl version), so it's quite ``bloated''. Anyway, here is my first code-golf submission:

#define V(r) (4*r*r+6*r+3)
#define F for(i=0;i<r;i++)
#define C ;break;case
#define U p-=2*r+2,
#define D p+=2*r+2,
#define R *++p=
#define L *--p=
#define H *p='|';
#define E else if
#define G(a) for(j=0;j<V(r)-1;j++)if(f[j]==i+'0')f[j]=a;
#define O(i) for(i=0;i<2*r+1;i++){
main(int i,char**v){char*p,f[V(8)];
int j,m,e,s,x,y,r;p=*++v;x=atoi(p);while(*p!=45)p++;
char*h="0123";y=atoi(p+1);r=atoi(*++v);
for(p=f+2*r+1;p<f+V(r);p+=2*r+2)*p=10;
*(p-2*r-2)=0;x=x?x/45:x;y/=45;s=0;e=2*r;m=r;p=f;O(i)O(j)
if(j>e)*p=h[0];E(j>m)*p=h[1];E(j>s)*p=h[2];else*p=h[3];p++;}
if(i+1==r){h="7654";m--;e--;}E(i==r){s--;}E(i>r){s--;e++;}
else{s++;e--;}p++;}for(p=f+V(r)/2-1,i=0;i<r;i++)*++p=48;
for(i=0;i<8;i++)if(i>=x&&i<y){G(64);}else G(32);
y=y==8?0:y;q:p=f+V(r)/2-1;*p='o';switch(x){
C 0:F R 45 C 1:F U R 47 C 2:F U H C 3:F U L 92
C 4:F L 45 C 5:F D L 47 C 6:F D H C 7:F D R 92;}
if(y!=8){x=y;y=8;goto q;}puts(f);}

also, the #defines look rather ugly, but they save about 200 bytes so I kept them in, anyway. It is valid ANSI C89/C90 and compiles with very few warnings (two about atoi and puts and two about crippled form of main).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文