28
\$\begingroup\$

A standard Scrabble board is a 15×15 grid of spaces to place letter tiles. Most of the spaces are blank but some are double word scores (pink), triple word scores (red), double letter scores (light blue), and triple letter scores (blue). There is usually a star in the very center (which counts as a double word score).

Scrabble board

Write a program or function that outputs a standard, empty Scrabble board in ASCII form where:

  • . represents an empty space

  • D represents a double word score

  • T represents a triple word score

  • d represents a double letter score

  • t represents a triple letter score

  • X represents the center star

That is, your exact output must be

T..d...T...d..T
.D...t...t...D.
..D...d.d...D..
d..D...d...D..d
....D.....D....
.t...t...t...t.
..d...d.d...d..
T..d...X...d..T
..d...d.d...d..
.t...t...t...t.
....D.....D....
d..D...d...D..d
..D...d.d...D..
.D...t...t...D.
T..d...T...d..T

optionally followed by a trailing newline.

The shortest code in bytes wins.

\$\endgroup\$
  • \$\begingroup\$ Why X and not * to represent the star? :o \$\endgroup\$ – Fatalize Sep 2 '16 at 17:09
  • 6
    \$\begingroup\$ * is too high and mighty. \$\endgroup\$ – Calvin's Hobbies Sep 2 '16 at 17:09
  • \$\begingroup\$ Why not ? :D \$\endgroup\$ – mbomb007 Sep 2 '16 at 21:46
  • 5
    \$\begingroup\$ @mbomb007 Non-ASCII char in an ASCII-art challenge? Heresy! \$\endgroup\$ – Luis Mendo Sep 2 '16 at 22:15

17 Answers 17

16
\$\begingroup\$

MATL, 59 54 52 bytes

4t:g2I5vXdK8(3K23h32h(H14(t!XR+8: 7:Pht3$)'DtdTX.'w)

Try it online!

Explanation

The code follows three main steps:

  1. Generate the 8x8 matrix

    4 0 0 3 0 0 0 4
    0 1 0 0 0 2 0 0
    0 0 1 0 0 0 3 0
    3 0 0 1 0 0 0 3
    0 0 0 0 1 0 0 0
    0 2 0 0 0 2 0 0
    0 0 3 0 0 0 3 0
    4 0 0 3 0 0 0 5
    
  2. Extend it to the 15x15 matrix

    4 0 0 3 0 0 0 4 0 0 0 3 0 0 4
    0 1 0 0 0 2 0 0 0 2 0 0 0 1 0
    0 0 1 0 0 0 3 0 3 0 0 0 1 0 0
    3 0 0 1 0 0 0 3 0 0 0 1 0 0 3
    0 0 0 0 1 0 0 0 0 0 1 0 0 0 0
    0 2 0 0 0 2 0 0 0 2 0 0 0 2 0
    0 0 3 0 0 0 3 0 3 0 0 0 3 0 0
    4 0 0 3 0 0 0 5 0 0 0 3 0 0 4
    0 0 3 0 0 0 3 0 3 0 0 0 3 0 0
    0 2 0 0 0 2 0 0 0 2 0 0 0 2 0
    0 0 0 0 1 0 0 0 0 0 1 0 0 0 0
    3 0 0 1 0 0 0 3 0 0 0 1 0 0 3
    0 0 1 0 0 0 3 0 3 0 0 0 1 0 0
    0 1 0 0 0 2 0 0 0 2 0 0 0 1 0
    4 0 0 3 0 0 0 4 0 0 0 3 0 0 4
    
  3. Index the string 'DtdTX.' with that matrix to produce the desired result.

Step 1

4        % Push 4
t:       % Duplicate, range: pushes [1 2 3 4]
g        % Logical: convert to [1 1 1 1]
2I5      % Push 2, then 3, then 5
v        % Concatenate all stack vertically into vector [4 1 1 1 1 2 3 5]
Xd       % Generate diagonal matrix from that vector

Now we need to fill the nonzero off-diagonal entries. We will only fill those below the diagonal, and then make use symmetry to fill the others.

To fill each value we use linear indexing (see this answer, length-12 snippet). That means accessing the matrix as if it had only one dimension. For an 8×8 matrix, each value of the linear index refers to an entry as follows:

1   9         57
2  10         58
3  11
4  
5  ...       ...
6  
7             63
8  16 ... ... 64

So, the following assigns the value 4 to the lower-left entry:

K        % Push 4
8        % Push 8
(        % Assign 4 to the entry with linear index 8

The code for the value 3 is similar. In this case the index is a vector, because we need to fill several entries:

3        % Push 3
K        % Push 4
23h      % Push 23 and concatenate horizontally: [4 23]
32h      % Push 32 and concatenate horizontally: [4 23 32]
(        % Assign 4 to the entries specified by that vector

And for 2:

H        % Push 2
14       % Push 14
(        % Assign 2 to that entry

We now have the matrix

4 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0
0 0 1 0 0 0 0 0
3 0 0 1 0 0 0 0
0 0 0 0 1 0 0 0
0 2 0 0 0 2 0 0
0 0 3 0 0 0 3 0
4 0 0 3 0 0 0 5

To fill the upper half we exploit symmetry:

t!       % Duplicate and transpose
XR       % Keep the upper triangular part without the diagonal
+        % Add element-wise

Step 2

The stack now contains the 8×8 matrix resulting from step 1. To extend this matrix we use indexing, this time in the two dimensions.

8:       % Push vector [1 2 ... 7 8]
7:P      % Push vector [7 6 ... 1]
h        % Concatenate horizontally: [1 2 ... 7 8 7 ... 2 1]. This will be the row index
t        % Duplicate. This will be the column index
3$       % Specify that the next function will take 3 inputs
)        % Index the 8×8 matrix with the two vectors. Gives a 15×15 matrix

Step 3

The stack now contains the 15×15 matrix resulting from step 2.

'DtdTX.' % Push this string
w        % Swap the two elements in the stack. This brings the matrix to the top
)        % Index the string with the matrix
\$\endgroup\$
  • \$\begingroup\$ This is really, really, cool. \$\endgroup\$ – AdmBorkBork Sep 2 '16 at 20:58
  • \$\begingroup\$ I like this answer in general, though it 'itches' a bit as you use 8 characters to create a vector of length 8. Have you considered obtaining the numbers by a mathematical sequence? Didn't find anything sweet yet but especially the last 7 show such a nice pattern. For instance ceil((1:7)^4/500) \$\endgroup\$ – Dennis Jaheruddin Sep 3 '16 at 9:33
  • \$\begingroup\$ @DennisJ Thanks! Yes, it feels too much. I'll try that later, on the phone now \$\endgroup\$ – Luis Mendo Sep 3 '16 at 10:21
8
\$\begingroup\$

Ruby, 103 97 bytes

Thanks to Mitch Schwartz for a 6 byte improvement on the iterations.

a=(-7..7).map &:abs
a.map{|i|puts a.map{|j|(d=i%7-j%7)%4<1?'X d t DTDdDdDtT d'[i+j+d*d/3]:?.}*''}

A similar but significantly different approach to my original answer below. As before, we use the fact that a letter must be printed if i%7-j%7 is equal to 0 or 4. But here we store that difference in d and use the formula i+j+d*d/3 to give an integer which is unique (up to symmetry) to that particular coloured square. Then we just look it up in the magic string.

Just for fun: C version of this approach, 120 bytes

z,i,j,d;f(){for(z=240;z--;)i=abs(z%16-8),j=abs(z/16-7),putchar(i-8?(d=i%7-j%7)%4?46:"X d t DTDdDdDtT d"[i+j+d*d/3]:10);}

Ruby, 115 113 bytes

2 bytes saved thanks to Value Ink.

(k=-7..7).map{|y|k.map{|x|i=x.abs;j=y.abs
$><<=(i%7-j%7)%4<1?"#{'XdTdT'[(i+j)/3]}dtDDDD"[[i%7,j%7].min]:?.}
puts}

Explanation

The origin is considered to be the centre of the board.

A letter must be printed if the x and y coordinates of the square have magnitudes that are identical or differ by 4. The only exceptions are on the outer edge of the board, but these follow the same pattern as the central row/column of the board, so we can use the same condition if we take the x and y coordinates modulo 7.

The choice of letter displayed is based on the coordinate of minimum magnitude. In this way the doubles and triples at (1,5) and (2,6) follow the same rule as at (1,1) and (2,2) and are obtained from the 7 character string "#{formula}dtDDDD" This does not cover all variations for the edge and centreline squares, so the first character of the string is calculated from the formula 'XdTdT'[(i+j)/3].

(k=-7..7).map{|y|
  k.map{|x|
    i=x.abs;j=y.abs
    print (i%7-j%7)%4<1?      #IF this expression is true print a letter 
    "#{'XdTdT'[(i+j)/3]       #select 1st character of magic string where [i%7,j%7].min==0 
     }dtDDDD"[[i%7,j%7].min]: #remaining 6 characters of magic string for diagonal
    ?.                        #ELSE print .
  }
  puts                        #at the end of the row print a newline
}
\$\endgroup\$
  • \$\begingroup\$ (k=-7..7).map{|y|k.map{... is 2 bytes shorter than your double -7.upto(7) technique. \$\endgroup\$ – Value Ink Sep 2 '16 at 22:44
  • \$\begingroup\$ A few modifications to save 6 bytes: a=(-7..7).map &:abs;a.map{|i|puts a.map{|j|(d=i%7-j%7)%4<1?'X d t DTDdDdDtT d'[i+j+d*d/3]:?.}*''} \$\endgroup\$ – Mitch Schwartz Sep 3 '16 at 1:37
7
\$\begingroup\$

brainfuck, 598 596 590 bytes

Golfing tips welcome.

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

Explanation

Initialize the tape to [10 116 68 46 100 84 92] i.e. [nl t D . d T \]

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

Each line here then prints one line of the board.
The middle line also decreases 92 to 88 i.e. \ to X

.<<..>.<...>>.<<...>.<..>>.<<<<<.
>>>.<.>...<<.>>...<<.>>...<.>.<<<.
>>>..<.>...>.<.>.<...<.>..<<<.
>>>>.<..<.>...>.<...<.>..>.<<<<.
>>>....<.>.....<.>....<<<.
>>>.<<.>>...<<.>>...<<.>>...<<.>>.<<<.
>>>..>.<...>.<.>.<...>.<..<<<.
>>>>>.<<..>.<...>>>----.<<<...>.<..>>.<<<<<.
>>>..>.<...>.<.>.<...>.<..<<<.
>>>.<<.>>...<<.>>...<<.>>...<<.>>.<<<.
>>>....<.>.....<.>....<<<.
>>>>.<..<.>...>.<...<.>..>.<<<<.
>>>..<.>...>.<.>.<...<.>..<<<.
>>>.<.>...<<.>>...<<.>>...<.>.<<<.
>>>>>.<<..>.<...>>.<<...>.<..>>.

Try it online!

\$\endgroup\$
  • 1
    \$\begingroup\$ Tips for BF: don't ascii golf in BF; nice strategy though. \$\endgroup\$ – Magic Octopus Urn Mar 9 '17 at 17:01
5
\$\begingroup\$

PowerShell v2+, 147 bytes

($x='T..d...T...d..T')
($y='.D...t..','..D...d.','d..D...d','....D...','.t...t..','..d...d.'|%{$_+-join$_[6..0]})
$x-replace'.T.','.X.'
$y[5..0]
$x

Takes advantage of how the default Write-Output at end of program execution handles arrays (i.e., it inserts a newline between elements). Might be a better way to generate the middle of the board -- I'm still working at it.

The first line outputs the top line of the board, also storing it in $x for use later.

The next line generates all the Double-Word lines by taking the left "half" of each, mirroring them (the -join$_[6..0] statement), and storing them as elements in array $y.

The next line is the middle row, with an X in the middle, thanks to -replace.

The next line outputs $y in reverse order, giving us the bottom Double-Word lines.

The final line is just $x again.

PS C:\Tools\Scripts\golfing> .\draw-empty-scrabble-board.ps1
T..d...T...d..T
.D...t...t...D.
..D...d.d...D..
d..D...d...D..d
....D.....D....
.t...t...t...t.
..d...d.d...d..
T..d...X...d..T
..d...d.d...d..
.t...t...t...t.
....D.....D....
d..D...d...D..d
..D...d.d...D..
.D...t...t...D.
T..d...T...d..T
\$\endgroup\$
5
\$\begingroup\$

><> (Fish), 153 Bytes

\!o;!?l
\'T..d...T...d..T'a'.D...t...t...D.'a'..D...d.d...D..'a'd..D...d...D..d'a'....D.....D....'a'.t...t...t...t.'a'..d...d.d...d..'a'T..d...'
\'X/'02p

A horribly, awfully, inefficient way of doing things. Currently looking into a way of shortening it down by mirroring both horizontally and vertically properly.

Try it online! (If you don't want to be there all day make sure you either set execution speed to max or run without the animation.)

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

C, 146 145 142 138 bytes

i,r,c;main(){for(;i<240;)r=abs(i/16-7),c="T..12..0..12..0"[r+7-abs(i%16-7)],putchar(++i%16?c&4?c:"Xd.dd.tt.D..D.dD.dD.tTd."[c%4+r*3]:10);}

Try it online!

1 byte5 bytes saved thanks to Level River St

This exploits the diagonal pattern of the board for encoding. In particular, if we take the top left quadrant of the board and align the diagonal, we get:

       T..d...T
      .D...t..
     ..D...d.
    d..D...d
   ....D...
  .t...t..
 ..d...d.
T..d...X

...a lot of the columns now line up. If we encode columns in a line this way:

       0..12..0 y/012/Td./
      .0..12..  y/012/D.t/
     ..0..12.   y/012/D.d/
    2..0..12    y/012/D.d/
   12..0..1     y/012/D../
  .12..0..      y/012/tt./
 ..12..0.       y/012/dd./
T..12..0        y/012/Xd./

...then the board pattern can be collapsed into a 15 character string: T..12..0..12..0; and we simply need the right mappings for each row.

With that in mind, here's an expanded version with comments:

i,r,c;
main() {
   for(;i<240;)  // one char per output including new line
   r=abs(i/16-7) // row; goes from 7 to 0 and back to 7.
   , c="T..12..0..12..0"[r+7-abs(i%16-7)] // pattern char
   , putchar(++i%16 // if this is 0 we need a new line
   ? c&4 // hash to distinguish 'T' and '.' from '0', '1', '2'
     ? c // print 'T' and '.' literally
     : "Xd.dd.tt.D..D.dD.dD.tTd."[c%4+r*3] // otherwise look up replacement char
   : 10 // print the new line
   );
}
\$\endgroup\$
  • \$\begingroup\$ Very nice. 1. you can submit a function instead of a program, so i,r,c;f()is fine. 2. (i%16-7)%8 -> i%16-7&7 3. I think c-48 -> c%4 works, doesnt it? \$\endgroup\$ – Level River St Sep 3 '16 at 10:28
  • \$\begingroup\$ Oops, sorry, functions have to be reusable, so f() would require an addtional i=0 inside the function so it wouldn't save anything. \$\endgroup\$ – Level River St Sep 3 '16 at 10:35
  • \$\begingroup\$ Thanks for comments! 2 won't work either (%8 uses the implementation's negative moduli to map %16 values 0..15 to -7..7; &7 would map this to 0..7,0..7). But, yes, 3 will absolutely work... will update when I get a chance. \$\endgroup\$ – H Walters Sep 3 '16 at 16:43
  • \$\begingroup\$ @LevelRiverSt Mea culpa; 2 still won't strictly work, but I didn't need that stuff anyway. \$\endgroup\$ – H Walters Sep 3 '16 at 21:37
3
\$\begingroup\$

05AB1E, 57 53 bytes

Code

•jd]31‚ŽÔc¦Ïïì¹Ep.Üì8Ìa;“•6B4ÝJ".TdDt"‡5'.3×:Â'Xý15ô»

Uses the CP-1252 encoding. Try it online!


Explanation (outdated)

The •4ç“–šã&$W§ñçvßÖŠ_æá_VFÛÞýi~7¾¬ÏXôc•5B decompresses to this number:

1002000100020010400030003000400040002020004002004000200040020000400000400000300030003000300020002020002001002000

With 4ÝJ".TdtD"‡, we transliterate the following in this big number:

0 -> .
1 -> T
2 -> d
3 -> t
4 -> D

We bifurcate the whole string, leaving the string and the string reversed on the stack and join them by "X" using ý. We split the entire string into pieces of 15 using th 15ô code and join the whole array by newlines using ».

\$\endgroup\$
  • \$\begingroup\$ û€û should be a built-in ;). \$\endgroup\$ – Magic Octopus Urn Mar 9 '17 at 18:22
2
\$\begingroup\$

Python 3, 138 bytes

d=lambda s:s+s[-2::-1]
print(*d(list(map(d,'T..d...T .D...t.. ..D...d. d..D...d ....D... .t...t.. ..d...d. T..d...X '.split()))),sep='\n')
\$\endgroup\$
  • \$\begingroup\$ Change list(map(A)) to [*map(A)], saves 3 bytes (requires Python 3.5+). \$\endgroup\$ – shooqie Sep 3 '16 at 8:35
2
\$\begingroup\$

05AB1E, 49 44 bytes

•1nÑ=}íge/Þ9,ÑT‰yo¬iNˆå•6B8ôû€û»5ÝJ".TtdDX"‡

Try it online!

Explained:

Push: 1003000104000200004000303004000300004000020002000030003010030005

Split into chunks of 8, palindromize each.

Palindromize again.

Replace numbers with characters.


Other Idea (Someone Try this in MATL)

Seeing as EVERYTHING is garunteed to have a period inbetween it...

Count the number of zeros inbetween each piece:

1003000104000200004000303004000300004000020002000030003010030005
^  ^   ^ ^   ^    ^   ^ ^  ^   ^    ^    ^   ^    ^   ^ ^  ^   ^

131424334342233135 => w\F6ß¿

Taking the counts of zeros runs:

23134312344343123 => ì:¼˜¾

Then you would decrypt and transpose them together.

Using them in 05AB1E (results in a +5 byte increase):

05AB1E, 27 bytes

•w\F6ß¿•6BS•ì:¼˜¾•5BS0ׂøJJ

Try it...


Meta-golfed entry:

05AB1E, 104 bytes

•G¨J´JÏÍ?»"”Ö3úoÙƒ¢y”vf%¯‚6À°IÕNO’Å2Õ=ÙŠxn®žÑŸ¶¼t¨š,Ä]ÓŽÉéȺÂ/ø‡ŸÖ|e³J—Ë'~!hj«igċ΂wî’©•7BžLR"
.DTXdt"‡

Try it!

Meta-golfed using my meta-golfer for ASCII art: https://tio.run/nexus/05ab1e#JY9NSgNBEIWvUo4/qAQxyfi30yAioiAiuBM6M9U9DT3doao7ccBFrhI3ooss3QguJniRXCR2x01RfK9479Xqtf2@XHy2H78/tw/L6aydq8VXr5sPsuX0LeP1jCwbJD3r54v3dp5mFGbZzWp1wXBPyLpE6@GRQj0C1spiCQJ4gjjSVgG@YBG8HiM4KpHAWbgiXYqmA1wF79ONrxCGa5nBOyCUQSEyCFuCi2LEklwNjGO0YAQpNA3cBTa6hsIF60kjd9Y@jAWhF9SAk1C5Gk1yiTSQ9g1MBKcKAp4q7RGuXWCMFlYioS3iKowBhf@9Kh2DNbEHGSIexhSZeDRIUcq4oTDxDS09aAsjZ3TRHGycb25tP@/s7@51e/386Pjk9OzwDw

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

Javascript (ES6), 150 bytes

_=>(r='',"T2d3T3d2T.D3t3t3D3D3d.d3D2d2D3d3D2d4D5D5t3t3t3t3d3d.d3d2T2d3".replace(/./g,c=>(c=+c?'.'.repeat(c):c,r=c+r,c))+'X'+r).match(/.{15}/g).join`
`

How it works

The string "T2d3T3d2T.D3t3t3D3D3d.d3D2d2D3d3D2d4D5D5t3t3t3t3d3d.d3d2T2d3" describes the board from its top left corner to the square just before the 'X', with consecutive empty squares encoded as digits. The replace() function both unpacks the empty squares and builds the mirror string r for the bottom of the board. Then both parts are put together and carriage returns are inserted every 15 characters.

Demo

let f =
_=>(r='',"T2d3T3d2T.D3t3t3D3D3d.d3D2d2D3d3D2d4D5D5t3t3t3t3d3d.d3d2T2d3".replace(/./g,c=>(c=+c?'.'.repeat(c):c,r=c+r,c))+'X'+r).match(/.{15}/g).join`
`
console.log(f())

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

JavaScript (ES6), 221 bytes

f=
_=>(a=[...Array(15)].map(_=>Array(15).fill`.`),r=([c,i,j])=>[a[i][j]=a[k=14-i][j]=a[i][j=14-j]=a[k][j]=c,j,i],[..."TDDDDtdX"].map((c,i)=>r([c,i,i])),"d30t51d62d73T70".replace(/.../g,s=>r(r(s))),a.map(a=>a.join``).join`
`)
;o.textContent=f()
<pre id=o>

Since I went to the trouble of creating this I thought I'd post it anyway even though there's a clearly superior solution available.

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

C 234 Bytes

#define g(t) while(i++<8)putchar(*b++);b-=2;--i;while(--i>0)putchar(*b--);putchar('\n');b+=t;
char*r="T..d...T.D...t....D...d.d..D...d....D....t...t....d...d.T..d...X";i;f(){char*b=r;do{g(9);}while(*b);b-=16;do{g(-7);}while(b>=r);}

Here's the output:

T..d...T...d..T
.D...t...t...D.
..D...d.d...D..
d..D...d...D..d
....D.....D....
.t...t...t...t.
..d...d.d...d..
T..d...X...d..T
..d...d.d...d..
.t...t...t...t.
....D.....D....
d..D...d...D..d
..D...d.d...D..
.D...t...t...D.
T..d...T...d..T
\$\endgroup\$
1
\$\begingroup\$

Charcoal, 33 bytes (noncompeting)

All credit for this answer goes to @DLosc.

T↑↑↘tdd↗→→↖XdtDDDD↓T..d‖O⟦↗→↓⟧UB.

Try it online!

Verbose

Print("T")
Move(:Up)
Move(:Up)
Print(:DownRight, "tdd")
Move(:UpRight)
Move(:Right)
Move(:Right)
Print(:UpLeft, "XdtDDDD")
Print(:Down, "T..d")
ReflectOverlap([:UpRight, :Right, :Down])
SetBackground(".")

Try it online!

\$\endgroup\$
  • \$\begingroup\$ The perfect tool for this challenge, with it's diagonal printing capabilities. +1 (and also cool to see a background method like that for ASCII) \$\endgroup\$ – Kevin Cruijssen Mar 9 '17 at 11:29
0
\$\begingroup\$

Haskell, 114 bytes

g=(++)<*>reverse.init
unlines$g$g<$>words"T..d...T .D...t.. ..D...d. d..D...d ....D... .t...t.. ..d...d. T..d...X"

g in a non-pointfree version is g x = x ++ (reverse (init x)). It is applied once per (half-)line and again on the result.

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

sh + coreutils, 119 bytes

This is a binary file. Shown as hexdump:

00000000  74 61 69 6c 20 2d 63 39  34 20 24 30 7c 67 75 6e  |tail -c94 $0|gun|
00000010  7a 69 70 0a 65 78 69 74  0a 1f 8b 08 00 2e ec ca  |zip.exit........|
00000020  57 00 03 65 4f c9 0d c0  30 08 fb 7b 18 4f 91 11  |W..eO...0..{.O..|
00000030  fc e8 00 1e a1 fb ab 08  68 a4 90 07 60 d9 98 43  |........h...`..C|
00000040  a4 49 8a 59 05 ae 40 6f  c7 22 98 84 b3 29 10 fc  |.I.Y..@o."...)..|
00000050  13 59 1d 7a 11 9d b1 bd  15 a8 56 77 26 54 c4 b3  |.Y.z......Vw&T..|
00000060  f7 0d fd f6 9f f3 ef fd  e7 7d f3 7e 8d ff 3e 05  |.........}.~..>.|
00000070  57 d9 a0 f0 00 00 00                              |W......|
00000077

Here's the base64 form so you can copy/paste it:

begin-base64 755 test.sh
dGFpbCAtYzk0ICQwfGd1bnppcApleGl0Ch+LCAAu7MpXAANlT8kNwDAI+3sY
T5ER/OgAHqH7qwhopJAHYNmYQ6RJilkFrkBvxyKYhLMpEPwTWR16EZ2xvRWo
VncmVMSz9w399p/z7/3nffN+jf8+BVfZoPAAAAA=
====
\$\endgroup\$
0
\$\begingroup\$

C 230 228 Bytes

char *s="T.D..Dd..D....D.t...t..d...dT..d...X";
int x,y,a,b;
#define X(N) {putchar(s[a]);N y<=x?1:y;}
#define P for(y=1;y<8;y++)X(a+=)for(y--;y+1;y--)X(a-=)puts("");
main(){for(;x<8;x++){a=b+=x;P}for(x=6;x+1;x--){a=b-=(x+1);P}}

try it on ideone

This is an attempt at improving the original C version posted that had quarter of board stored in a C array. Not as short as I was hoping for. This version only has one eighth of the board stored.

Ungolfed:

char *s="T.D..Dd..D....D.t...t..d...dT..d...X";
int x,y,a,b;
main(){
    for(x = 0; x < 8; x++){
        a=b+=x;
        for(y = 1; y < 8; y++){
            putchar(s[a]);
            a += y<=x ? 1 : y;
        }
        for(y--; y >= 0; y--){
            putchar(s[a]);
            a -= y<=x ? 1 : y;
        }
        puts("");
    }
    for(x=6; x >= 0; x--){
        a=b-=(x+1);
        for(y = 1; y < 8; y++){
            putchar(s[a]);
            a += y<=x ? 1 : y;
        }
        for(y--; y >= 0; y--){
            putchar(s[a]);
            a-= y<=x ? 1 : y;
        }
        puts("");
    }
}
\$\endgroup\$
0
\$\begingroup\$

GNU sed, 219 205 bytes

s/$/T..d...T...d..T/p;h
s/.*/.D...t...t...D./p;G;h
s/.*/..D...d.d...D../p;G;h
s/.*/d..D...d...D..d/p;G;h
s/.*/....D.....D..../p;G;h
s/.*/.t...t...t...t./p;G;h
s/.*/..d...d.d...d../p;G;h
s/.*\n//;s/T/X/2p;g

Taking advantage of the mirror symmetry of the board, the second half is the first one that was stored in reverse order in the hold space.

\$\endgroup\$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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