嵌入式钻石!


26

不,不是这个。而不是这个无论是。这个问题不像那些

编写最短的代码以打印/返回以下输出:

   /\      /\      /\
  /  \    /  \    /  \
 / /\ \  / /\ \  / /\ \
/ /  \ \/ /  \ \/ /  \ \
\ \  / /\ \  / /\ \  / /
 \ \/ /  \ \/ /  \ \/ /
  \  / /\ \  / /\ \  /
   \/ /  \ \/ /  \ \/
   /\ \  / /\ \  / /\
  /  \ \/ /  \ \/ /  \
 / /\ \  / /\ \  / /\ \
/ /  \ \/ /  \ \/ /  \ \
\ \  / /\ \  / /\ \  / /
 \ \/ /  \ \/ /  \ \/ /
  \  /    \  /    \  /
   \/      \/      \/
  • 输入/输出的标准方法。
  • 有标准漏洞。
  • 无论如何,尾随/前导空格都是可以的。

3
不是这个,不是那个,呢?
马修·罗

Answers:


14

木炭28 24 23字节

↗²↖↙⁴⟲P²⁴⁶↘↙↙²⟲P²⁴⁶C⁸¦⁰

在线尝试!说明:

↗²↖↙⁴   Draw the top left 4x4 corner
         /
        //
⟲P²⁴⁶   Rotate it three times to complete a diamond
         /\
        //\\
        \\//
         \/
↘↙↙²    Draw the top left line of the inner diamond
         /\
        //\\
        \\//
         \//
⟲P²⁴⁶   Rotate three times to complete five diamonds
C⁸¦⁰    Copy everything 8 characters to the right to complete eight diamonds

编辑:我以前的答案用来‖M‖M↓通过反射顶角来创建整个菱形,但是由于木炭中的错误,这使光标偏离了位置。幸运的是,我发现了另一种实现相同效果的方法,该方法不会移动光标,这意味着我节省了一个绘制内部菱形的字节。(我也研究了重叠的操作,但是无法对旋转/复制方法进行改进。)

编辑:↖²↗↘⁴‖M¬M¹¦³↘²‖M¬C⁸¦⁰以21字节为单位进行工作,但是这依赖于新的反映行为,因此我不知道这对于旧代码是否可行。


是的,很抱歉,这是一个错误-我已修复它,并将尝试尽快推送,但这仍然很短:O +1
仅ASCII格式,

仅@ASCII如果我一直在使用TIO,那对我有什么影响?
尼尔

好吧,它仍然处于缓存状态,因此只要您缓存了它,就可以了,那就没问题了
ASCII码,仅ASCII

仅@ASCII我想知道的是,当TIO的行为发生变化时,我希望能够提供一个更新的(尽管是非竞争性的)链接。
尼尔

哦,在那种情况下,它已经有了修补程序
仅ASCII码

7

木炭62 50 48 45 42 40字节

感谢@Okx节省了两个字节!

↙²→↘²↙↖⁴→↗⁴‖MF²C⁸¦⁰M⁸↓→↗²↓↘²M⁴→↑↗²↓↘²‖M↓

在线尝试!

说明:

↙²→↘²          // Draw the left half of the inner part of the first diamond.
↖⁴→↗⁴          // Draw the left half of the outer part.
‖M             // Mirror the half of the diamond to create the first full diamond.
F²C⁸¦⁰         // Copy the picture eight characters to the left twice.
               // The first copy gives us two diamonds, and the second copy of the
               // two diamonds overlaps so that the result is three diamonds.
M⁸↓→↗²↓↘²     // Move down to draw the upper inner half of the first middle diamond.
M⁴→↑↗²↓↘²     // Move right to do the same for the second middle diamond.
‖M↓           // Mirror the whole thing vertically.

1
您可以替换C⁸¦⁰C⁸¦⁰使用F²C⁸¦⁰¦,以节省一个字节。
Okx

@Okx谢谢!实际上,这节省了两个字节,因为它无需尾随即可工作¦
Steadybox '17

记录下来,一些更新似乎已破坏了这一点,因为该代码在TIO上不再正常工作。答案仍然有效,因为在发布此答案时,它可以与TIO使用的版本一起使用。
Steadybox

6

05AB1E45 44 43字节

码:

…/ \©•—‹íćCé']d₂2ó@¯çX‘¯¨•3вè8äJvy®‡«}»Â»

解释前:

•—‹íćCé'\]d₂2ó@¯çX‘¯¨•3в部分只是以下数组的压缩版本:

[1, 1, 1, 0, 2, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 2, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 2, 1, 2, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 2, 1, 2, 0, 1, 0, 1, 2, 1, 2, 1, 1, 0, 1, 0, 2, 1, 2, 1, 1, 2, 1, 2, 0, 1, 0, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 0, 1, 0, 2, 1, 2, 1, 1, 1, 1, 2, 0, 1, 0, 1, 1, 2, 1, 2]

我们将其索引到字符串中…/ \。此地图0 -> /1 -> space2 -> \。之后,我们使用以下程序处理此字符串:

8äJvy®‡«}»Â»

8ä               # Split the array into 8 pieces
  J              # Join each sub-array in the array
   vy     }      # For each string in the array
     Â           #   Bifurcate (duplicate and reverse)
      ®          #   Push the string "/ \" (which was copied using ©)
       Â         #   Bifurcate to get "\ /"
        ‡        #   Transliterate / -> \ and \ -> /
         «       #   Append to the original string
           »     # Join the entire stack on newlines
            Â    # Bifurcate
             »   # Join the stack by newlines

使用05AB1E编码。在线尝试!


05AB1E非常擅长ASCII艺术,似乎...
硕果累累

4
划掉四十四仍然是四十四。
Okx

@Okx除非您应用不间断空格
Steadybox '17

5

PHP,126字节

<?=gzinflate(base64_decode("vY7BCQAwCAP/mSIbuJD7z1GJLbbiuz5yKCeEpDk1RUSQWm8iMiRnIyw178Qgi5hs3ceHOA86snN7ON2b/687X+7umuIC"));

在线尝试!

PHP,149字节

$s=strtr("000
111
222
333
444
555
  \ 22 /  
   \\33/   ",["   /\   ","  /  \  "," / /\ \ ","/ /  \ \\","\ \  / /"," \ \/ / "]);echo"$s
".strrev($s);

在线尝试!


3

JavaScript,232字节

_=>(a=`3868683
2/274/274/272
1/18172/18172/18171
/1/27191/27191/2717
7172/18172/18172/1/
17191/27191/27191/1
272/18172/18172/2
391/27191/27193`.replace(/\d/g,n=>n>6?['\\','/\\','\\/'][n-7]:' 
'.repeat(n)))+`
`+[...a].reverse().join``

在线尝试!

const f = _=>(a=`3868683
2/274/274/272
1/18172/18172/18171
/1/27191/27191/2717
7172/18172/18172/1/
17191/27191/27191/1
272/18172/18172/2
391/27191/27193`.replace(/\d/g,n=>n>6?['\\','/\\','\\/'][n-7]:' '.repeat(n)))+`
`+[...a].reverse().join``

console.log(`
${f()}
`)


我下面有一个126字节的解决方案。:)
史蒂夫·贝内特

3

Ruby,99 97个字节

400.times{|i|print (23<x=i%25)?$/:" /  \\   "[(x^y=i/25)&4^x+y&1^(x-2&4&y-2>y/6%2*x/2%11*4?2:0)]}

说明

每个4x4正方形仅包含和/\。我们绘制这些图以给出整体菱形图案。为避免边界出现局部图案,某些2x2正方形必须留空,如下所示。

.. /\ .... /\ .... /\ ..
../  \..../  \..../  \..
 / /\ \  / /\ \  / /\ \
/ /  \ \/ /  \ \/ /  \ \
\ \  / /\ \  / /\ \  / /
 \ \/ /  \ \/ /  \ \/ /
..\  / /\ \  / /\ \  /..
.. \/ /  \ \/ /  \ \/ ..
.. /\ \  / /\ \  / /\ ..
../  \ \/ /  \ \/ /  \..
 / /\ \  / /\ \  / /\ \
/ /  \ \/ /  \ \/ /  \ \
\ \  / /\ \  / /\ \  / /
 \ \/ /  \ \/ /  \ \/ /
..\  /....\  /....\  /..
.. \/ .... \/ .... \/ ..

非高尔夫版本 -修改以打印上述内容以帮助解释

400.times{|i|print (23<x=i%25)?$/:     #Calculate x. If last column, print a newline else
  " /..\\ .."[(x^y=i/25)&4^x+y&1^      #If (x^y)&4==4, use x+y&1 to select between space and /. If (x^y)&4==0 select between \ and space.
  (x-2&4&y-2>y/6%2*x/2%11*4?2:0)]      #If x-2&4&y-2==4, and we are on the 2 character wide border (y/6%2*x/2%11==0), XOR with 2 to print .
}

2

Pyth- 106 98 96 92字节

V16V24J%t+NH8K%+_2-NH8=Y&&&>H1>N1<N14<H22p?|q2J&&Y!%J4?<1%H4J!J\/?|q2K&&Y!%K4?<1%H4!KK\\d)pb

试试吧


1

C#,608字节

void q(){Action<string>a=Console.Write;Func<int,int,string>b=(c,d)=>new string(' ',c)+(d<1?"/\\":d<2?"/  \\":d<3?"/ /\\ \\":d<4?"/ /  \\ \\":d<5?"\\ \\  / /":d<6?"\\ \\/ /":d<7?"\\  /":"\\/");Action e=()=>a(b(0,4)+b(0,4)+b(0,4)+"\n"+b(1,5)+b(2,5)+b(2,5)+"\n");Action f=()=>a(b(1,2)+b(2,2)+b(2,2)+"\n");Action g=()=>a(b(0,3)+b(0,3)+b(0,3)+"\n");a(b(3,0)+b(6,0)+b(6,0)+"\n"+b(2,1)+b(4,1)+b(4,1)+"\n");f();g();e();a("  \\  / /\\ \\  / /\\ \\  /\n"+"   \\/ /  \\ \\/ /  \\ \\/\n"+"   /\\ \\  / /\\ \\  / /\\\n"+"  /  \\ \\/ /  \\ \\/ /  \\\n");f();g();e();a(b(2,6)+b(4,6)+b(4,6)+"\n"+b(3,7)+b(6,7)+b(6,7)+"\n");}

并不是说我想再做一次,但看起来您失踪了using System;。我也很确定您可以打更多的高尔夫球,但是我并没有花费太多时间来确保自己100%的确定。
TheLethalCoder

它比输出长,所以只会System.Console.WriteLine(@"...");比我的答案好200个字节。
LiefdeWen

1

C#,382291字节

_=>string.Format(@"{5}{5}{5}
{2}{2}{2}
{0}{0}{0}
{1}{1}{1}
\ \ {0}{0} / /
 \ \{1}{1}/ /
  \ {0}{0} /
   \{1}{1}/
   /\ \ {0} / /\
  /  \ \{1}/ /  \
 {0}{0}{0}
{1}{1}{1}
\ \ {0}{0} / /
 \ \{1}{1}/ /
{4}{4}{4}
{3}{3}{3}",@" / /\ \ ",@"/ /  \ \",@"  /  \  ",@"   \/   ",@"  \  /  ",@"   /\   ");

1

Javascript 126个字节

for(c=r=a='';r<16;c++>22&&(r++,c=0,a+=`
`))C=c%22>1&&r%14>1,q=[1,,C&&r&2,,,,C&&~r&2,,1],a+=q[c+5+r&7]?'/':q[r-c+20&7]?'\\':' '

由于现在已经很难理解了,因此有一个基本的解释:

  • 我们从左上方到右下方平铺空间
  • 我们将其绘制为基本上每6个对角线每8个字符重复一次:2条实线和4条“虚线”(两个字符,然后两个空格...)
  • C=...东西是限制一个边框内的一些线绘制
  • 为了节省大量字符,我们故意添加数字以使上下两行的表达式极为相似
  • 然后,将表达式本身放入一个稀疏数组中[1,,C&&...],我们将查找该数组。如果有真实价值,我们会画出适当的字符。

--

for(c=r=a='';r<16;c++>22&&(r++,c=0,a+=`
`))                 // basic grid tiling
C=c%22>1&&r%14>1,   // are we not near the edges
q=[1,               // a solid line that always draws
,                   // a line that never draws
C&&r&2,             // a line that draws if not near the edge, and if on the correct "dash" (r&2)
,,,
C&&~r&2,            // if not near the edge, and on the opposite "dash" (~r&2)
,1                  // the opposite diagonal line that always draws
],
a+=q[c+5+r&7]?'/' // compute which upward line we're on, check whether to draw it
:q[r-c+20&7]?'\\' // do the same for the downward line
:' '                // otherwise draw a space

也许这种解释没有帮助。:)

在线尝试:https//codepen.io/stevebennett/pen/WjgMpY

希望我得到正确的输出:

   /\      /\      /\   
  /  \    /  \    /  \  
 / /\ \  / /\ \  / /\ \ 
/ /  \ \/ /  \ \/ /  \ \
\ \  / /\ \  / /\ \  / /
 \ \/ /  \ \/ /  \ \/ / 
  \  / /\ \  / /\ \  /  
   \/ /  \ \/ /  \ \/   
   /\ \  / /\ \  / /\   
  /  \ \/ /  \ \/ /  \  
 / /\ \  / /\ \  / /\ \ 
/ /  \ \/ /  \ \/ /  \ \
\ \  / /\ \  / /\ \  / /
 \ \/ /  \ \/ /  \ \/ / 
  \  /    \  /    \  /  
   \/      \/      \/   

历史

130

for(c=r=a='';r<16;c++>22&&(r++,c=0,a+=`
`))C=c%22>1&&r%14>1,q=[1,,C&&r&2,,,,C&&~r&2,,1],a+=q[(c+5+r)%8]?'/':q[(r-c+20)%8]?'\\':' '

133

for(c=r=a='';r<16;c++>22&&(r++,c=0,a+=`
`))C=c%22>1,q=[1,,C&&r&2&&r<14,,,,C&&~r&2&&r>1,,1],a+=q[(c+5+r)%8]?'/':q[(r-c+20)%8]?'\\':' '

137

for(c=r=a='';r<16;c++==23&&(r++,c=0,a+=`
`))C=c<22&&c>1,q=[1,,C&&r&2&&r<14,,,,C&&~r&2&&r>1,,1],a+=q[(c+5+r)%8]?'/':q[(r-c+20)%8]?'\\':' '

155

for(c=r=a='';r<16;c++==23&&(r++,c=0,a+=`
`))Z=(C=c<22&&c>1)&&~r&2&&r>1,Y=C&&r&2&&r<14,B=(c-r+12)%8,A=(c+5+r)%8,q=[1,,Y,,,,Z,,1],a+=q[A]?'/':q[8-B]?'\\':' '

历史记录:172

for(c=r=a='';r<16;c++==23&&(r++,c=0,a+='\n'))a+=(Z=(C=c<22&&c>1)&&~r&2&&r>3,Y=C&&r&2&&r<12,B=(c-r+16)%8,A=(c+r)%8,A==3||A==5&&Y||A==1&&Z?'/':B==4||B==2&&Y||B==6&&Z?'\\':' ')

1

画布,18 字节

4/2/33╋╬2/77╋╬:91╋

在这里尝试!

说明:

4/           push a diagonal of length 4
  2/         push a diagonal of length 2
    33╋      insert that at [3;3] in the 1st diagonal
                    /
                   / 
                  / /
                 / / 
╬            quad-palindromize with 0 overlap
 2/77╋       insert a 2-long diagonal in the bottom-right corner
                    /\   
                   /  \  
                  / /\ \ 
                 / /  \ \
                 \ \  / /
                  \ \/ / 
                   \  / /
                    \/ / 
      ╬      quad-palindromize with 0 overlap, creating most of the output
                    /\      /\   
                   /  \    /  \  
                  / /\ \  / /\ \ 
                 / /  \ \/ /  \ \
                 \ \  / /\ \  / /
                  \ \/ /  \ \/ / 
                   \  / /\ \  /  
                    \/ /  \ \/   
                    /\ \  / /\   
                   /  \ \/ /  \  
                  / /\ \  / /\ \ 
                 / /  \ \/ /  \ \
                 \ \  / /\ \  / /
                  \ \/ /  \ \/ / 
                   \  /    \  /  
                    \/      \/   
       :91╋  overlap self on [9;1]

0

视网膜,214字节


F/\E/\E/\¶B/B\BB/B\FAD D¶F\/ C C¶FD D /\¶BC CAF\B/BB\B/¶F\/E\/E\/
F
B 
E
BBB
D
/\ \B/
C
/B\ \/
B
  
A
 /  \¶ / /\ \  / /\ \  / /\ \¶/ /  \ \/ /  \ \/ /  \ \¶\ \  / /\ \  / /\ \  / /¶ \ \/ /  \ \/ /  \ \/ /¶  \  / 

在线尝试!

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.