36
\$\begingroup\$

Print or return the following string:

R******* *R****** **R***** ***R**** ****R*** *****R** ******R* *******R
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*

*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
R******* *R****** **R***** ***R**** ****R*** *****R** ******R* *******R
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*

*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
R******* *R****** **R***** ***R**** ****R*** *****R** ******R* *******R
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*

*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
R******* *R****** **R***** ***R**** ****R*** *****R** ******R* *******R
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*

*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
R******* *R****** **R***** ***R**** ****R*** *****R** ******R* *******R
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*

*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
R******* *R****** **R***** ***R**** ****R*** *****R** ******R* *******R
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*

*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
R******* *R****** **R***** ***R**** ****R*** *****R** ******R* *******R
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*

*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
*....... .*...... ..*..... ...*.... ....*... .....*.. ......*. .......*
R******* *R****** **R***** ***R**** ****R*** *****R** ******R* *******R

This represents all the possible positions of a rook on an 8x8 chessboard and for each the possible moves it can make.

  • Standard I/O methods apply, you can output as a string, list of lines, matrix of characters, etc.
  • The characters used must be exactly as shown, you cannot substitute them for others.
  • Trailing whitespace is permitted on each line, and trailing newlines are permitted, but otherwise the output and spacing must be exactly as shown.
  • This is code golf, the shortest code in bytes wins.
\$\endgroup\$
3
  • \$\begingroup\$ Several answers have a full line of spaces at the end of the output. Is this acceptable as a combination of trailing newlines and trailing whitespace on each line? \$\endgroup\$
    – DLosc
    Commented Aug 15, 2022 at 21:17
  • \$\begingroup\$ "A challenge for rookies"? Heh, I'm too rusty to solve any more challenges \$\endgroup\$
    – DialFrost
    Commented Aug 16, 2022 at 0:32
  • \$\begingroup\$ @DLosc Yes, that's acceptable to me. \$\endgroup\$
    – Sisyphus
    Commented Aug 16, 2022 at 3:14

34 Answers 34

41
\$\begingroup\$

J, 29 27 24 23 bytes

' .*xR'{~*/~,0,.~1+=i.8

Try it online!

My initial observation was that the output is essentially a row-wise function table of the 8x8 identity matrix with itself, where each evaluation is simply an ordinary addition table: row_i +/ row_j.

This can be simplified further by flattening the identity matrix first, as follows:

  • 1+=i.8 8 by 8 identity table, plus 1:

    2 1 1 1 1 1 1 1
    1 2 1 1 1 1 1 1
    1 1 2 1 1 1 1 1
    1 1 1 2 1 1 1 1
    1 1 1 1 2 1 1 1
    1 1 1 1 1 2 1 1
    1 1 1 1 1 1 2 1
    1 1 1 1 1 1 1 2
    
  • 0,.~ Add a column of zeros

    2 1 1 1 1 1 1 1 0
    1 2 1 1 1 1 1 1 0
    1 1 2 1 1 1 1 1 0
    1 1 1 2 1 1 1 1 0
    1 1 1 1 2 1 1 1 0
    1 1 1 1 1 2 1 1 0
    1 1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 1 1 1 0 1 1 2 1 1 1 1 1 0 1 1 1 2 1 1 1 1 0 1 1 1 1 2 1 1 1 0 1 1 1 1 1 2 1 1 0 1 1 1 1 1 1 2 1 0 1 1 1 1 1 1 1 2 0
    4 2 2 2 2 2 2 2 0 2 4 2 2 2 2 2 2 0 2 2 4 2 2 2 2 2 0 2 2 2 4 2 2 2 2 0 2 2 2 2 4 2 2 2 0 2 2 2 2 2 4 2 2 0 2 2 2 2 2 2 4 2 0 2 2 2 2 2 2 2 4 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    
  • ' .*xR'{~ Convert to ascii. This returns the required pattern.

\$\endgroup\$
2
  • 4
    \$\begingroup\$ brilliant! i'm stealing this :) \$\endgroup\$
    – ngn
    Commented Aug 15, 2022 at 12:58
  • 1
    \$\begingroup\$ ended up shorter in k because of the "identity matrix" primitive (=n) and out-of-bounds indexing returning spaces \$\endgroup\$
    – ngn
    Commented Aug 15, 2022 at 13:08
11
\$\begingroup\$

Ruby, 67 66 bytes

-1 byte thanks to @G B

A function that returns a list of lists.

->{(a=0..70).map{|x|a.map{'.*R '[x%9|_1%9<8?1[x%10]+1[_1%10]:3]}}}

Attempt This Online!

Ruby, 69 bytes

Alternatively, outputting the string to STDOUT takes two extra bytes.

71.times{|x|71.times{$><<'.*R '[x%9|_1%9<8?1[x%10]+1[_1%10]:3]};puts}

Attempt This Online!

\$\endgroup\$
1
  • 2
    \$\begingroup\$ You don't need to splat the range. \$\endgroup\$
    – G B
    Commented Aug 16, 2022 at 21:11
7
\$\begingroup\$

Python, 77 bytes (@xnor)

f=lambda*_:[[" ",I[i%10<1]][i%9<8]for i in range(71)]
I=f(I:='.*'),f(I:='*R')

Attempt This Online!

Previous Python, 79 bytes

J=[]
f=lambda I=J:[" "[~i%9:]or I[i%10<1]for i in range(71)]
J+=f('.*'),f('*R')

Attempt This Online!

Previous Python, 80 bytes

J=[]
f=lambda I=J:sum(zip(*8*[iter(8*(I+7*I[1:]))],8*' '),())
J+=f('R*'),f('*.')

Attempt This Online!

This uses the good old grouper to create lots of 8 and to mix in the separators.

\$\endgroup\$
3
  • \$\begingroup\$ Interesting trick with modifying the default argument! Here's a 76 in Python 2 with something similar, though Python 3 doesn't accept it \$\endgroup\$
    – xnor
    Commented Aug 16, 2022 at 4:15
  • \$\begingroup\$ 77 bytes in 3.8+ \$\endgroup\$
    – xnor
    Commented Aug 16, 2022 at 4:20
  • \$\begingroup\$ @xnor Nice, took me a moment to understand what's actually going on there. Note that I modified the body to show off an equal length variation. \$\endgroup\$
    – loopy walt
    Commented Aug 16, 2022 at 8:10
7
\$\begingroup\$

Python, 86 83 82 81 bytes

lambda r=range(71):[[" .*R"[i%9|j%9<8and(i%10<1)-~(j%10<1)]for i in r]for j in r]

Attempt This Online!

-1 byte thanks to @loopy walt

\$\endgroup\$
1
  • \$\begingroup\$ lambda r=range(71):[[" .*R"[i%9|j%9<8and(i%10<1)-~(j%10<1)]for i in r]for j in r] for 81. \$\endgroup\$
    – loopy walt
    Commented Aug 16, 2022 at 11:27
7
\$\begingroup\$

K (ngn/k), 34 32 30 24 20 bytes

".*R"a+\:a:,/|+|3,=8

Try it online!

idea from jonah's solution

=8 identity matrix

3, prepend a 3

| reverse

+ transpose (this will extend the 3 to eight copies)

| reverse again

,/ raze

a: assign to a

a+\: add-each-right, i.e. make a matrix in which element i,j is a[i]+a[j]

".*R" index into this string. out-of-bounds indices generate " "-s in the result.

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

MATL, 26 25 24 21 20 bytes

'.*xR '8XyQO9Y(le&*)

Try it online!

-3 bytes thanks to @Luis Mendo

Explanation

Port of @Jonah answer to MATL

'.*xR '8XyQO9Y(le&*)
       8Xy              % 8 x 8 identity matrix
          Q             % add one
           O9Y(         % add a row of zeros to the end
               le       % flatten
                 &*     % multiply with itself
'.*xR '            )    % convert numbers to required codepoints
\$\endgroup\$
0
6
\$\begingroup\$

sed -E, 125 bytes

s/^/Rssssssss/
s/.*/&&&&&&&&/
s/.{8}$//
s/.{8}/& /g
y/s/*/
h
y/R*/*./
H;H;H;H;H;H;H;H
g;H;H;H;G;G
s/.{584}/&\n/g
s/.{1244}$//

Attempt This Online!

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

gbz80 machine code, 73 72 70 bytes

21 00 C0 06 00 0E 00 16 00 1E 00 36 00 78 B9 20
01 34 7A BB 20 01 34 AF BE 28 08 3C BE 28 08 3E
52 18 06 3E 2E 18 02 3E 2A 22 3E 08 1C BB 20 DB
36 20 23 14 BA 20 D2 36 0A 23 0C B9 20 C9 36 0A
23 04 B8 20 C0 76

As an ASM rookie, I gladly accept.

The string is returned in $C000-$D247 ($1248 long, nice). You may check it by copying that range using an emulator debugger (it finishes very quickly, you'll know it's done if the program counter is on or after the halt) into a text file and opening it with a text editor that supports LF. The emulator I used is BGB.

This code can be placed anywhere in a ROM and jumped to from the entrypoint, or called as a routine if the $76 (halt) at the end is replaced with a $C9 (ret).

Source, which may be assembled with RGBDS:

section "Header", ROM0[$100]
    jr GenerateMetaTable    ; the generated binary could be placed anywhere because of the lack of calls and jps

    ds $150 - @, 0          ; Make room for the header

GenerateMetaTable:
    ld hl, LotsaSpace
    ld b, 0                 ; meta-line tracker. each of these hardcoded zeroes is necessary because all of these registers change
.outermost:
    ld c, 0                 ; sub-line tracker
.mediumOuter:
    ld d, 0                 ; meta-row tracker
.mediumInner:
    ld e, 0                 ; sub-row tracker
.innermost:
    ld [hl], 0              ; we're out of registers (besides a which is used for comparing), but we have this convenient value we're pointing to that will get overwritten anyway.
    ld a, b
    cp a, c                 ; meta-line == sub-line -> rook move or rook position
    jr nz, .skipFirstInc
    inc [hl]
    .skipFirstInc:
    ld a, d
    cp a, e                 ; meta-row == sub-row -> rook move or rook position
    jr nz, .skipSecondInc
    inc [hl]
    .skipSecondInc:
    xor a, a
    cp a, [hl]
    jr z, .period           ; [hl] == 0 -> neither rook position nor rook move
    inc a
    cp a, [hl]
    jr z, .star             ; [hl] == 1 -> rook move
    ld a, "R"               ; [hl] == 2 -> rook position
    jr .write
.period:
    ld a, "."
    jr .write
.star:
    ld a, "*"
.write:
    ld [hl+], a
.innermostEnd:
    ld a, 8
    inc e
    cp a, e
    jr nz, .innermost
    ld [hl], " "
    inc hl
.mediumInnerEnd:
    inc d
    cp a, d
    jr nz, .mediumInner
    ld [hl], "\n"
    inc hl
.mediumOuterEnd:
    inc c
    cp a, c
    jr nz, .mediumOuter
    ld [hl], "\n"
    inc hl
.outermostEnd:
    inc b
    cp a, b
    jr nz, .outermost
HangMachine:
    db $76                  ; directly encoded halt, saves one byte over "halt", which automatically adds a nop
                            ; this is here to prevent the program from repeating endlessly. that may not seem problematic, but if a tester stops it while [hl] is being used to hold the match count, they'll copy a bad output.
                            ; to make GenerateMetaTable a function, just replace this with "ret"

section "Memory", WRAM0
LotsaSpace:
    ; we need $1248 of space, but we can't just ds it because WRAM0 is $1000 long. no formalism for you. we don't bank-switch ever, so it's not a problem.

Edit 1: "ld a, 0" -> "xor a, a", -1 byte

Edit 2: rearranging character loading jumps allowed removal of one, -2 bytes

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

C (GCC), 102 bytes

main(i,k){for(i=9;++i<82;puts(""))for(k=9;++k<82;)putchar(k%9&&i%9?i%10|k%10?i%10&&k%10?46:42:82:32);}

Attempt This Online!

C (GCC), 111 109 107 bytes

#define F(X,c)for(X=0;++X<9;putchar(c))
main(i,j,k,l){F(i,10)F(j,10)F(k,32)F(l,i-j|k-l?i-j&&k-l?46:42:82);}

Attempt This Online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ also 102 \$\endgroup\$
    – c--
    Commented Aug 16, 2022 at 23:37
4
\$\begingroup\$

Knight, 80 bytes

;=i~1W>8=i+1i;=j~1;W>8=j+1j;=x~1;W>8=x+1xO+I?j iS*'*'8xT'R'S*'.'8xT'*'' \'O''O''

Try It Online!

\$\endgroup\$
3
  • 5
    \$\begingroup\$ ... but this is a problem about a Rook, not a Knight... \$\endgroup\$
    – Neil
    Commented Aug 15, 2022 at 18:01
  • 2
    \$\begingroup\$ @Neil Well you're in luck, cuz I also got a Knight answer on a problem about a Knight :P \$\endgroup\$
    – Aiden Chow
    Commented Aug 15, 2022 at 18:17
  • \$\begingroup\$ Nice, that's certainly a fitting challenge to answer in! \$\endgroup\$
    – Neil
    Commented Aug 15, 2022 at 19:38
4
\$\begingroup\$

C#, 131 bytes

_=>{T[]F<T>(T x,T y,T z)=>new T[72].Select((_,i)=>i%10<1?x:i%9<8?y:z).ToArray();return F(F("R","*"," "),F("*","."," "),new[]{""});}

Try it online!


Makes use of an inline generic function:

_ => {
    /* both the characters within each row and the rows in the whole string follow the same pattern
     a default string, a different string at every 10th string,
     and a space string at every 9th string, starting at 8

    e.g. R******* *R****** **R***** ***R**** ****R*** *****R** ******R* *******R
    the default string is "*", the special character is "R" and the space is " "

    for the whole result string, the default string is "*....... .*...... [...]"
    the special string is "R******* *R****** [...]" and the space is either "" or " " (both work)

    */

    // generic function (defines T as the generic type), inputs of type T
    T[] F<T> (T specialChar, T defaultChar, T space) => 
    // create a new T[] of length 72, and set each element according to its index
    new T[72]
        .Select((_, i) => 
            // special char every 10th element
            i % 10 < 1 ? specialChar : 
                // space every 9 starting at 8, otherwise default
                i % 9 < 8 ? defaultChar : space
        ).ToArray();


    // construct rook (special) row string
    var a = F("R", "*", " ");
    // construct default row string
    var b = F("*", ".", " ");
    // correctly typed space for next func call
    var c = new string[] { "" };

    // construct whole string using default, special and space strings
    return F(a, b, c);
};
\$\endgroup\$
4
\$\begingroup\$

Jelly, 17 bytes

8⁼þj-‘×þ`ị“.* R ”

A niladic Link that yields a list of the lines of characters. The empty lines have trailing spaces.

Try it online! (Footer joins with newlines)

How?

Implements Jonah's brilliant method.

8⁼þj-‘×þ`ị“.* R ” - Link: no arguments
8                 - 8
  þ               - ([1..8]) table ([1..8]) with:
 ⁼                -   is equal?
    -             - -1
   j              - join
     ‘            - increment all values
        `         - use as both arguments of:
       þ          -   table with:
      ×           -     multiply
          “.* R ” - ".* R "
         ị        - index into (1-indexed and modular, so 0 gives ' ')
\$\endgroup\$
4
  • \$\begingroup\$ You can remove the trailing at the end, it is implicitly closed \$\endgroup\$
    – naffetS
    Commented Aug 15, 2022 at 23:48
  • \$\begingroup\$ Only if it were valid as a full program, which I don't think it would be without joining with newlines. \$\endgroup\$ Commented Aug 15, 2022 at 23:51
  • 1
    \$\begingroup\$ I guess you're right, I forgot about Jelly's smashing. \$\endgroup\$
    – naffetS
    Commented Aug 15, 2022 at 23:52
  • 1
    \$\begingroup\$ You've accidentally used # instead of * in your string (although it doesn't matter for the byte-count) \$\endgroup\$ Commented Aug 25, 2022 at 7:24
3
\$\begingroup\$

Retina, 64 bytes


R7*$(9*$*R)7*$(¶9*$($*7*$(9*.$*)¶)R7*$(9*$*R
%8,9,`.
 
8,9,`.+

Try it online! Explanation:


R7*$(9*$*R)7*$(¶9*$($*7*$(9*.$*)¶)R7*$(9*$*R

Replace the empty input with the pattern of Rs, *s and .s. Note that * is Retina 1's string repetition operator so actual *s have to be quoted as $*.

%8,9,`.
 

Clear out every ninth column.

8,9,`.+

Clear out every ninth row.

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

Charcoal, 31 bytes

E⁷¹⭆⁷¹§ .*R∧﹪⊕ι⁹∧﹪⊕λ⁹⊕⁺¬﹪ιχ¬﹪λχ

Try it online! Link is to verbose version of code. Explanation:

 ⁷¹                             Literal integer `71`
E                               Map over implicit range
    ⁷¹                          Literal integer `71`
   ⭆                            Map over implicit range and join
        .*R                     Literal string ` .*R`
      §                         Indexed by
              ι                 Current row
             ⊕                  Incremented
            ﹪                   Modulo
               ⁹                Literal integer `9`
           ∧                    Logical And
                   λ            Current column
                  ⊕             Incremented
                 ﹪              Modulo
                    ⁹           Literal integer `9`
                ∧               Logical And
                         ι      Current row
                        ﹪       Modulo
                          χ     Predefined variable `10`
                       ¬        Logical Not
                      ⁺         Plus
                             λ  Current column
                            ﹪   Modulo
                              χ Predefined variable `10`
                           ¬    Logical Not
                     ⊕          Incremented
                                Implicitly print

Actually using ASCII art drawing commands seems to take 51 bytes: Try it online! Link is to verbose version of code.

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

PARI/GP, 69 bytes

f()=matrix(71,,i,j,Vec(".*R ")[if(i%9&&j%9,(i%10==1)+(j%10==1)+1,4)])

Attempt This Online!

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

Rust, 171 bytes

||(0..71).any(|x|(0..72).map(|y|(x/9,y/9,x%9,y%9,y/71+1)).any(|(x,y,a,b,l)|print!("{:
<1$}",if a>7||b>7{' '}else if x==a&&y==b{'R'}else if x==a||y==b{'*'}else{'.'},l)>()))

Playground Link

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

Haskell, 99 90 89 bytes

[[" R*."!!((f(i%10)+f(k%10)+1)*f(k%9*i%9))|k<-r]|i<-r]
(%)=mod
f=fromEnum.(>0)
r=[10..81]

Attempt This Online!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ You don't need the space in front of the list comprehension. For ATO, you can use the CPP pragma and then write a =\ and continue on the next line without indentation. (Also intercalate "\n" is exactly unlines) Attempt This Online! \$\endgroup\$
    – Laikoni
    Commented Aug 17, 2022 at 21:16
  • \$\begingroup\$ @Laikoni thank you! \$\endgroup\$
    – matteo_c
    Commented Aug 18, 2022 at 9:11
3
\$\begingroup\$

Haskell, 63 bytes

q["",q" .*",q" *R"]
q l=[l!!(0^m 10-0^m 9+1)|m<-mod<$>[10..80]]

Try it online!

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

C (gcc), 140 102 bytes

#define a(z,y)for(int z=8;z--;putchar(y+10))
main(){a(i,)a(j,)a(k,22)a(l,i-j|l-k?i==j|l==k?42:46:72);}

Try it online!

#define a(z,y) for (int z=8; z--; putchar(y+10))
main() {
  a(i,) // 10 = space
    a(j,)
      a(k, 22) // 22+10 = 32, space
        a(l,
          (i - j) | (l - k) ? // subtract is quicker than != here
            i == j | l == k ? 42 : // if the x matches xor the y matches, print asterisk
              46 : // if neither match, print dot
                72); // if both match, print R, only the last number has 10 added in the macro, so 82
}
\$\endgroup\$
2
  • \$\begingroup\$ @ceilingcat Would it be shorter to use puts with & of the char? edit: it seems it's not possible like that, you need a variable first, if it was possible however, you'd need brackets which is still 102 bytes \$\endgroup\$
    – mekb
    Commented Jan 7, 2023 at 2:24
  • 1
    \$\begingroup\$ Suggest i-j&&l-k?46:42 instead of i==j|l==k?42:46 \$\endgroup\$
    – ceilingcat
    Commented Jan 7, 2023 at 7:31
3
\$\begingroup\$

Uiua, 24 bytes

⊏⊞×.⇌♭≡'⊂0+1⊞=.⇡8" .*xR"

Try it!

Port of @Jonah's J answer. Tip: when looking at the output on the Uiua pad, set the font size to the smallest by clicking the gear in the upper right so you can see the output without line wrapping.

⊏⊞×.⇌♭≡'⊂0+1⊞=.⇡8" .*xR"
                 " .*xR"  # place ascii replacements on the stack
            ⊞=.⇡8         # 8x8 identity matrix
          +1              # increment
      ≡'⊂0                # add column of zeros
     ♭                    # deshape
    ⇌                     # reverse
 ⊞×.                      # outer product
⊏                         # select
\$\endgroup\$
4
  • \$\begingroup\$ There's a leading space on each row (because 0 is put on the front), which is not allowed. \$\endgroup\$
    – Bubbler
    Commented Oct 20, 2023 at 7:58
  • \$\begingroup\$ Porting ngn's K version and applying some stack tricks gives 21: Try it \$\endgroup\$
    – Bubbler
    Commented Oct 20, 2023 at 8:29
  • \$\begingroup\$ The leading spaces have been fixed. Feel free to add the K port as another answer. \$\endgroup\$
    – chunes
    Commented Oct 20, 2023 at 17:13
  • \$\begingroup\$ Replace '⊂ with ⊂: since the new version of Uiua removed ' as a function, and this has no change in bytes. Try it \$\endgroup\$ Commented Aug 10 at 4:21
2
\$\begingroup\$

Factor + math.matrices, 97 bytes

[ 8 identity-matrix 1 m+n [ 0 suffix ] map
concat dup outer [ "\0"" .*R"zip substitute ] map ]

Try it online!

A straight translation of @Jonah's excellent J answer.

  • 8 identity-matrix Make an 8x8 identity matrix.
  • 1 m+n Add 1 to each element of the matrix.
  • [ 0 suffix ] map Add a column of 0s to the far right end of the matrix.
  • concat Flatten the matrix into a list.
  • dup outer Take the outer product with itself.
  • [ "\0"" .*R"zip substitute ] map Convert the resulting matrix to the required code points.
\$\endgroup\$
2
\$\begingroup\$

V (vim), 42 bytes

iR·* 7o*·. {7ñä}$FR7jdpbñGï{7ñäGGkdd{p

Try it online!

Hexdump:

00000000: 6952 b72a 201b 376f 2ab7 2e20 1b7b 37f1  iR.* .7o*.. .{7.
00000010: e416 7d24 4652 1637 6a64 7062 f147 ef7b  ..}$FR.7jdpb.G.{
00000020: 37f1 e447 476b 6464 7b70                 7..GGkdd{p
\$\endgroup\$
2
\$\begingroup\$

BQN (REPL), 24 bytes

" .*xR"⊏˜×⌜˜⥊∾⟜0˘1+=⌜˜↕8

Outputs a 2D array of characters. Try it at BQN online!

Explanation

Ports Jonah's J solution, which you should upvote.

" .*xR"⊏˜×⌜˜⥊∾⟜0˘1+=⌜˜↕8
                        ↕8  Range(8)
                     =⌜˜    Equality table with self (8x8 identity matrix)
                   1+       Add 1 to each (main diagonal is 2s, rest is 1s)
               ∾⟜0˘        Append 0 to each row
             ⥊              Deshape into a flat list
          ×⌜˜               Multiplication table with self
       ⊏˜                   Use each element of that 2D array to index into
" .*xR"                     this string

Just for fun, here's a different solution (27 bytes) that outputs a 2D array of 2D arrays of characters (feels appropriate, but goes against the challenge's I/O requirements and also is longer):

{".*R"⊏˜r(+´𝕨‿𝕩=⋈)⌜r}⌜˜r←↕8

Try it at BQN online!

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

Vyxal, 16 bytes

8Þ□›0j:v*` €xR`İ

Try it Online!

Another port of Jonah's answer.

\$\endgroup\$
2
  • \$\begingroup\$ Sadly, we don't have a shorthand for .*? \$\endgroup\$
    – emanresu A
    Commented Aug 17, 2022 at 10:13
  • \$\begingroup\$ j now does work on lists, so this can be updated \$\endgroup\$
    – emanresu A
    Commented Jan 20, 2023 at 5:22
1
\$\begingroup\$

Pyth, 36 bytes

VJU71sm@>".*R "+!%NT!%dT_<7.|%d9%N9J

Try it online!

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

JShell (Java), 191 188 bytes

void f(String x){System.out.print(x);}int i,j,x,y;for(j=0;j<8;j++){for(y=0;y<8;y++){for(i=0;i<8;i++){for(x=0;x<8;x++){int X=i^x,Y=j^y;f(X*Y<1?X+Y<1?"R":"x":".");}f(" ");}f("\n");}f("\n");}

Or, expanded:

void f(String x) {
    System.out.print(x);
}

int i, j, x, y;
for (j = 0; j < 8; j++) {
    for (y = 0; y < 8; y++) {
        for (i = 0; i < 8; i++) {
            for (x = 0; x < 8; x++) {
                int X = i ^ x;
                int Y = j ^ y;
                f(X * Y < 1 ? X + Y < 1 ? "R" : "x" : ".");
            }
            f(" ");
        }
        f("\n");
    }
    f("\n");
}
\$\endgroup\$
2
  • 2
    \$\begingroup\$ Welcome to CGCC, nice answer! You could save 4 bytes by using int X=i^x,Y=j^y;f(X*Y<1?X+Y<1?"R":"x":".");. \$\endgroup\$ Commented Aug 16, 2022 at 7:11
  • \$\begingroup\$ 152 bytes \$\endgroup\$
    – ceilingcat
    Commented Oct 8, 2022 at 15:14
1
\$\begingroup\$

Dart, 173 bytes

main(){var l=[0,1,2,3,4,5,6,7],s="R"+"*"*7+"*......."*7,p=" "*7+"\n",i,j,k,m;print([for(i in l)...[for(j in l)for(k in l)...[for(m in l)s[(k^m)*8+i^j],p[k]],"\n"]].join());}
//       1         2         3         4         5         6         7         8         9         0         1         2         3         4         5         6         7            
//345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123

Pretty-printed:

main() {
  var l = [0, 1, 2, 3, 4, 5, 6, 7],
      s = "R" + "*" * 7 + "*......." * 7,
      p = " " * 7 + "\n",
      i, j, k, m;
  print([
    for (i in l) ...[
      for (j in l)
        for (k in l) ...[for (m in l) s[(k ^ m) * 8 + i ^ j], p[k]],
      "\n"
    ]
  ].join());
}
\$\endgroup\$
1
\$\begingroup\$

Perl 5, 100 bytes

print$_%72?$_/72%9?$_%9?($v=1==$_%72%10)&($h=1==$_/72%9-$_/648)?R:$v|$h?'*':'.':$":'':$/for 73..5184

Try it online!

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

Java, 151 145 137 bytes

for(int y=0,x,a,b;++y<72;){var s="";for(x=1;x<72;s+=x++%9*(y%9)<1?' ':a+b<1?'R':a*b<1?'*':'.'){a=~-x%10;b=~-y%10;}System.out.println(s);}

Attempt This Online! Link is to a "normal" Java version, as I don't know if the link to the online JShell will stay valid.

Jeffrey's answer made me aware of JShell, which saves a couple of bytes compared to a lambda function or an interface. EDIT It also reminded me that ternary ifs don't always need parentheses. Thanks!

-8 bytes thanks to @ceilingcat!

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

Uiua, 21 bytes

⬚@ ⊏⊞+.♭⊠⊂⊞=.⇡.8".*R"

Try it online!

A port of ngn's K answer, which is also based on Jonah's J but adds a deliberate out-of-bounds indexing trick. With size 4 instead of 8, the following vector is generated:

[1 0 0 0 4 0 1 0 0 4 0 0 1 0 4 0 0 0 1 4]

and its self outer product by addition gives

╭─                                         
╷ 2 1 1 1 5 1 2 1 1 5 1 1 2 1 5 1 1 1 2 5  
  1 0 0 0 4 0 1 0 0 4 0 0 1 0 4 0 0 0 1 4  
  1 0 0 0 4 0 1 0 0 4 0 0 1 0 4 0 0 0 1 4  
  1 0 0 0 4 0 1 0 0 4 0 0 1 0 4 0 0 0 1 4  
  5 4 4 4 8 4 5 4 4 8 4 4 5 4 8 4 4 4 5 8  
  1 0 0 0 4 0 1 0 0 4 0 0 1 0 4 0 0 0 1 4  
  2 1 1 1 5 1 2 1 1 5 1 1 2 1 5 1 1 1 2 5  
  1 0 0 0 4 0 1 0 0 4 0 0 1 0 4 0 0 0 1 4  
  1 0 0 0 4 0 1 0 0 4 0 0 1 0 4 0 0 0 1 4  
  5 4 4 4 8 4 5 4 4 8 4 4 5 4 8 4 4 4 5 8  
  1 0 0 0 4 0 1 0 0 4 0 0 1 0 4 0 0 0 1 4  
  1 0 0 0 4 0 1 0 0 4 0 0 1 0 4 0 0 0 1 4  
  2 1 1 1 5 1 2 1 1 5 1 1 2 1 5 1 1 1 2 5  
  1 0 0 0 4 0 1 0 0 4 0 0 1 0 4 0 0 0 1 4  
  5 4 4 4 8 4 5 4 4 8 4 4 5 4 8 4 4 4 5 8  
  1 0 0 0 4 0 1 0 0 4 0 0 1 0 4 0 0 0 1 4  
  1 0 0 0 4 0 1 0 0 4 0 0 1 0 4 0 0 0 1 4  
  1 0 0 0 4 0 1 0 0 4 0 0 1 0 4 0 0 0 1 4  
  2 1 1 1 5 1 2 1 1 5 1 1 2 1 5 1 1 1 2 5  
  5 4 4 4 8 4 5 4 4 8 4 4 5 4 8 4 4 4 5 8  
                                          ╯

In this matrix, 0, 1, 2 correspond to .*R respectively, and anything larger is a space, so "index into ".*R" with any out-of-bounds indexes mapped to spaces" gives the correct matrix of characters. Any number >= 3 works for the padding; reusing 8 saves a byte over hardcoding any other number (which requires a space between the two numbers).

⬚@ ⊏⊞+.♭⊠⊂⊞=.⇡.8".*R"
              ⊞=.⇡ 8        identity matrix of size 8
        ♭⊠⊂     .         append 8 to each row and flatten
     ⊞+.                    self outer product by addition
    ⊏               ".*R"    select; convert 0, 1, 2 into ".*R"...
⬚@                           and all others to spaces
\$\endgroup\$

Your Answer

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

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