现在在监狱里


18

挑战

给定一个整数n(其中4<=n<=10**6)作为输入,使用下面示例中的符号创建一个ASCII艺术“监狱门” * ,该字体测量n-1字符宽和n字符高。


╔╦╗
╠╬╣
╠╬╣
╚╩╝

使用的字符如下:

┌───────────────┬─────────┬───────┐
│ Position      │ Symbol  │ Char  │
├───────────────┼─────────┼───────┤
│ Top Left      │    ╔    │ 9556  │
├───────────────┼─────────┼───────┤
│ Top           │    ╦    │ 9574  │
├───────────────┼─────────┼───────┤
│ Top Right     │    ╗    │ 9559  │
├───────────────┼─────────┼───────┤
│ Right         │    ╣    │ 9571  │
├───────────────┼─────────┼───────┤
│ Bottom Right  │    ╝    │ 9565  │
├───────────────┼─────────┼───────┤
│ Bottom        │    ╩    │ 9577  │
├───────────────┼─────────┼───────┤
│ Bottom Left   │    ╚    │ 9562  │
├───────────────┼─────────┼───────┤
│ Left          │    ╠    │ 9568  │
├───────────────┼─────────┼───────┤
│ Inner         │    ╬    │ 9580  │
└───────────────┴─────────┴───────┘

规则

  • 只要标准I / O规则允许,您可以通过任何合理,方便的方式进行输入。
  • 为了解决这一挑战,在用于构建“门”的符号为多字节字符的语言中,它们可能会以单个字节的形式计入您的分数。
  • 所有其他字符(单字节或多字节)应视为正常字符。
  • 输出可能不包含任何尾随空格,但如果绝对必要,则允许尾随换行符。
  • 这是因此最低字节数为准。

测试用例

Input: 4
Output:
╔╦╗
╠╬╣
╠╬╣
╚╩╝

Input: 8
Output:
╔╦╦╦╦╦╗
╠╬╬╬╬╬╣
╠╬╬╬╬╬╣
╠╬╬╬╬╬╣
╠╬╬╬╬╬╣
╠╬╬╬╬╬╣
╠╬╬╬╬╬╣
╚╩╩╩╩╩╝

Input: 20
Output:
╔╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╦╗
╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣
╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣
╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣
╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣
╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣
╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣
╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣
╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣
╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣
╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣
╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣
╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣
╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣
╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣
╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣
╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣
╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣
╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣
╚╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╩╝

*是的,我知道它越大,看起来越像监狱门!:D


4
如果您可以同时输入x和y尺寸,那就太好了
Beta Decay

15
它在沙盒中的时间已经足够长,您可以提出建议。
毛茸茸的

我的程序甚至可以在其代码页中包含低谷吗?如果不是,那么"'Z“ζ允许以一个字节为单位(或2个字节)为单位吗?(推送9580,转换为unicode)?
dzaima

@dzaima 为了解决这一挑战,在用于“门”的符号占用多个字节的语言中,它们可能会在您的乐谱中被视为一个字节。
Okx

@Okx`╬`-不能以任何字节数重新设置,"'Z“ζ等于一个字节就好像是在javascript中"╬"花费1字节
dzaima

Answers:


9

爪哇8,156个 151 148 118字节

n->{String a="╔",b="╠",c="╚";for(int i=n;i-->3;a+="╦",b+="╬")c+="╩";a+="╗\n";for(b+="╣\n";n-->2;)a+=b;return a+c+"╝";}

在打完5个字节后,通过创建@raznagul C#(.NET Core)答案端口创建了-30个字节。

在线尝试。

旧的148字节答案:

n->{String r="╔";int i=n,j;for(;i-->3;r+="╦");r+="╗\n╠";for(i=n;i-->2;r+="╣\n"+(i>2?"╠":"╚"))for(j=n;j-->3;r+="╬");for(;n-->3;r+="╩");return r+"╝";}

-5个字节,感谢@raznagul

说明:

在这里尝试。

n->{                   // Method with integer parameter and String return-type
  String r="╔";        //  Result String (starting with the top-left corner)
  int i=n,j;           //  Indexes `i` and `j`
  for(;i-->3;          //  Loop (1) `n`-3 times:
      r+="╦"           //   Append result with top edges
  );                   //  End of loop (1)
  r+="╗\n╠";           //  Append result with the top-right corner, new-line and left edge
  for(i=n;i-->2        //  Loop (2) `n`-2 times
      ;                //     After every iteration:
      r+="╣\n"         //   Append result with right edge and new-line
      +(i>2?"╠":"╚"))  //    + either the left edge or bottom-left corner
    for(j=n;j-->3;     //   Inner loop (3) `n`-3 times:
        r+="╬"         //    Append result with middle section
    );                 //   End of inner loop (3)
                       //  End of loop (2) (implicit / single-line body)
  for(;n-->3;          //  Loop (4) `n`-3 times:
    r+="╩"             //   Append result with bottom edges
  );                   //  End of loop (4)
  return r+"╝";        //  Return result with its bottom-right corner
}                      // End of method

您可以使用转义/字符代码保存任何字节,而不是对其进行硬编码吗?
TheLethalCoder

@TheLethalCoder也许,但是由于质询规则状态,我们可以将符号每个计数为1个字节,因此它可能会更短(因此,从156个字节开始计数而不是实际的176个字节计数)。但是请随意尝试一些使字符代码更短的事情。
凯文·克鲁伊森

啊,我错过了规则的那部分。
TheLethalCoder

2
转到(-->)运算符的+1 。
raznagul

1
如果您使用i-->3i-->2j-->3´ you can save 5 bytes by removing the 正= 3`和n+1
raznagul

7

木炭,34-5 = 29字节

A⁻N³γUB╬↓×╠γ╠¶╚×╩γ‖BOγ‖BO↑⁺γ

在线尝试!链接是详细版本的代码。箱形图字符减少5个字节。

ReflectOverlapOverlap(0)应该等同于,ReflectMirror()但Charcoal只是做了一个ReflectTransform()替代,否则此解决方案也适用于n=3。这是一种变通方法,显示了38-5 n=3= 33字节时会发生什么:

A⁻N³γUB╬↓×╠γ╠¶╚×╩γ¿γ‖BOγ‖M‖BO↑⁺γ¹

更好的是,如果可以的话ReflectOverlapOverlap(0),但是我不花心地支持n=3,那么我可以用31-4 = 27个字节来做到这一点:

A⁻N³γUB╬↓×╠γ╚×╩γ‖BOγ‖BO↑⁻γ¹

1
嗯,不知道木炭也反映出/镜子和这样的。“ 由于某些原因,木炭的字节计数器不工作。 ”也许木炭的字节计数器不工作,因为这些字符不是其代码页的一部分?您可以根据每个虽则挑战规则将它们算作1个字节,所以这确实是27
凯文Cruijssen

@KevinCruijssen这取决于您使用的运算符。(我必须每次都回去仔细检查;其中有很多并且令人困惑……)
尼尔(Neil

@Neil Oops,这是一个错误,将尽快修复。感谢您找到它!
仅ASCII码

@Neil同样由于某种原因,它在n = 4时被破坏了
ASCII码



6

Haskell,75个字节

w i(a:b:c)=a:(b<$[4..i])++c
f n=concat$w(n+1)$w n<$>["╔╦╗\n","╠╬╣\n","╚╩╝"]  

在线尝试!

函数w接受一个整数i和一个列表,其中a是列表的第一个,b第二个元素和c列表的其余部分,并创建一个新列表a,其后是的i-3副本b,然后是cw首先在列表的每个元素上应用["╔╦╗\n","╠╬╣\n","╚╩╝"],然后在结果列表上再次应用(用i增加1)。连接成一个列表。


什么是<$运算符?只是>>的参数翻转了吗?
Aneesh Durg

@AneeshDurg:<$最初来自Data.Functor,已经放入Prelude。与几乎相同>>a <$ b将的每个元素替换ba,而b >> a期望a是一个列表,并连接的b副本长度a[1,2] >> "aa"- > "aaaa""aa" <$ [1,2]- > ["aa","aa"]。注意:'x' <$ [1,2]等于[1,2] >> "x"
nimi 2015年

5

Vim,29个字节

3<C-x>C╔╦╗
╠╬╣
╚╩╝<Esc>h<C-v>kkx@-Pjyy@-p

由于有控制字符,所以这是xxd转储:

00000000: 3318 43e2 9594 e295 a6e2 9597 0de2 95a0  3.C.............
00000010: e295 ace2 95a3 0de2 959a e295 a9e2 959d  ................
00000020: 1b68 166b 6b78 402d 506a 7979 402d 70    .h.kkx@-Pjyy@-p

在线尝试!(V解释器似乎在使用外来字符时遇到问题,因此该链接使用了更多平凡的字符。)

说明

3<C-x>     " Decrement the number by 3
C╔╦╗
╠╬╣
╚╩╝<Esc>   " Cut the number (goes in @- register) and enter the "template"
h<C-v>kkx  " Move to the middle column, highlight and cut it
@-P        " Paste @- copies of the cut column
jyy        " Move to the middle line and copy it
@-p        " Paste @- copies of the copied line

确认一下:难道只有TIO解释器使这些符号窒息?
毛茸茸的

@Shaggy是的,它引发了有关Latin-1的Python错误,而不是Vim错误。(我之所以使用V页面是因为TIO没有普通的Vim页面,而我认为V使用的是Latin-1。)我机器上的Vim的字符没有任何问题。
乔丹

5

GNU sed,74 +1 = 75字节

+1字节的-r标志。将输入作为一元数。

s/1111(1*)/╔╦\1╗\n;\1╠╬\1╣\n╚╩\1╝/
:
s/(.)1/\1\1/
t
s/;([^;\n]+)/\1\n\1/
t

在线尝试!

说明

这很简单。假设输入为6(一元111111)。第一行删除4 1s并将其余输入转换为:

╔╦11╗
;11╠╬11╣
╚╩11╝

循环中的第三行1用前面的字符替换每一行。这将创建我们的列:

╔╦╦1╗
;11╠╬11╣
╚╩11╝

╔╦╦╦╗
;11╠╬11╣
╚╩11╝

...

╔╦╦╦╗
;;;╠╬╬╬╣
╚╩╩╩╝

注意,这也复制了;字符。最后,循环中的第五行将每个;字符替换为以下行的副本:

╔╦╦╦╗
;;╠╬╬╬╣
╠╬╬╬╣
╚╩╩╩╝

╔╦╦╦╗
;╠╬╬╬╣
╠╬╬╬╣
╠╬╬╬╣
╚╩╩╩╝

╔╦╦╦╗
╠╬╬╬╣
╠╬╬╬╣
╠╬╬╬╣
╠╬╬╬╣
╚╩╩╩╝

4

果冻,33 字节

...是33吗?-从1个字节的字符串文字(代码页索引)转换为Unicode字符花费5。

_2µ“€ðБẋ“¡Ø¤“©ßµ‘js3x€2¦€’+⁽"7ỌY

完整程序打印结果。

在线尝试!

怎么样?

_2µ“€ðБẋ“¡Ø¤“©ßµ‘js3x€2¦€’+⁽"7ỌY - Main link: n
_2                                - subtract 2
  µ                               - start a new monadic chain with n-2 on the left
   “€ðБ                          - code page indexes [12, 24, 15] (middle row characters)
        ẋ                         - repeat n-2 times (make unexpanded middle rows)
         “¡Ø¤“©ßµ‘                - code page indexes [[0,18,3],[6,21,9]] (top & bottom)
                  j               - join (one list: top + middles + bottom)
                   s3             - split into threes (separate into the unexpanded rows)
                          ’       - decrement n-2 = n-3
                        ¦€        - sparsely apply to €ach:
                       2          -   at index 2
                     x€           -   repeat €ach (expand centre of every row to n-3 chars)
                            ⁽"7   - literal 9556
                           +      - addition (0->9556; 12->9568; etc...)
                               Ọ  - cast to characters (╠; ╔; etc...)
                                Y - join with newlines
                                  - implicit print

@Shaggy-我使用9个字节表示字符串文字中的字符-这些是代码页索引。Y末尾的5个字节+⁽"7Ọ将9556添加到这些字符,然后强制转换为字符。他们(5个)免费吗?我感觉就像可以直接使用Unicode字符一样。(我也可以使用实际字符而不是代码页索引,并使用映射来获取更多字节)。
乔纳森·艾伦,

不。经过讨论,得出的结论是,只有char本身始终可以算作1,不能算作其他任何表示形式。
暴民埃里克(Erik the Outgolfer)'17年

3

Python 3,75个字节

n=int(input())-3
print("╔"+"╦"*n+"╗\n"+("╠"+"╬"*n+"╣\n")*-~n+"╚"+"╩"*n+"╝")

在线尝试!


您可以从以下位置开始打高尔夫球n-3n=int(input())-3;print("╔"+"╦"*n+"╗\n"+("╠"+"╬"*n+"╣\n")*(n+1)+"╚"+"╩"*n+"╝")
Kevin Cruijssen

另外,n+1等效于-~n
Leaky Nun

3

Dyalog APL,71个字节

{('╔',('╠'⍴⍨⍵-2),'╚'),((⍵-3)\⍪('╦',('╬'⍴⍨⍵-2),'╩')),'╗',('╣'⍴⍨⍵-2),'╝'}

在线尝试!


您绝对可以打高尔夫球。例如,你可以随时更换(some expr)f Y使用Y f⍨ some expr
亚当

@Adám我知道,它正在进行中,我目前不在计算机上
Uriel

3

Japt60 52 49 48 36字节

"╔{Uµ3 ç'╦}╗{UÄ ç"
╠{ç'╬}╣"}
╚{ç'╩}╝

在线尝试!

另一个版本(47字节+ -R标记)

"8{Uµ3 ç'J};{UÄ ç"D{ç'P}G"}>{ç'M}A"c_+9500ÃòU+2

需要-R标志(添加到输入字段中)。在线尝试!

它是如何工作的?

因为我最初认为“门字符”的成本超过一个字节,所以我认为通过编码它们可以节省很多字节。然后,我从字符代码中减去了9500,这给我留下了字符8J; DPG >MA,每个字符仅花费一个字节。然后,我可以将9500添加到每个字符代码中,一切都会好起来的。

 "8{   Uµ 3 ç'J}  ;{   UÄ  ç"D{   ç'P}  G"}  >{   ç'M}  A"c_+9500Ã òU+2
 "8"+((U-=3 ç'J)+";"+((U+1 ç"D"+(Uç'P)+"G")+">"+(Uç'M)+"A"c_+9500} òU+2
 "8"+           +";"+                      +">"+      +"A"              # Take this string of characters
     ((U-=3 ç'J)                                                        # Repeat "J" input - 3 times
                     ((    ç              )                             # Repeat the string
                            "D"+(Uç'P)+"G"                              # "D" + input-3 times "P" + "G"
                       U+1                                              # Input - 2 times
                                                (Uç'M)                  # Repeat "M" input - 3 times
                                                          c_     }      # Take the character code of every character
                                                            +9500       # Add 9500 to it
                                                          c_     }      # And convert it back to a character
                                                                   òU+2 # Split this string on every (input)th character
                                                                        # Print the resulting array, joined with newlines.

哦,是的,你是对的。
路加福音



2

迅捷,161字节

let f:(String,Int)->String={String(repeating:$0,count:$1)};var p={i in print("╔\(f("╦",i-3))╗\n\(f("╠\(f("╬",i-3))╣\n",i-2))╚\(f("╩",i-3))╝")}

未打高尔夫球:

let f:(String,Int)->String = {
    String(repeating:$0,count:$1)
}
var p={ i in
    print("╔\(f("╦",i-3))╗\n\(f("╠\(f("╬",i-3))╣\n",i-2))╚\(f("╩",i-3))╝")
}

你可以在这里尝试这个答案


2

QBIC,78个字节

[:-3|X=X+@╦`]?@╔`+X+@╗`[b-2|Y=Z[b-3|Y=Y+@╬`]?@╠`+Y+@╣`}[b-3|W=W+@╩`]?@╚`+W+@╝`

幸运的是,室外单元门中使用的所有符号都在QBasic代码页上。

说明

            The TOP
[:-3|       FOR a = 1 to n-3 (-1 for the width, -2 for beginning and end)
X=X+@╦`]    Build out X$ with the parts of the middle-top
?@╔`+X+@╗`  Then print that preceded and followed by the corners
┘           Syntactic linebreak

            The MIDDLE
[b-2|       FOR c = 1 to n-2 (all the middle rows)
Y=Z         Reset Y$ to ""
            Build up the middle rows in the same way as the top,
            just with different symbols and once for each middle row
[b-3|Y=Y+@╬`]?@╠`+Y+@╣`
}           Close the FOR loop
            The BOTTOM
            The same as the top, just with different symbols
[b-3|W=W+@╩`]?@╚`+W+@╝`

样本输出

Command line: 7

╔╦╦╦╦╗
╠╬╬╬╬╣
╠╬╬╬╬╣
╠╬╬╬╬╣
╠╬╬╬╬╣
╠╬╬╬╬╣
╚╩╩╩╩╝

1
+1,用于使用在其默认代码页中实际上将它们作为一个字节字符的语言。
约书亚记

您可以添加TIO(或同等水平)吗?
毛茸茸的


1
哦耶!我保证,最终,我保证!:D
毛茸茸的

@Shaggy好吧,不要太习惯这个想法。我刚刚找到了运行QBasic的Dosbox的Emscripten构建版本。我将在下个月尝试将其用于QBIC,因此可能会出现网络环境……
steenbergh

2

PHP,131字节,113个字符

for($z=str_split("╔╠╚╦╬╩╗╣╝",3);$i<$a=$argn;)echo str_pad($z[$b=$i++?$i<$a?1:2:0],3*$a-3,$z[$b+3]),$z[$b+6],"\n";

在线尝试!

PHP,133字节,115个字符

for(;$i<$a=$argn;)echo str_pad(["╔","╠","╚"][$b=$i++?$i<$a?1:2:0],3*$a-3,["╦","╬","╩"][$b]),["╗","╣","╝"][$b],"\n";

在线尝试!


2

JavaScript(ES6),86个字节

这比其他JS答案长得多,但是我想尝试一下其他方法。

n=>(g=i=>--i?`╬╣╠╩╝╚╦╗╔
`[(j=i%n)?!--j+2*!(n-j-2)+3*(i<n)+6*(i>n*n-n):9]+g(i):'')(n*n)

怎么样?

我们为网格的每个边缘分配权重:1代表右侧,2代表左侧,3代表底部,6代表顶部。权重之和给出了要使用的字符的索引。

8666667    0 1 2 3 4 5 6 7 8
2000001    ╬ ╣ ╠ ╩ ╝ ╚ ╦ ╗ ╔
2000001
2000001
2000001
2000001
2000001
5333334

演示版


2

JavaScript(ES6),80 74字节

n=>`╔${"╦"[a="repeat"](n-=3)}╗${`
╠${"╬"[a](n)}╣`[a](n+1)}
╚${"╩"[a](n)}╝`

您可以将符号每个计为一个字节,即80个字节。而且您应该能够更好地利用模板文字来节省一些字节;)
Shaggy

如果可以找到一个本机将采用CP437输入的ES6实现,则只能将符号算作一个字节。
user5090812

@ user5090812,这是针对此挑战的津贴。
毛茸茸的

@ user5090812无需找到该实现,因为质询规则声明“ 对于本质询而言,在用于“门”的符号占用多个字节的语言中,它们可能被计入您的分数,每个为单个字节。 “因此,它的字节数为80字节,而不是98(如果我计数正确的话)。
Kevin Cruijssen

好吧,这是一个坏规则。它消除了寻找更好的字符存储方式的所有动机。
路加福音

2

红宝石, 54 52字节

-2个字节感谢ymbirtt。

->n{?╔+?╦*(n-=3)+"╗
"+(?╠+?╬*n+"╣
")*-~n+?╚+?╩*n+?╝}

在线尝试!

不打高尔夫球

这太无聊了:

->n{
   ?╔ + ?╦ * (n-=3) + "╗\n" + 
  (?╠ + ?╬ * n      + "╣\n") * -~n + 
   ?╚ + ?╩ * n      + ?╝
}

您可以(n+1)通过写一些内容来缩短一点-~n-运算符优先级也可以节省括号。
ymbirtt

2

Java 8,102 + 101字节

java.util.function.BiFunction<String,Integer,String>r=(c,n)->"".valueOf(new char[n]).replace("\0",c);

n->{n-=3;return "╔"+r.apply("╦",n)+"╗\n"+r.apply('╠'+r.apply("╬",n)+"╣\n",-~n)+"╚"+r.apply("╩",n)+"╝";}

这是另一个相同长度的字符串转发器:

java.util.function.BiFunction<String,Integer,String>r=(c,n)->{String p=c;for(;--n>0;p+=c);return p;}

在线尝试!


不错,您可以让您的方法比我的回答还要低。首先,可以通过使用一个Java 7方法代替它降低到78 + 72个字节(总共150) BiFunctionn->{n-=3;return"╔"+r("╦",n)+"╗\n"+r("╠"+r("╬",n)+"╣\n",-~n)+"╚"+r("╩",n)+"╝";}String r(String c,int n){return c.valueOf(new char[n]).replace("\0",c);} 在线尝试。而且第二种方法也可以更改为String r(String c,int n){String r=c;for(;n-->1;r+=c);return r;}(63个字节),因此总共变为141个字节
Kevin Cruijssen

更正后,您甚至可以将其降低到130个字节n->"╔"+r("╦",n-=3)+"╗\n"+r("╠"+r("╬",n)+"╣\n",-~n)+"╚"+r("╩",n)+"╝"String r(String c,int n){String r=c;for(;n-->1;r+=c);return r;} 在线尝试。
凯文·克鲁伊森

2

C#(.NET Core)得分123(141字节)得分118(136字节)

n=>{string a="╔",b="╠",c="╚";for(int i=3;i++<n;a+="╦",b+="╬")c+="╩";a+="╗\n";for(b+="╣\n";n-->2;)a+=b;return a+c+"╝";}

在线尝试!

-5个字节,感谢@KevinCruijssen

说明:

n => 
{
    string a = "╔", b = "╠", c = "╚"; //Initialize the first, last and the middle lines with the starting character.
    for (int i = 3; i++ < n;          //Loop n-3 times
        a += "╦", b += "╬")           //Add the middle character to the first and middle line.
        c += "╩";                     //Add the middle character to the last line.
    a += "╗\n";                       //Add the end character to the first line.
    for (b += "╣\n";                  //Add the end character to the first line.
        n-- > 2;)                     //Loop n-2 times.
        a += b;                       //Add the middle line to the first line.
    return a + c + "╝";               //Add the last line and the final character and return.
}

1
好的回答,我+1。我知道已经有一段时间了,但是您可以将“在线尝试”更改b+="╣\n";c+="╝";for(;n-->2;)a+=b;return a+c;};为5个字节for(b+="╣\n";n-->2;)a+=b;return a+c+"╝";}
凯文·克鲁伊森

@KevinCruijssen:谢谢。
raznagul

2

Stax,23 个字节

÷ÅoB↔╒╢Fm|╦a⌐á5µ┐»♫÷d╕Ñ

运行并调试

这是非高尔夫版本。有趣的是,stax 使用文字字符实际上要小一些,因为将它们包含为文字会阻止源打包。

"2Pfj_EQGG]T"!  packed representation of the 9 characters
3/              split into groups of 3
GG              call into trailing program twice
m               print each row
}               trailing program begins here
1|xv\           [1, --x - 1]; x starts as original input
:B              repeat each element corresponding number of times
                effectively, this repeats the internal row of the matrix
M               transpose door; this way it expands the two dimensions

运行这个


1

Mathematica,106个字节

(T[a_,b_,c_]:=a<>Table[b,#-3]<>c;w=Column;w[{T["╔","╦","╗"],w@Table[T["╠","╬","╣"],#-2],T["╚","╩","╝"]}])&

您可以添加一个TIO(或等效版本)吗?
毛茸茸的

1
goto sandbox.open.wolframcloud.com/app/objects 粘贴代码(ctrl + v),在末尾添加[8]并按shift + enter
J42161217,2015年

每行之间似乎有一个额外的换行符,我是否正确地说这是输出的渲染问题,而不是输出本身的问题?
毛茸茸的

@Shaggy Wolfram云以一种滑稽变形的方式显示所有角色,因此这不是呈现此类任务的最佳方式。没有多余的行,并且在mathematica上一切正常。复制并粘贴您的测试用例进行检查。我做到了,它们看起来相同
J42161217,2015年

1

OK,38个字符

`0:"╔╠╚╦╬╩╗╣╝"{+x+/:3*0,2_x}@&1,|1,-2+

在线尝试。

k似乎不想很好地处理unicode,因此我选择了oK。


1

批处理,126字节

@set s=
@for /l %%i in (4,1,%1)do @call set s=%%s%%Î
@echo É%s:Î=Ë%»
@for /l %%i in (3,1,%1)do @echo Ì%s%¹
@echo È%s:Î=Ê%¼

适用于CP437或CP850。在这些代码页中看起来像这样:

@set s=
@for /l %%i in (4,1,%1)do @call set s=%%s%%╬
@echo ╔%s:╬=╦%╗
@for /l %%i in (3,1,%1)do @echo ╠%s%╣
@echo ╚%s:╬=╩%╝

1

视网膜56 50字节

.+
$*╬╣
^╬╬╬
╠
.?
$_¶
T`╠╬╣`╔╦╗`^.*
T`╠╬╣`╚╩╝`.*¶$

在线尝试!通过建立一个╬s正方形,然后固定边缘(特别是在添加侧面时删除了三个列)来工作。


1

PowerShell,67字节

'╔'+'╦'*($x=$args[0]-3)+'╗';,('╠'+'╬'*$x+'╣')*($x+1);'╚'+'╩'*$x+'╝'

将输入$args[0],减去3,保存到$x,在门的顶部构造中使用以输出适当数量的中间部分。然后,我们输出其中的中间行$x+1。最后,底行与顶行相似。所有这些都保留在管道上,隐式Write-Output函数免费在元素之间插入换行符。

在线尝试!


1

Perl 5、61

60个字符的代码(包括多字节门字符的90个字符)+1个 -p

$_='╔'.'╦'x($n=$_-3)."╗\n";$_.=y/╔╦╗/╠╬╣/r x++$n.y/╔╦╗/╚╩╝/r

在线尝试!



By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.