Skip to main content
Commonmark migration
Source Link

RAD, 51 46 39 bytes

{+/(⍵∘+¨(⊖,⊢)(⊢,-)(⍳2)(1¯2))∊,W}¨¨W←⍳⍵⍵

Try it online!

##How?

How?

Counts the number of valid knight moves for each square by seeing which knight moves would land on the board:

{+/(⍵∘+¨(⊖,⊢)(⊢,-)(⍳2)(1¯2))∊,W}¨¨W←⍳⍵⍵
 +/                                     - The number of ...
                            ∊,W         - ... in-bounds ...
        (⊖,⊢)(⊢,-)(⍳2)(1¯2)             - ... knight movements ...
   (⍵∘+¨                   )            - ... from ...
{                              }¨¨W←⍳⍵⍵ - ... each square

RAD, 51 46 39 bytes

{+/(⍵∘+¨(⊖,⊢)(⊢,-)(⍳2)(1¯2))∊,W}¨¨W←⍳⍵⍵

Try it online!

##How?

Counts the number of valid knight moves for each square by seeing which knight moves would land on the board:

{+/(⍵∘+¨(⊖,⊢)(⊢,-)(⍳2)(1¯2))∊,W}¨¨W←⍳⍵⍵
 +/                                     - The number of ...
                            ∊,W         - ... in-bounds ...
        (⊖,⊢)(⊢,-)(⍳2)(1¯2)             - ... knight movements ...
   (⍵∘+¨                   )            - ... from ...
{                              }¨¨W←⍳⍵⍵ - ... each square

RAD, 51 46 39 bytes

{+/(⍵∘+¨(⊖,⊢)(⊢,-)(⍳2)(1¯2))∊,W}¨¨W←⍳⍵⍵

Try it online!

How?

Counts the number of valid knight moves for each square by seeing which knight moves would land on the board:

{+/(⍵∘+¨(⊖,⊢)(⊢,-)(⍳2)(1¯2))∊,W}¨¨W←⍳⍵⍵
 +/                                     - The number of ...
                            ∊,W         - ... in-bounds ...
        (⊖,⊢)(⊢,-)(⍳2)(1¯2)             - ... knight movements ...
   (⍵∘+¨                   )            - ... from ...
{                              }¨¨W←⍳⍵⍵ - ... each square
deleted 55 characters in body
Source Link
Adalynn
  • 6.2k
  • 1
  • 17
  • 36

RAD, 51 4646 39 bytes

{+/(⍵∘+¨,(4 2⍴⌽,⊢,-)(⊢,-∘⌽)¨(⍳2)(1¯2))∊,W}¨¨W←⍳⍵⍵

Try it online!Try it online!

##How?

Counts the number of valid knight moves for each square by seeing which knight moves would land on the board:

{+/(⍵∘+¨,(4 2⍴⌽,⊢,-)(⊢,-∘⌽)¨(⍳2)(1¯2))∊,W}¨¨W←⍳⍵⍵
 +/                                            - The number of ...
                                   ∊,W         - ... in-bounds ...
        ,(4 2⍴⌽,⊢,-)(⊢,-∘⌽)¨(⍳2)(1¯2)             - ... knight movements ...
   (⍵∘+¨                          )            - ... from ...
{                                     }¨¨W←⍳⍵⍵ - ... each square

RAD, 51 46 bytes

{+/(⍵∘+¨,(4 2⍴⌽,⊢,-,-∘⌽)¨(⍳2)(1¯2))∊,W}¨¨W←⍳⍵⍵

Try it online!

##How?

Counts the number of valid knight moves for each square by seeing which knight moves would land on the board:

{+/(⍵∘+¨,(4 2⍴⌽,⊢,-,-∘⌽)¨(⍳2)(1¯2))∊,W}¨¨W←⍳⍵⍵
 +/                                            - The number of ...
                                   ∊,W         - ... in-bounds ...
        ,(4 2⍴⌽,⊢,-,-∘⌽)¨(⍳2)(1¯2)             - ... knight movements ...
   (⍵∘+¨                          )            - ... from ...
{                                     }¨¨W←⍳⍵⍵ - ... each square

RAD, 51 46 39 bytes

{+/(⍵∘+¨(,⊢)(⊢,-)(⍳2)(1¯2))∊,W}¨¨W←⍳⍵⍵

Try it online!

##How?

Counts the number of valid knight moves for each square by seeing which knight moves would land on the board:

{+/(⍵∘+¨(,⊢)(⊢,-)(⍳2)(1¯2))∊,W}¨¨W←⍳⍵⍵
 +/                                     - The number of ...
                            ∊,W         - ... in-bounds ...
        (,⊢)(⊢,-)(⍳2)(1¯2)             - ... knight movements ...
   (⍵∘+¨                   )            - ... from ...
{                              }¨¨W←⍳⍵⍵ - ... each square
added 424 characters in body
Source Link
Adalynn
  • 6.2k
  • 1
  • 17
  • 36

RAD, 51 46 bytes

{+/(⍵∘+¨,(4 2⍴⌽,⊢,-,-∘⌽)¨(⍳2)(1¯2))∊,W}¨¨W←⍳⍵⍵

Try it online!

##How?

Counts the number of valid knight moves for each square by seeing which knight moves would land on the board.:

{+/(⍵∘+¨,(4 2⍴⌽,⊢,-,-∘⌽)¨(⍳2)(1¯2))∊,W}¨¨W←⍳⍵⍵
 +/                                            - The number of ...
                                   ∊,W         - ... in-bounds ...
        ,(4 2⍴⌽,⊢,-,-∘⌽)¨(⍳2)(1¯2)             - ... knight movements ...
   (⍵∘+¨                          )            - ... from ...
{                                     }¨¨W←⍳⍵⍵ - ... each square

RAD, 51 46 bytes

{+/(⍵∘+¨,(4 2⍴⌽,⊢,-,-∘⌽)¨(⍳2)(1¯2))∊,W}¨¨W←⍳⍵⍵

Try it online!

Counts the number of valid knight moves for each square by seeing which knight moves would land on the board.

RAD, 51 46 bytes

{+/(⍵∘+¨,(4 2⍴⌽,⊢,-,-∘⌽)¨(⍳2)(1¯2))∊,W}¨¨W←⍳⍵⍵

Try it online!

##How?

Counts the number of valid knight moves for each square by seeing which knight moves would land on the board:

{+/(⍵∘+¨,(4 2⍴⌽,⊢,-,-∘⌽)¨(⍳2)(1¯2))∊,W}¨¨W←⍳⍵⍵
 +/                                            - The number of ...
                                   ∊,W         - ... in-bounds ...
        ,(4 2⍴⌽,⊢,-,-∘⌽)¨(⍳2)(1¯2)             - ... knight movements ...
   (⍵∘+¨                          )            - ... from ...
{                                     }¨¨W←⍳⍵⍵ - ... each square
Source Link
Adalynn
  • 6.2k
  • 1
  • 17
  • 36
Loading