ASCII Rubik's Cube

12

3

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!

Stephen

Posted 2017-06-26T12:52:45.003

Reputation: 12 293

Sandbox – Stephen – 2017-06-26T12:52:59.670

3Related. (As well as, more tangentially, a couple of other challenges you can find when searching for "diamond tiling".) – Martin Ender – 2017-06-26T12:56:48.517

710 hours in the Sandbox (especially with only one upvote) is hardly enough. I'd recommend waiting at least 48 hours. – Dada – 2017-06-26T12:56:52.513

@Dada it's KC, KC challenges don't need much time in Sandbox :) – Stephen – 2017-06-26T12:58:11.877

9To 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. – Dada – 2017-06-26T13:20:18.003

@Dada fixed the image, thanks; that image inspired me, so I included it, it's not essential to the challenge. You can say the same for any KC challenge :) – Stephen – 2017-06-26T13:23:35.170

4@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. – LiefdeWen – 2017-06-26T13:32:18.673

Answers

9

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

dzaima

Posted 2017-06-26T12:52:45.003

Reputation: 19 048

11

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!

Neil

Posted 2017-06-26T12:52:45.003

Reputation: 95 035

6

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!

ovs

Posted 2017-06-26T12:52:45.003

Reputation: 21 408

5outgolfed in bubblegum – Uriel – 2017-06-26T14:06:07.263

5

><>, 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.)

Teal pelican

Posted 2017-06-26T12:52:45.003

Reputation: 1 338

5

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!

xnor

Posted 2017-06-26T12:52:45.003

Reputation: 115 687

4

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!

Mr. Xcoder

Posted 2017-06-26T12:52:45.003

Reputation: 39 774

1

Umm.. isn't hard-coding the output shorter? Even with the escaped slashes, it's 112 bytes in Java 8 / C# / JavaScript.

– Kevin Cruijssen – 2017-06-26T13:44:41.897

@KevinCruijssen It actually is >.<... Omg I'm so dumb – Mr. Xcoder – 2017-06-26T13:46:24.200

1Now I have a lot of golfing to do.... – Mr. Xcoder – 2017-06-26T13:50:44.640

96 bytes – HyperNeutrino – 2017-06-26T14:09:58.390

And why do you have the extra newlines? :P – HyperNeutrino – 2017-06-26T14:11:43.313

3You can also use Python 2 to get 93 bytes – HyperNeutrino – 2017-06-26T14:12:19.070

94 bytes if you use r – Post Rock Garf Hunter – 2017-06-26T15:26:44.120

Your "dumb" 139 byte solution doesn't even work. You need to replace abs(i-3) on the 3rd line to (2-i) – sagiksp – 2017-06-26T17:46:20.033

@sagiksp It was a typo. Fixed now. – Mr. Xcoder – 2017-06-26T18:44:04.447

@HyperNeutrino Thanks for the suggestions – Mr. Xcoder – 2017-06-26T18:44:19.283

@WheatWizard I ninja'd you ;) :P – HyperNeutrino – 2017-06-26T19:38:12.997

@HyperNeutrino Looks like by an hour. I thought you were just suggesting changing the language so I didn't click. :) – Post Rock Garf Hunter – 2017-06-26T19:43:47.817

@WheatWizard Ah okay :) But yeah :P – HyperNeutrino – 2017-06-26T19:46:09.463

4

Tail, 99 bytes

#!/bin/tail -n+2
    _ _ _
  /_/_/_/\
 /_/_/_/\/\
/_/_/_/\/\/\
\_\_\_\/\/\/
 \_\_\_\/\/
  \_\_\_\/

user71387

Posted 2017-06-26T12:52:45.003

Reputation:

1Welcome to PPCG! – Stephen – 2017-06-26T15:21:17.430

Or the #!/bin/sed 1d variant – sch – 2017-06-26T16:03:41.623

3

Java 8, 112 bytes

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

Hard-coded output.

Try it here.

Kevin Cruijssen

Posted 2017-06-26T12:52:45.003

Reputation: 67 575

Can I edit the JS and C# hardcoded parts into your answer? – LiefdeWen – 2017-06-26T13:36:34.627

Okay you can save 5 bytes on C# with verbatim literal so o=>@"... and then replace \n with an actual newline. – LiefdeWen – 2017-06-26T13:46:28.600

3

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.

Uriel

Posted 2017-06-26T12:52:45.003

Reputation: 11 708

2

C#, 86 bytes

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

Try it here.

Kevin Cruijssen

Posted 2017-06-26T12:52:45.003

Reputation: 67 575

Challenging. Found a slightly smaller total size (header+footer+code), but exchanges smaller header/footer for slightly larger main than yours: Try it online!

– Mark Rejhon – 2017-06-26T22:39:45.193

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

– Kevin Cruijssen – 2017-06-27T06:50:59.517

2

PHP, 77 bytes

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

Try it online!

Jörg Hülsermann

Posted 2017-06-26T12:52:45.003

Reputation: 13 026

1

Save 4 bytes: Try it online!

– Neil – 2017-06-26T17:00:09.157

1@Neil Thank You and additional 2 Bytes saved – Jörg Hülsermann – 2017-06-26T17:02:59.603

It's always great when you can outperform literal output! – Neil – 2017-06-26T17:04:22.690

2

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.

Neil

Posted 2017-06-26T12:52:45.003

Reputation: 95 035

2

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¦

Emigna

Posted 2017-06-26T12:52:45.003

Reputation: 50 798

ÀÀÀ in that alternate version [O_O"]... – Magic Octopus Urn – 2017-06-27T18:48:43.693

@MagicOctopusUrn: Yeah... I haven't found a shorter way to do or get around it :P – Emigna – 2017-06-27T18:54:44.303

1I concur, I spent a couple minutes trying too; there's no way around it I can see xD. – Magic Octopus Urn – 2017-06-27T18:56:59.283

2

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

vladdobra

Posted 2017-06-26T12:52:45.003

Reputation: 21

I think you can delete some spaces in the CSS around :s and {}s – Stephen – 2017-06-26T20:25:44.303

2

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.

Magic Octopus Urn

Posted 2017-06-26T12:52:45.003

Reputation: 19 422

1

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

_=>`   _ _ _
  /_/_/_/\\
 /_/_/_/\\/\\
/_/_/_/\\/\\/\\
\\_\\_\\_\\/\\/\\/
 \\_\\_\\_\\/\\/
  \\_\\_\\_\\/`

Stephen

Posted 2017-06-26T12:52:45.003

Reputation: 12 293

94 bytes. – Shaggy – 2017-06-26T17:06:27.643

@Shaggy duh, I knew that, even used it recently. Thanks! – Stephen – 2017-06-26T17:11:18.323

193 bytes – Joshua Bell – 2017-06-26T19:30:50.913

@JoshuaBell feel free to post that as your own answer, that's definitely not a golf of mine :) (it's also very ingenius) – Stephen – 2017-06-26T19:32:19.980

1

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

Level River St

Posted 2017-06-26T12:52:45.003

Reputation: 22 049

1

Windows Batch, 122 bytes

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

Pretty self-explantory.

stevefestl

Posted 2017-06-26T12:52:45.003

Reputation: 539

1

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

Teun Pronk

Posted 2017-06-26T12:52:45.003

Reputation: 2 599

1

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.

apricot boy

Posted 2017-06-26T12:52:45.003

Reputation: 281

1

Perl 5, 89 bytes

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

Try it online!

Xcali

Posted 2017-06-26T12:52:45.003

Reputation: 7 671

0

Python 2, 93 bytes

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

Try it online!

totallyhuman

Posted 2017-06-26T12:52:45.003

Reputation: 15 378