Skip to main content
added 984 characters in body
Source Link
Adnan
  • 44.5k
  • 6
  • 82
  • 246

05AB1E, 27 25 bytes

Thanks to Emigna for saving 2 bytes!

Uses 1-indexed coordinates. Code:

Code:

F•eĆ•SÍü‚Dí«δ+€`Ùʒ{`9‹*0›

Uses the 05AB1E encoding. Try it online!

Explanation:

F                          # Do the following <input_1> times..
 •eĆ•SÍ                    #   Push [-1, -2, 1, 2, -1]
       ü‚                  #   Pairwise pairing: [[-1, -2], [-2, 1], [1, 2], [2, -1]]
         D                 #   Duplicate the array
          í                #   Reverse each element
           «               #   Concatenate to the previous array

This gives us the following array:

[[-1, -2], [-2, 1], [1, 2], [2, -1], [-2, -1], [1, -2], [2, 1], [-1, 2]]

Which are the deltas of the moves of the knight.

            δ+             #   Addition vectorized on both sides
              €`           #   Flatten each element
                Ù          #   Uniquify
                 ʒ         #   Keep elements which..
                  {`9‹     #     Has a maximum element smaller than 9
                      *0›  #     And a minimum element larger than 0

05AB1E, 27 25 bytes

Thanks to Emigna for saving 2 bytes!

Uses 1-indexed coordinates. Code:

F•eĆ•SÍü‚Dí«δ+€`Ùʒ{`9‹*0›

Uses the 05AB1E encoding. Try it online!

05AB1E, 27 25 bytes

Thanks to Emigna for saving 2 bytes!

Uses 1-indexed coordinates.

Code:

F•eĆ•SÍü‚Dí«δ+€`Ùʒ{`9‹*0›

Uses the 05AB1E encoding. Try it online!

Explanation:

F                          # Do the following <input_1> times..
 •eĆ•SÍ                    #   Push [-1, -2, 1, 2, -1]
       ü‚                  #   Pairwise pairing: [[-1, -2], [-2, 1], [1, 2], [2, -1]]
         D                 #   Duplicate the array
          í                #   Reverse each element
           «               #   Concatenate to the previous array

This gives us the following array:

[[-1, -2], [-2, 1], [1, 2], [2, -1], [-2, -1], [1, -2], [2, 1], [-1, 2]]

Which are the deltas of the moves of the knight.

            δ+             #   Addition vectorized on both sides
              €`           #   Flatten each element
                Ù          #   Uniquify
                 ʒ         #   Keep elements which..
                  {`9‹     #     Has a maximum element smaller than 9
                      *0›  #     And a minimum element larger than 0
added 52 characters in body
Source Link
Adnan
  • 44.5k
  • 6
  • 82
  • 246

05AB1E, 2727 25 bytes

Thanks to Emigna for saving 2 bytes!

Uses 1-indexed coordinates. Code:

FƵ‡4в2ô<D(«Dí«δ+€`ÙʒF•eĆ•SÍü‚Dí«δ+€`Ùʒ{`9‹*0›

Uses the 05AB1E encoding. Try it online!Try it online!

05AB1E, 27 bytes

Uses 1-indexed coordinates. Code:

FƵ‡4в2ô<D(«Dí«δ+€`Ùʒ{`9‹*0›

Uses the 05AB1E encoding. Try it online!

05AB1E, 27 25 bytes

Thanks to Emigna for saving 2 bytes!

Uses 1-indexed coordinates. Code:

F•eĆ•SÍü‚Dí«δ+€`Ùʒ{`9‹*0›

Uses the 05AB1E encoding. Try it online!

added 28 characters in body
Source Link
Adnan
  • 44.5k
  • 6
  • 82
  • 246

05AB1E, 27 bytes

Uses 1-indexed coordinates. Code:

FƵ‡4в2ô<D(«Dí«δ+€`Ùʒ{`9‹*0›

Uses the 05AB1E encoding. Try it online!

05AB1E, 27 bytes

Code:

FƵ‡4в2ô<D(«Dí«δ+€`Ùʒ{`9‹*0›

Uses the 05AB1E encoding. Try it online!

05AB1E, 27 bytes

Uses 1-indexed coordinates. Code:

FƵ‡4в2ô<D(«Dí«δ+€`Ùʒ{`9‹*0›

Uses the 05AB1E encoding. Try it online!

Source Link
Adnan
  • 44.5k
  • 6
  • 82
  • 246
Loading