Chess Knight

Chess Knight

Simple
English RU UK

Your friend loves chess very much, but he's not a strong player. You can help him by using your programming skills.
If this mission is too simple for you, try another one from this set - The shortest Knight's path.

There is only one figure on the board - your Knight. The input data will consist of a start cell and the maximum amount of moves that the Knight can make. Your task is to write a function that can find all of the chessboard cells to which the Knight can move at not more than maximum amount of moves (less is allowed).

If the same cell appears more than once - do not add it again. To count cell as reached, you need to move there from another cell. So, you will add start cell to reached, if you may return there from some other cell. "Zero" move is not counted: initial being in start cell doesn't mean, that it's reached by moving. You should return the list of all of the possible cells and sort them as follows: in alphabetical order (from 'a' to 'h') and in ascending order (from 'a1' to 'a8' and so on).

example

Input: A start cell, the number of moves.

Output: A list of all of the possible cells.

Example:

chess_knight('a1', 1) == ['b3', 'c2']
chess_knight('h8', 2) == ['d6', 'd8', 'e5', 'e7', 'f4', 'f7', 'f8', 'g5', 'g6', 'h4', 'h6', 'h8']

How it is used: For game analysis and bot (game AI) development.

Settings
Code:
Other:
Invalid hot key. Each hot key should be unique and valid
Hot keys:
CheckiO Extensions

CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.

In order to install CheckiO client you'll need installed Python (version at least 3.8)

Install CheckiO Client first:

pip3 install checkio_client

Configure your tool

checkio --domain=py config --key=

Sync solutions into your local folder

checkio sync

(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)

checkio serv -d

Alternatevly, you can install Chrome extension or FF addon

checkio install-plugin
checkio install-plugin --ff
checkio install-plugin --chromium

Read more here about other functionality that the checkio client provides. Feel free to submit an issue in case of any difficulties.

Pair Programming (Beta-version)

Welcome to Pair Programming! Engage in real-time collaboration on coding projects by starting a session and sharing the provided unique URL with friends or colleagues. This feature is perfect for joint project development, debugging, or learning new skills together. Simply click 'Start Session' to begin your collaborative coding journey!

Waiting for Pair Programming to start...

You are trying to join a pair programming session that has not started yet.

Please wait for the session creator to join.

Waiting for Pair Programming to reconnect...

It looks like the creator of the pair programming session closed the editor window.

It might happen accidentally, so that you can wait for reconnection.

×
 
 
<< <
> >>
exec show

Whats Next?

Free accounts will see Best CheckiO solutions with some delay.
Best Solutions will be opened in a moment
Become Awesome and Don't wait
The next stage is ""
Will be activated in
View More Solutions Random Review Solutions Go to the next mission