14
\$\begingroup\$

Inspired by this and the following chat:

Inspiration

Your task is to output the following:

   _ _ _
  /_/_/_/\
 /_/_/_/\/\
/_/_/_/\/\/\
\_\_\_\/\/\/
 \_\_\_\/\/
  \_\_\_\/

Extra leading or trailing whitespace is allowed, as long as it does not change the appearance of the cube. As usual, returning the above or a list of strings from a function is allowed.

This is , so shortest answer in bytes wins!

\$\endgroup\$
7
  • \$\begingroup\$ Sandbox \$\endgroup\$
    – Stephen
    Jun 26, 2017 at 12:52
  • 3
    \$\begingroup\$ Related. (As well as, more tangentially, a couple of other challenges you can find when searching for "diamond tiling".) \$\endgroup\$ Jun 26, 2017 at 12:56
  • 7
    \$\begingroup\$ 10 hours in the Sandbox (especially with only one upvote) is hardly enough. I'd recommend waiting at least 48 hours. \$\endgroup\$
    – Dada
    Jun 26, 2017 at 12:56
  • 9
    \$\begingroup\$ To explain my downvote: I don't really like the challenge, because the image is taking much of the space, and I feel like you are more trying to show a funny image than to make a good challenge (even more since the pattern isn't the same as the one on the picture) (and I'm quite sure this will attract some upvotes from people that just laughed at the picture). Also, "output this exact string" with a string that looks more or less than this one has been done several times, and I fail to see how your challenge is different enough to be interesting. \$\endgroup\$
    – Dada
    Jun 26, 2017 at 13:20
  • 4
    \$\begingroup\$ @StephenS I gave +1, but I disagree that you can say the same for any KC challenge, when I make a KC challenge I make sure to make the pattern somewhat complex (so charcoal doesn't just auto-win), I make longer patterns so languages that can handle loops better have a chance (Like JS) and I try to use things that some languages might have built in like the alphabet, KC challenges differ a lot, and trying to say they are all the same takes something away from the category. \$\endgroup\$
    – LiefdeWen
    Jun 26, 2017 at 13:32

26 Answers 26

11
\$\begingroup\$

Charcoal, 28 23 bytes

F³⁺⁺×\_³×\/⁻³ι¶ ‖M↑×_ ³

Try it online! Link is to verbose version of code. Not very Charcoal-y I know. I didn't realise that ‖M↓ deliberately moves the cursor so I had originally tried F³«P⁺×/_³×/\⁻³ι↗»‖M↓×_ ³ which didn't work, because I was trying to do it upside-down. If you want something more Charcoal-y then try G↗³←⁶↘³/\¶\/G↖³←⁷↘³_\¶\_↘‖M↑×_ ³ for 32 bytes: Try it online!

\$\endgroup\$
0
9
\$\begingroup\$

SOGL V0.12, 27 bytes

Y=Q∫+ZΔ○H!╝Ηūf⅟Ξ∆׀Æģ≠a⁶‘6«n

Try it Here!

Sadly, the palendromization version qE½Dε▒2β[}█O%q‘6«n╬∑ doesn't really work

\$\endgroup\$
0
6
\$\begingroup\$

Bubblegum, 35 bytes

00000000: 5350 5088 0741 2e05 05fd 7830 8ce1 82b3  SPP..A....x0....
00000010: 806c 0413 c889 8907 4330 8f4b 01c1 036a  .l......C0.K...j
00000020: 8671 00                                  .q.

Try it online!

\$\endgroup\$
1
  • 5
    \$\begingroup\$ outgolfed in bubblegum 😲 \$\endgroup\$
    – Uriel
    Jun 26, 2017 at 14:06
5
\$\begingroup\$

><>, 97 94 93 89 bytes

">knknknk//>k>knknknk/>k>k>knknknkk>k>k>n>n>n>k>k>n>n>n>/k>n>n>n>//n/n/n///"01.
of-

Try it online!

Edit 3: Figured out that you can use the character "" (ascii 25) - Now the process just takes 15 off every stack item and prints. Also removed extra directional instructions and replaced all with 1 move (01.)

\$\endgroup\$
5
\$\begingroup\$

Python 2, 81 bytes

i=7
while i:k=min(i,7-i);i-=1;print' '*(3-k)+'\/___ '[i/3::3]*3+k*'\//\\'[i>2::2]

Try it online!

\$\endgroup\$
4
\$\begingroup\$

Tail, 99 bytes

#!/bin/tail -n+2
    _ _ _
  /_/_/_/\
 /_/_/_/\/\
/_/_/_/\/\/\
\_\_\_\/\/\/
 \_\_\_\/\/
  \_\_\_\/
\$\endgroup\$
2
  • 1
    \$\begingroup\$ Welcome to PPCG! \$\endgroup\$
    – Stephen
    Jun 26, 2017 at 15:21
  • \$\begingroup\$ Or the #!/bin/sed 1d variant \$\endgroup\$
    – sch
    Jun 26, 2017 at 16:03
4
\$\begingroup\$

Python 3, 98 94 bytes

@KevinCruijssen suggested this...

-4 bytes thanks to @HyperNeutrino and @WheatWizard

Output Hardcoding solution:

print(r"""   _ _ _
  /_/_/_/\
 /_/_/_/\/\
/_/_/_/\/\/\
\_\_\_\/\/\/
 \_\_\_\/\/
  \_\_\_\/""")

Try it online!

or, 98 bytes:

print("   _ _ _\n  /_/_/_/\\\n /_/_/_/\/\\\n/_/_/_/\/\/\\\n\_\_\_\/\/\/\n \_\_\_\/\/\n  \_\_\_\/")

Try it online!


Python 3, 139 bytes

Dumb Python 3 Non-Hardcoding sumbmission, sure it can be golfed. Surprisingly, compressing the two fors in just one loop is longer:

p=print;p(' '*3+"_ "*3)
for i in range(3):p(abs(2-i)*' '+'/_'*3+'/'+i*"\/"+'\\')
for i in range(3):p(i*' '+'\\_'*3+'\\'+"/\\"*abs(2-i)+'/')

Try it online!

Python 3, 140 bytes

print(' '*3+"_ "*3,'\n'+'\n'.join(abs(2-i)*' '+'/_'*3+'/'+i*"\/"+'\\'if i<3else (i-3)*' '+'\\_'*3+'\\'+"/\\"*abs(i-5)+'/'for i in range(6)))

Try it online!

\$\endgroup\$
14
3
\$\begingroup\$

Bubblegum, 42 bytes

0000: e0 00 4f 00   22 5d 00 10   68 13 e2 04   15 00 b7 11 │ à.O."]..h.â...·.
0010: 7a 0e c5 f5   30 27 b5 b3   3d 39 8f a6   1f f9 74 52 │ z.Åõ0'µ³=9.¦.ùtR
0020: c5 66 98 bd   bd 0a 9a 8d   44 00                     │ Åf.½½¶..D.
\$\endgroup\$
0
3
\$\begingroup\$

Java 8, 112 bytes

o->"   _ _ _\n  /_/_/_/\\\n /_/_/_/\\/\\\n/_/_/_/\\/\\/\\\n\\_\\_\\_\\/\\/\\/\n \\_\\_\\_\\/\\/\n  \\_\\_\\_\\/"

Hard-coded output.

Try it here.

\$\endgroup\$
2
  • \$\begingroup\$ Can I edit the JS and C# hardcoded parts into your answer? \$\endgroup\$
    – LiefdeWen
    Jun 26, 2017 at 13:36
  • \$\begingroup\$ Okay you can save 5 bytes on C# with verbatim literal so o=>@"... and then replace \n with an actual newline. \$\endgroup\$
    – LiefdeWen
    Jun 26, 2017 at 13:46
3
\$\begingroup\$

Retina, 59 bytes


   _¶  /_/\¶ /_/V\¶/_/VV\¶\_VVV¶ \_VV¶  \_V
._
$&$&$&
V
\/

Try it online! Explanation: The first stage simply creates the following:

   _
  /_/\
 /_/V\
/_/VV\
\_VVV
 \_VV
  \_V

The second stage then expands all the _s by repeating them and the previous character 3 times, while the third stage turns the Vs into \/s.

\$\endgroup\$
3
\$\begingroup\$

PHP, 77 bytes

<?=strtr('   _ _ _
  0\
 01\
011\
2111
 211
  21',["/_/_/_/","\/","\_\_\_"]);

Try it online!

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Save 4 bytes: Try it online! \$\endgroup\$
    – Neil
    Jun 26, 2017 at 17:00
  • 1
    \$\begingroup\$ @Neil Thank You and additional 2 Bytes saved \$\endgroup\$ Jun 26, 2017 at 17:02
  • \$\begingroup\$ It's always great when you can outperform literal output! \$\endgroup\$
    – Neil
    Jun 26, 2017 at 17:04
2
\$\begingroup\$

C#, 86 bytes

o=>@"   _ _ _
  /_/_/_/\
 /_/_/_/\/\
/_/_/_/\/\/\
\_\_\_\/\/\/
 \_\_\_\/\/
  \_\_\_\/"

Try it here.

\$\endgroup\$
2
  • \$\begingroup\$ Challenging. Found a slightly smaller total size (header+footer+code), but exchanges smaller header/footer for slightly larger main than yours: Try it online! \$\endgroup\$ Jun 26, 2017 at 22:39
  • \$\begingroup\$ @MarkRejhon Unfortunately it's the main part that counts with the default program or function. ;) With the added o=>{} it would be 98 bytes in your case. \$\endgroup\$ Jun 27, 2017 at 6:50
2
\$\begingroup\$

05AB1E, 34 31 bytes

„_ 3×Âð'/:3F„/\«∞2ä`RˆD}\)¯R«.c

Try it online!

Explanation

„_ 3×             # push the string "_ _ _ "
     Â            # push a reversed copy
      ð'/:        # replace spaces with slashes
3F                # 3 times do
  „/\«            # append "/\"
      ∞           # mirror
       2ä`        # split into 2 separate parts on stack
         Rˆ       # reverse the second part and push to global list
           D      # duplicate the remaining part
            }     # end loop
\)                # discard the last copy and wrap stack in a string
  ¯R              # push the global list and reverse it
    «             # append to the rest of the list
     .c           # pad lines to equal length

Alternate 31 byte solution

„ _3×3FDð'/:„/\«∞2ä`R.Á})ÀÀÀ.c¦
\$\endgroup\$
3
  • \$\begingroup\$ ÀÀÀ in that alternate version [O_O"]... \$\endgroup\$ Jun 27, 2017 at 18:48
  • \$\begingroup\$ @MagicOctopusUrn: Yeah... I haven't found a shorter way to do or get around it :P \$\endgroup\$
    – Emigna
    Jun 27, 2017 at 18:54
  • 1
    \$\begingroup\$ I concur, I spent a couple minutes trying too; there's no way around it I can see xD. \$\endgroup\$ Jun 27, 2017 at 18:56
2
\$\begingroup\$

CSS, 225 223 bytes

-2 bytes thanks to Stephen S, extra spaces removed

I'm not exactly sure if this counts because CSS isn't really a programming language, but technically CSS can be standalone since the <html> element is autogenerated if there isn't one.

html:after{content:'   _ _ _ \A   /_/_/_/\005c\A  /_/_/_/\005c/\005c \A /_/_/_/\005c/\005c/\005c \A \005c_\005c_\005c_\005c/\005c/\005c/ \A  \005c_\005c_\005c_\005c/\005c\/\A   \005c_\005c_\005c_\005c /';white-space: pre;}

And here's a version with a monospaced font, 247 246 bytes.

-1 byte thanks to Stephen S, extra spaces removed

html:after{font-family:'Courier';content:'   _ _ _ \A   /_/_/_/\005c\A  /_/_/_/\005c/\005c \A /_/_/_/\005c/\005c/\005c \A \005c_\005c_\005c_\005c/\005c/\005c/ \A  \005c_\005c_\005c_\005c/\005c\/\A   \005c_\005c_\005c_\005c /';white-space: pre;}

\$\endgroup\$
1
  • \$\begingroup\$ I think you can delete some spaces in the CSS around :s and {}s \$\endgroup\$
    – Stephen
    Jun 26, 2017 at 20:25
2
\$\begingroup\$

05AB1E, 35 32 31 bytes

"/ _\"•₁7æ¤ÝI}?ÕR&Ü•4вè4ôJ€∞ø¨»

Try it online!

100% different method than Emigna.


Edit: If I start with the pattern already transposed I can cut out 3 bytes.


"/ _\"            # Push ASCII-art characters used.
•₁7æ¤ÝI}?ÕR&Ü•4в  # Push transposed version of base-4 pattern.
è                 # Replace all digits in base-4 number with appropriate symbol.
 4ô               # Split into groups of 4.
   J              # Join together.
    €∞            # Mirror each row (technically column).
      ø           # Transpose back.
       ¨»         # Remove the extra "_ _ _", and print with newlines.
\$\endgroup\$
1
\$\begingroup\$

JavaScript (ES6), 95 bytes

_=>String.raw`   _ _ _
  /_/_/_/\
 /_/_/_/\/\
/_/_/_/\/\/\
\_\_\_\/\/\/
 \_\_\_\/\/
  \_\_\_\/`

JavaScript (ES6), 103 94 bytes

-9 bytes thanks to @Shaggy

_=>`   _ _ _
  ${a=`/_/_/_/\\`}
 ${a}/\\
${a}/\\/\\
${b=`\\_\\_\\_\\/`}\\/\\/
 ${b}\\/
  ${b}`

JavaScript (ES6), 106 bytes

_=>`   _ _ _
  /_/_/_/\\
 /_/_/_/\\/\\
/_/_/_/\\/\\/\\
\\_\\_\\_\\/\\/\\/
 \\_\\_\\_\\/\\/
  \\_\\_\\_\\/`
\$\endgroup\$
4
  • \$\begingroup\$ 94 bytes. \$\endgroup\$
    – Shaggy
    Jun 26, 2017 at 17:06
  • \$\begingroup\$ @Shaggy duh, I knew that, even used it recently. Thanks! \$\endgroup\$
    – Stephen
    Jun 26, 2017 at 17:11
  • 1
    \$\begingroup\$ 93 bytes \$\endgroup\$ Jun 26, 2017 at 19:30
  • \$\begingroup\$ @JoshuaBell feel free to post that as your own answer, that's definitely not a golf of mine :) (it's also very ingenius) \$\endgroup\$
    – Stephen
    Jun 26, 2017 at 19:32
1
\$\begingroup\$

Ruby, 72 70 bytes

7.times{|i|puts' '*(j=i^i/4+3)+'_ \_/_'[-i/3*2,2]*3+'/\/'[i/4,2]*j^=3}

Latest edit: avoid double \ by enclosing strings in '' instead of "".

Ungolfed (note in Ruby negative string indexes wrap around. -1 is the last character.)

7.times{|i|                       #7 lines.
  puts" "*(j=i^i/4+3)+            #Print j= 3,2,1,0, 0,1,2 spaces.
      "_ \\_/_"[-i/3*2,2]*3+      #Print 3 repeats of 2 characters from the string, index 0,-2,-2,-2,-4,-4,-4.
      "/\\/"[i/4,2]*j^=3          #Print 2 characters from the string, /\ or \/, repeated 3^j times.
}
\$\endgroup\$
1
\$\begingroup\$

Windows Batch, 122 bytes

@echo    _ _ _
@echo   /_/_/_/\
@echo  /_/_/_/\/\
@echo /_/_/_/\/\/\
@echo \_\_\_\/\/\/
@echo  \_\_\_\/\/
@echo   \_\_\_\/

Pretty self-explantory.

\$\endgroup\$
1
\$\begingroup\$

Brainf*ck 387 bytes

Not even sure if this is still a thing but I was bored and did it for sh*ts and giggles :)

++++++++[->++++>++++>++++>++++<<<<]+++++[->>+++>+++>+++<<<<]<+++[->+++++<]>[->>>+++>+++<<<<]>>>>+++<<<...<+++[->.>>>.<<<<]<<++++++++++>+++++++++++++.<.>>>..>.<<+++[->>>>.<<.<<]>>>.<<<<.<.>>>.>.<<+++[->>>>.<<.<<]>>>.<.>.<<<<.<.>>>>.<<+++[->>>>.<<.<<]>>>.<.>.<.>.<<<<.<.>>>>>.<<<+++[->>>>.<.<<<]>>.>.<.>.<.<<<.<.>>>.>>.<<<+++[->>>>.<.<<<]>>.>.<.<<<.<.>>>..>>.<<<+++[->>>>.<.<<<]>>.<<<.<.>>

Edit: TIL: I am 54.28% more effective than some generator I found online ^.^

Edit2: Try it online Make sure Wrap is on for Memory overflow behaviour in the options

\$\endgroup\$
1
\$\begingroup\$

COBOL, 238 bytes

Compiled with open-cobol. Note that the indentation is a single tab, not spaces, even if this website formats it that way.

    IDENTIFICATION DIVISION.
    PROGRAM-ID. a.
    PROCEDURE DIVISION.
    DISPLAY "   _ _ _".
    DISPLAY "  /_/_/_/\".
    DISPLAY " /_/_/_/\/\".
    DISPLAY "/_/_/_/\/\/\".
    DISPLAY "\_\_\_\/\/\/".
    DISPLAY " \_\_\_\/\/".
    DISPLAY "  \_\_\_\/".
    STOP RUN.
\$\endgroup\$
1
\$\begingroup\$

Perl 5, 89 bytes

say"   _ _ _";$r[7-$_]=($r[$_]=$"x(3-$_).'/_'x3 .'/\\'x$_.$/)=~y|/\\|\\/|r for 1..3;say@r

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Deadfish~, 687 bytes

{iii}iiccc{iiiiii}iiic{dddddd}dddc{iiiiii}iiic{dddddd}dddc{iiiiii}iiic{{d}ii}dddddc{ii}iicc{i}iiiiic{iiiii}ddc{ddddd}iic{iiiii}ddc{ddddd}iic{iiiii}ddc{ddddd}iic{iiii}iiiiic{{d}ii}ddc{ii}iic{i}iiiiic{iiiii}ddc{ddddd}iic{iiiii}ddc{ddddd}iic{iiiii}ddc{ddddd}iic{iiii}iiiiic{dddd}dddddc{iiii}iiiiic{{d}ii}ddc{iiii}dddc{iiiii}ddc{ddddd}iic{iiiii}ddc{ddddd}iic{iiiii}ddc{ddddd}iic{iiii}iiiiic{dddd}dddddc{iiii}iiiiic{dddd}dddddc{iiii}iiiiic{{d}ii}ddc{{i}dd}iiciiicdddciiicdddciiicdddc{dddd}dddddc{iiii}iiiiic{dddd}dddddc{iiii}iiiiic{dddd}dddddc{dddd}iiic{ii}iic{iiiiii}ciiicdddciiicdddciiicdddc{dddd}dddddc{iiii}iiiiic{dddd}dddddc{dddd}iiic{ii}iicc{iiiiii}ciiicdddciiicdddciiicdddc{dddd}dddddc

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Self-modifying Brainfuck, 86 bytes

Replace the ␀ with an actual null byte (0x00).

<[.<]␀/\_\_\_\  
/\/\_\_\_\ 
/\/\/\_\_\_\
\/\/\/_/_/_/
\/\/_/_/_/ 
\/_/_/_/  
_ _ _   

Try it online!

Explanation

Another literal output answer.

<[.<]             - Print the source code in reverse until a NULL byte is found.
     ␀            - Null, replace with 0x00. Ends program.
      <the rest>  - The cube in reverse.
\$\endgroup\$
1
\$\begingroup\$

Vyxal j, 33 32 bytes

-1 bytes thanks to Aaron Miller

»\!¡øoΠ¥⅛831‟½ø↲p∇±₀WṀ»‛_ k/+τ7/

Explanation

»\!¡øoΠ¥⅛831‟½ø↲p∇±₀WṀ»             - Push a base-4 number containing the cube
                       ‛_ k/+τ      - Change to custom base, replacing the numbers 
                                      with the symbols.
                              7/    - Divide into seven lines.
<j flag>                            - Join by newlines
<implicit output>                   - Print it!

Try it Online!

\$\endgroup\$
1
1
\$\begingroup\$

Zsh, 86 bytes

Port of the PHP solution. Try it online!

sed 's|0|/_/_/_/|;s|1|\\/|g;s|2|\\_\\_\\_|'<<<'   _ _ _
  0\
 01\
011\
2111
 211
  21'

But the naïve approach only costs 1 extra, for 87 bytes ...

 <<<'    _ _ _
  /_/_/_/\
 /_/_/_/\/\
/_/_/_/\/\/\
\_\_\_\/\/\/
 \_\_\_\/\/
  \_\_\_\/'
\$\endgroup\$
1
  • \$\begingroup\$ tried flipping the \ to / to build the bottom half, but it ended up over 100 bytes.. \$\endgroup\$
    – roblogic
    Oct 15, 2021 at 4:59
0
\$\begingroup\$

Python 2, 93 bytes

print r"""   _ _ _
  /_/_/_/\
 /_/_/_/\/\
/_/_/_/\/\/\
\_\_\_\/\/\/
 \_\_\_\/\/
  \_\_\_\/"""

Try it online!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.