11
\$\begingroup\$

Introduction

Alphabet challenges are in our DNA, so let's show it.

Challenge

Print the following the text exactly:

AaBbCc        cCbBaA
BbCcDd        dDcCbB
EeFfGg        gGfFeE
HhIiJj        jJiIhH
KkLlMm        mMlLkK
NnOoPp        pPoOnN
QqRrSs        sSrRqQ
TtUuVv        vVuUtT
   WwXx      xXwW
       Yy  yY
         ZZ
         zz
         ZZ
       Yy  yY
   WwXx      xXwW
TtUuVv        vVuUtT
QqRrSs        sSrRqQ
NnOoPp        pPoOnN
KkLlMm        mMlLkK
HhIiJj        jJiIhH
EeFfGg        gGfFeE
BbCcDd        dDcCbB
AaBbCc        cCbBaA

Rules

  • You must match the case of each letter
  • Trailing and/or leading newlines and/or spaces are allowed

Winning

Shortest code in bytes wins.

\$\endgroup\$
  • 14
    \$\begingroup\$ It doesn't make much sense that the first two lines both contain B and C when all other lines (bar the mid section) have unique letters. \$\endgroup\$ – Fatalize Aug 23 '16 at 14:38
  • 1
    \$\begingroup\$ @Fatalize That's to make the challenge slightly more interesting \$\endgroup\$ – Beta Decay Aug 23 '16 at 15:44
  • 5
    \$\begingroup\$ I would personally argue it does the opposite \$\endgroup\$ – Fatalize Aug 23 '16 at 17:26
  • 2
    \$\begingroup\$ I believe there's a mistake in the 9th line. Should be "WwXx xXwW", not "WwXx xXWw", shouldn't it? \$\endgroup\$ – GOTO 0 Aug 23 '16 at 18:58
  • 2
    \$\begingroup\$ @BetaDecay Fatalize is right, that makes the challenge more boring. \$\endgroup\$ – moonheart08 Mar 7 at 15:56

15 Answers 15

18
\$\begingroup\$

Vim (no external tools), 106 bytes

Newlines for clarity:

:h<_↵↵↵YZZPllabc♥
:s/./\u&&/g↵
qa6li↵♥q7@a3i ♥fY
i↵    →→↵  →↵→ð♥
ʌHA ♥9l
qbmaʌ99jY$P`ah@bq@b
y11G:g//m0↵P

Here is Return, is Right, is Escape, ʌ is CTRL-V, and ð is Delete.

golf animation

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

Python 2, 230 bytes

s='';m=['AaBbCc','BbCcDd','EeFfGg','HhIiJj','KkLlMm','NnOoPp','QqRrSs','TtUuVv','   WwXx',' '*7+'Yy',' '*9+'Z'];
p=lambda l:l.ljust(10)+l[::-1].rjust(10)+'\n';
for l in m:s+=p(l);
s+=' '*9+'zz\n';
for l in m[::-1]:s+=p(l)
print s
\$\endgroup\$
  • 1
    \$\begingroup\$ 1) Remove semicolon from second, third and fourth lines 2) Remove the newline at the end of the first line 3) Enjoy your answer being shorter than daHugLenny's 4) Since nobody said it yet, welcome to PPCG! \$\endgroup\$ – Erik the Outgolfer Sep 4 '16 at 21:30
3
\$\begingroup\$

PowerShell v2+, 175 169 163 154 bytes

($x=(-join(65..67+66..86|%{$_;32+$_}|%{[char]$_})-split'(.{6})'-ne'')+'   WwXx'+'       Yy'+(' '*9+'Z')|% *ht 10|%{$_+-join$_[9..0]})
' '*9+'zz'
$x[10..0]

Try it online!

Abuses the fact that default Write-Output at the end of execution inserts a newline between elements.

The first line constructs the branches. We loop over two ranges corresponding to the ASCII values for the capital letters, each iteration output a char array of that letter and that letter +32 (which is the lowercase ASCII point). That's -joined together into one long string, then -split on every six elements (encapsulated in parens so they're preserved), followed by a -ne'' to pull out the empty elements as a result of the split, thus forming an array of strings.

These strings in an array get array-concatenation to add on the WwXx, Yy, and Z elements, then a PadRight 10 to make them all the appropriate width. At this point we have an array of strings like the following (one element per line).

AaBbCc    
BbCcDd    
EeFfGg    
HhIiJj    
KkLlMm    
NnOoPp    
QqRrSs    
TtUuVv    
   WwXx   
       Yy 
         Z

That whole array is piped to another loop to construct the mirrored strings with -join and array-reversing [9..0].

AaBbCc        cCbBaA
BbCcDd        dDcCbB
EeFfGg        gGfFeE
HhIiJj        jJiIhH
KkLlMm        mMlLkK
NnOoPp        pPoOnN
QqRrSs        sSrRqQ
TtUuVv        vVuUtT
   WwXx      xXwW   
       Yy  yY       
         ZZ         

We save the resulting strings into $x and enclose in parens to also place a copy on the pipeline.

The next line places the zz string on the pipeline, then the $x array in reverse order. All of those are left on the pipeline and output is implicit.

PS C:\Tools\Scripts\golfing> .\alphabet-chromosome.ps1
AaBbCc        cCbBaA
BbCcDd        dDcCbB
EeFfGg        gGfFeE
HhIiJj        jJiIhH
KkLlMm        mMlLkK
NnOoPp        pPoOnN
QqRrSs        sSrRqQ
TtUuVv        vVuUtT
   WwXx      xXwW   
       Yy  yY       
         ZZ
         zz
         ZZ
       Yy  yY       
   WwXx      xXwW   
TtUuVv        vVuUtT
QqRrSs        sSrRqQ
NnOoPp        pPoOnN
KkLlMm        mMlLkK
HhIiJj        jJiIhH
EeFfGg        gGfFeE
BbCcDd        dDcCbB
AaBbCc        cCbBaA

-9 bytes thanks to mazzy.

\$\endgroup\$
  • \$\begingroup\$ 154 bytes - '(.{6})' instead (......) and RightPad instead tail spaces. \$\endgroup\$ – mazzy Mar 7 at 4:22
3
\$\begingroup\$

Python 2, 156 bytes

r=('AaBbCc.BbCcDd.EeFfGg.HhIiJj.KkLlMm.NnOoPp.QqRrSs.TtUuVv.   WwXx.%8cy.%10c.%10c'%(89,90,'z')).split('.')
for k in r+r[-2::-1]:s='%-10s'%k;print s+s[::-1]

Try it online!

Maybe the formula 512/(i**4+47)-1 is of interest to future golfers: it maps the integers around 0 to $$\cdots,-1,-1,0,3,7,9,\fbox{9},9,7,3,0,-1,-1,\cdots$$

which encodes how many spaces to prepend to each line ((-1)*' ' being equal to 0*' ').

\$\endgroup\$
2
\$\begingroup\$

Python 2, 331 241 229 bytes

Will golf it more later.

l=("AaBbCc|BbCcDd|EeFfGg|HhIiJj|KkLlMm|NnOoPp|QqRrSs|TtUuVv|   WwXx|%sYy"%(" "*7)).split("|");n=0;v=1;p='for i in([8]*8+[6,2])[::v]:print l[n]+" "*i+l[n][::-1];n+=v';exec p;v=-1;n=9;print"{0}ZZ\n{0}zz\n{0}ZZ".format(" "*9);exec p
\$\endgroup\$
2
\$\begingroup\$

Lua, 212 Bytes

s=([[         Z
       Yy 
   WwXx   
TtUuVv_QqRrSs_NnOoPp_KkLlMm_HhIiJj_EeFfGg_BbCcDd_AaBbCc    ]]):gsub("_","    \n")S="         zz"for z in s:gmatch"[%w ]+"do k=z..z:reverse()S=k..'\n'..S..'\n'..k end print(S)

Simple enough, based off of TimmyD's answer, kind of. Builds the top left arm using a really poorly compressed chunk, then does both mirrors at once around a 'zz', and prints.

Try it on Repl.It

\$\endgroup\$
2
\$\begingroup\$

05AB1E, 48 46 40 38 36 bytes

Ž3ô8.DƵJ6XD)bTj»0ð:1žRAu¦«Dl.ιS.;º.∊

-2 bytes (and the opportunity for 10 more with this alternative approach) thanks to @MagicOctopusUrn.

Try it online.

Explanation:

Ž3ô            # Push compressed integer 1008
   8.D         # Duplicate it 8 times
      ƵJ       # Push compressed integer 120
        6      # Push 6
         XD    # Push 1 twice
           )   # Wrap all into a list
b              # Convert each to binary
 Tj            # Add leading spaces to each binary-string to make them size 10  
   »           # Then join all strings by newlines
0ð:            # Replace all 0s with spaces
 žR            # Push the string "ABC"
   Au¦«        # Merge the uppercased alphabet minus the first "A" with it
       Dl      # Create a lowercase copy
         .ι    # Intersect the uppercase and lowercase strings: "AaBbCcBb..."
           S   # Convert it to a list of characters
1           .; # Replace every 1 with each of these characters in the same order
º              # Then mirror everything vertically without overlap,
 .∊            # and horizontally with the last line overlapping
               # (and output the result implicitly)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why Ž3ô is 1008 and ƵJ is 120.

\$\endgroup\$
  • 1
    \$\begingroup\$ -2 bytes using a mask approach: •3ô•8.D120 6 1D)bí.Bí»…abcA¦«Dus.ιv1y.;}0ð:º.∊ \$\endgroup\$ – Magic Octopus Urn Apr 9 at 16:11
  • 1
    \$\begingroup\$ @MagicOctopusUrn Ah nice, and with some compression and the builtin "abc" it can be golfed by 6 more: •3ô• can be Ž3ô; 120 6 1D can be ƵJ6XD; …abcA¦«Dus.ι can be žRAu¦«Dl.ι. :) \$\endgroup\$ – Kevin Cruijssen Apr 9 at 16:48
  • 1
    \$\begingroup\$ @MagicOctopusUrn Oh, and 2 more by changing í.Bí to Tj (only works in the new version, but not sure if its a bug or intentional). So implicitly you enabled a 10-bytes save in total with your alternative approach. :D \$\endgroup\$ – Kevin Cruijssen Apr 9 at 17:03
  • 1
    \$\begingroup\$ You gotta find one more to win ;). \$\endgroup\$ – Magic Octopus Urn Apr 9 at 17:09
  • 1
    \$\begingroup\$ @MagicOctopusUrn Fine, 2 more removed. ;p And žRAu¦«Dl.ιS could alternatively be A¬žR:uSDl.ι, but unfortunately that won't save bytes. And 0м.B instead of 0ð: is a byte more instead of less.. Kinda hoped the mirrors might implicitly box by adding trailing spaces so the .B wouldn't be necessary, but maybe it's better they don't for other challenges I guess. \$\endgroup\$ – Kevin Cruijssen Apr 9 at 17:29
2
\$\begingroup\$

Stax, 42 41 38 35 bytes

înáöêòé{V║»╧å╓ä¥ì√‼╦▓°nlΓΣ▌ê9t☻*$╢√

Run and debug it

Update: There was a bug in the 41 byte solution. (yes, even though it has no input) While fixing it, I found 3 more bytes to shave.

Update again: There's competition afoot, so I removed 3 more contingency bytes.

Explanation: (of a different, yet identically sized solution)

VA3(        "ABC"
VAD2T       "BCD...VWX"
+3/         concatenate and split into groups of 3
'Y]+        concatenate ["Y"]
{cv\$m      map each string using: copy, lowercase, zip, flatten
.ZzM+       concatenate ["Z", "z"]
|p          palindromize list of strings
m           map each string _ using the rest of the program and implicitly print output
  c%Nh6+H   (-len(_)/2 + 6) * 2
  )         left-pad (npm lol amirite) to length
  A(        right-pad to 10
  :m        mirror (a + a[::-1])

Run this one

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

Matricks, 105 bytes (noncompeting)

Whoa, I found a lot of bugs. The only hard part of this challenge was the cross in the middle. That makes almost half the byte count.

Run with the -A 1 flag

m+/c2+66+*r3*32%c2 7 6v{k-{}1z-L1Q}u{q-Lc2k+{}2b0b0b0a[a0a0u[a89a121]a[u0u90]]}a{Y}u[mQc9a122a122]u{z1cX}

Explanation:

m+/c2+66+*r3*32%c2 7 6                       # Construct the "normal" block
v{k-{}1z-L1Q}                                # Add the "abnormal" part above
u{q-Lc2k+{}2b0b0b0a[a0a0u[a89a121]a[u0u90]]} # Make the 1/4 of the weird diagonal
a{Y}u[mQc9a122a122]u{z1cX}                   # Mirror the block just created, adding
                                             # lowercase zs in between halves

Another bug I haven't fixed yet is that the last part, u{z1cX} doesn't work when you put the cut after the X. Will investigate/fix.

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

///, 229 bytes

/*/\/\///^/        *0/AaBbCc^cCbBaA
*1/BbCcDd^dDcCbB
*2/EeFfGg^gGfFeE
*3/HhIiJj^jJiIhH
*4/KkLlMm^mMlLkK
*5/NnOoPp^pPoOnN
*6/QqRrSs^sSrRqQ
*7/TtUuVv^vVuUtT
*8/   WwXx      xXwW
*9/       Yy  yY
/0123456789^ ZZ
^ zz
^ ZZ
9876543210

Try it online!

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

PowerShell, 150 bytes

($x='AaBbCc
BbCcDd
EeFfGg
HhIiJj
KkLlMm
NnOoPp
QqRrSs
TtUuVv
   WwXx
       Yy
         Z'-split'
'|% *ht 10|%{$_+-join$_[9..0]})
' '*9+'zz'
$x[10..0]

Try it online!

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

Brainfuck, 456 bytes

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

Try it online!

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

Python 3, 215 bytes (Non-Competing)

p=lambda l:l.ljust(10)+l[::-1].rjust(10)
a=("AaBbCc|BbCcDd|EeFfGg|HhIiJj|KkLlMm|NnOoPp|QqRrSs|TtUuVv|   WwXx|%sYy|%sZ"%(7*' ',9*' ')).split('|')
print('\n'.join([p(x)for x in a]+[' '*9+'zz']+[p(x)for x in a[::-1]]))

Try it online!

Takes some ideas from the two Python 2 solutions, but applies them to an approach using join() that seems to save quite a few bytes. It's possible that this can be golfed further; I might revisit this later.

\$\endgroup\$
  • \$\begingroup\$ Note that answers no longer have to be marked non-competing. \$\endgroup\$ – Jonathan Frech Apr 9 at 1:51
  • \$\begingroup\$ @JonathanFrech Python 3 was released long before this challenge. This must have the tag "non-competing" for some other reason. \$\endgroup\$ – pppery Sep 21 at 23:38
  • \$\begingroup\$ @pppery One thing I did notice is that this post does not create spaces to fill the chromosome's left-concave region. \$\endgroup\$ – Jonathan Frech Sep 22 at 0:39
  • \$\begingroup\$ @squid May I ask why this answer has been marked non-competing? \$\endgroup\$ – Jonathan Frech Sep 22 at 0:41
0
\$\begingroup\$

Ruby, 177 ... 145 bytes

puts r=(("%s%s%s\n"*8+"%5s%s\n%9s\n%11s")%[*?a..?c,*?b..?z].map{|x|x.upcase+x}).lines.map{|l|l=l.chop.ljust 10;l+l.reverse},"%11s"%"zz",r.reverse

Try it online!

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

Bubblegum, 168 bytes

00000000: 6dd1 c712 8230 1006 e0fb 3e45 5e85 264d  m....0....>E^.&M
00000010: 7a51 b8a1 14e9 1d91 a757 4632 ce38 9bd3  zQ.......WF2.8..
00000020: e6cb a4ec 1f26 626f dc9d 1ce3 cedd d888  .....&bo........
00000030: 819d f898 62cc ef0c 4272 4ac5 8c62 26a6  ....b...BrJ..b&.
00000040: a744 00e9 21e7 4a41 b150 72f9 2181 5a9e  .D..!.JA.Pr.!.Z.
00000050: 2bad a658 6bd5 b954 416f 8cd6 ec28 7666  +..Xk..TAo...(vf
00000060: 6b34 3a58 bd3d 3823 c5d1 19ec de02 77f2  k4:X.=8#......w.
00000070: 667f a1b8 f8b3 37b9 f0a9 2ecf ebfa b5f5  f.....7.........
00000080: fabc c0b1 1ebc 0879 0574 4648 18fe ea6d  .......y.tFH...m
00000090: c3fc b7e3 ef44 f462 f489 6833 68db 6840  .....D.b..h3h.h@
000000a0: 6894 68e8 0cf2 3d6f                      h.h...=o

Try it online!

Since this is my first Bubblegum submission, it might not be the optimal solution. Please double-check.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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