The Alphabet Chromosome

11

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.

Beta Decay

Posted 2016-08-23T14:30:38.083

Reputation: 21 478

14It 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. – Fatalize – 2016-08-23T14:38:06.807

1@Fatalize That's to make the challenge slightly more interesting – Beta Decay – 2016-08-23T15:44:18.067

5I would personally argue it does the opposite – Fatalize – 2016-08-23T17:26:34.930

2I believe there's a mistake in the 9th line. Should be "WwXx xXwW", not "WwXx xXWw", shouldn't it? – GOTO 0 – 2016-08-23T18:58:57.863

You probably should've used the Sandbox to get feedback before posting. – Mego – 2016-08-23T22:10:03.887

2@BetaDecay Fatalize is right, that makes the challenge more boring. – moonheart08 – 2019-03-07T15:56:04.867

Are trailing spaces allowed per line or only at the text block's end? – Jonathan Frech – 2019-09-22T00:40:43.023

Answers

18

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

Lynn

Posted 2016-08-23T14:30:38.083

Reputation: 55 648

3

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*' ').

Lynn

Posted 2016-08-23T14:30:38.083

Reputation: 55 648

3

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.

AdmBorkBork

Posted 2016-08-23T14:30:38.083

Reputation: 41 581

154 bytes - '(.{6})' instead (......) and RightPad instead tail spaces. – mazzy – 2019-03-07T04:22:42.900

3

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

Andrew Dunai

Posted 2016-08-23T14:30:38.083

Reputation: 321

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!
  • < – Erik the Outgolfer – 2016-09-04T21:30:59.357

    2

    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

    recursive

    Posted 2016-08-23T14:30:38.083

    Reputation: 8 616

    2

    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.

    Kevin Cruijssen

    Posted 2016-08-23T14:30:38.083

    Reputation: 67 575

    1-2 bytes using a mask approach: •3ô•8.D120 6 1D)bí.Bí»…abcA¦«Dus.ιv1y.;}0ð:º.∊ – Magic Octopus Urn – 2019-04-09T16:11:42.987

    1@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.ι. :) – Kevin Cruijssen – 2019-04-09T16:48:23.003

    Wow, nice improvements, I knew there had to be a better way to make that array. – Magic Octopus Urn – 2019-04-09T17:03:16.160

    1@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 – Kevin Cruijssen – 2019-04-09T17:03:39.317

    1You gotta find one more to win ;). – Magic Octopus Urn – 2019-04-09T17:09:47.773

    1@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. – Kevin Cruijssen – 2019-04-09T17:29:55.173

    @KevinCruijssen: You'll need 2 more again. :) – recursive – 2019-04-09T17:55:21.910

    @recursive Hehe. :) Not sure if I'm able to find something for -2. -1 might still be possible. Had already upvoted your Stax answer last month. Stax byte encryption has an edge here, since I doubt the unencrypted source code is shorter? ;) Btw, could you add an explanation to your answer. Curious to see your approach. – Kevin Cruijssen – 2019-04-09T18:23:33.287

    @KevinCruijssen: The unpacked stax source is now at 42 bytes. The packing concept is kind of a double-edge sword, since it makes the primary symbol alphabet smaller at the same time as reducing their effective packed size. One character instructions from printable ascii are roughly ~6.5 bits after packing, but non-ascii characters aren't usable. I decided to do it that way to keep that langauge easily type-able.

    I will add an explanation today. – recursive – 2019-04-09T18:29:04.153

    @recursive If you remove 6 more bytes from the unpacked version, I'll try to remove 2 ;p And I indeed understand the value of the unpacked vs packed version. I now copy non-ASCII characters almost every time, whereas languages like Japt or unpacked Stax could just type them. :) – Kevin Cruijssen – 2019-04-09T18:30:34.950

    @KevinCruijssen: Hah. I'll try! – recursive – 2019-04-09T18:31:24.087

    @KevinCruijssen: Added an explanation, although I can't shake the feeling there is some additional bloat in there somewhere. – recursive – 2019-04-09T21:25:23.383

    2

    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
    

    acrolith

    Posted 2016-08-23T14:30:38.083

    Reputation: 3 728

    2

    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

    ATaco

    Posted 2016-08-23T14:30:38.083

    Reputation: 7 898

    1

    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!

    mazzy

    Posted 2016-08-23T14:30:38.083

    Reputation: 4 832

    1

    Brainfuck, 456 bytes

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

    Try it online!

    orthoplex

    Posted 2016-08-23T14:30:38.083

    Reputation: 339

    1

    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.

    Blue

    Posted 2016-08-23T14:30:38.083

    Reputation: 1 986

    1

    ///, 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!

    Erik the Outgolfer

    Posted 2016-08-23T14:30:38.083

    Reputation: 38 134

    0

    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.

    Reinstate Monica

    Posted 2016-08-23T14:30:38.083

    Reputation: 1 382

    Note that answers no longer have to be marked non-competing.

    – Jonathan Frech – 2019-04-09T01:51:37.930

    @JonathanFrech Python 3 was released long before this challenge. This must have the tag "non-competing" for some other reason. – pppery – 2019-09-21T23:38:32.270

    @pppery One thing I did notice is that this post does not create spaces to fill the chromosome's left-concave region. – Jonathan Frech – 2019-09-22T00:39:23.587

    @squid May I ask why this answer has been marked non-competing? – Jonathan Frech – 2019-09-22T00:41:43.133

    0

    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!

    G B

    Posted 2016-08-23T14:30:38.083

    Reputation: 11 099

    0

    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.

    orthoplex

    Posted 2016-08-23T14:30:38.083

    Reputation: 339