埋め込みダイヤモンド!


26

いいえ、これではありません。これでもありません。この質問はそれらのようなものではありません

次の出力を印刷または返すための最短のコードを記述します。

   /\      /\      /\
  /  \    /  \    /  \
 / /\ \  / /\ \  / /\ \
/ /  \ \/ /  \ \/ /  \ \
\ \  / /\ \  / /\ \  / /
 \ \/ /  \ \/ /  \ \/ /
  \  / /\ \  / /\ \  /
   \/ /  \ \/ /  \ \/
   /\ \  / /\ \  / /\
  /  \ \/ /  \ \/ /  \
 / /\ \  / /\ \  / /\ \
/ /  \ \/ /  \ \/ /  \ \
\ \  / /\ \  / /\ \  / /
 \ \/ /  \ \/ /  \ \/ /
  \  /    \  /    \  /
   \/      \/      \/
  • 入出力の標準的な方法。
  • 標準の抜け穴が適用されます。
  • 末尾/先頭の空白は、どんな量でも大丈夫です。

3
これではない、それではない、これはどうですか?
マシュー盧

回答:


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↓は、上隅を反映してダイヤモンド全体を作成していましたが、Charcoalのバグにより、カーソルが位置から外れました。幸いなことに、カーソルを動かさない同じ効果を達成する別の方法を発見しました。つまり、内側のダイアモンドを描画するバイトを保存しました。(重複する操作も調べましたが、回転/コピーのアプローチを改善することはできませんでした。)

編集:↖²↗↘⁴‖M¬M¹¦³↘²‖M¬C⁸¦⁰21バイトで仕事をしますが、それは新しい反映行動に依存しているので、これが古いコードで可能だったかどうかはわかりません。


ええ、ごめんなさい、それはバグでした-私はそれを修正し、できるだけ早くプッシュしようとしますが、これはまだめちゃくちゃ短いです:O +1
ASCIIのみ

@ASCIIのみTIOを使用している場合、それはどのように影響しますか?
ニール

それはあなたが何を意味するかだ場合まあ、それはまだキャッシュされていますので、限り、それがキャッシュされているように、それは問題ないはずです
ASCIIのみ

@ASCIIのみ私が知りたいのは、TIOの動作が変更されたときに、更新された(競合しない)リンクを提供できるようにしたいということです。
ニール

ああ、その場合には、それはすでに修正プログラムがあります
ASCIIのみ

7

62 50 48 45 42 40バイト

2バイトを節約してくれた@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ありがとう!実際、これは2バイトを節約します¦。これは、末尾のなしで機能するためです。
Steadybox

記録に関しては、コードが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-芸術で非常に良いです
Esolangingフルーツ

4
44を消しても、まだ44です。
Okx

@Okx改行しないスペースを適用しない限り。
Steadybox


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

ルビー、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の正方形を空白のままにする必要があります。

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

Ungolfedバージョン -説明を支援するために上記を印刷するように変更

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 .
}


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#、382 291バイト

_=>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]?'\\':' '

今ではかなり読みにくいので、基本的な説明:

  • スペースを左上から右下に並べます
  • 基本的には、8文字ごとに繰り返される6本の対角線として描画します。2本の実線と4本の「破線」(2文字、次に2つのスペース...)
  • 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]

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.