# Magic with 5 cards

Moderate
Magician: John, I'm going to blow your mind with a simple magic trick. Choose five cards.
The magician turns around to see nothing.
John: I just picked five cards.
Magician: Bot will tell me four of them and I will guess the fifth one.
Bot: Jack of diamonds, Ace of hearts, Queen of clubs, King of spades.
Magician: I see red, yeah it's of diamonds... And it's not a face... It's even pretty low... The three of diamonds, right?!
The magician quickly turns around to see John's face...
John: No way!
Magician: Told you!
John: It was just luck, do it again!
Magician: I can do it all day long, dummy.

Well, it's an automatic magic trick, that I will explain in a moment. You will have to create two functions. A function named ``` bot ``` which will take five cards, an integer and return four of them ; and a function named ``` magician ``` which will take four cards, the same integer and return the fifth one.

The trick use the standard 52-card deck . Cards will be represented like ``` 'A ♥' ``` , ``` '3 ♦' ``` , ``` 'K ♠' ``` , ``` 'Q ♣' ``` , ``` 'J ♦' ``` ( ``` ♣ ``` for clubs, ``` ♦ ``` for diamonds, ``` ♥ ``` for hearts, ``` ♠ ``` for spades, A for Ace, J for Jack, Q for Queen and K for King).
We will soon need to compare cards. The deck order is ``` A ♣ < A ♦ < A ♥ < A ♠ < 2 ♣ < ... ``` . To compare two cards, look ranks ``` A < 2 < ... < 10 < J < Q < K ``` , then suits ``` ♣ < ♦ < ♥ < ♠ ``` (same order than with letters: ``` club < diamond < heart < spade ``` ).

The card the bot choose to hide and the order of the four cards the bot says is crucial for the magician so he can guess the fifth one. There are five cards, but only four suits so there are at least two cards from the same suit, we name them card A and card B . The bot will hide one and say the other, but which one? Imagine the thirteen cards in a circle, clockwise . If going from card A to card B on this circle is quicker than going from card B to card A , then we will hide card B , say card A , and the distance from card A to card B is noted as delta (it's necessarily a number between one and six). We still have three cards to say, and since there are six ways to tell three cards, we can transmit "delta information". The card A will be the starting point, then by "adding" delta to card A , the magician can "guess" the fifth card.
Sort the three remaining cards, according to the above order, and note them C1 , ...
At this point, the bot have two things to say: the

bot magician
Input Five strings and an integer Four strings and an integer
Output A list/tuple of four strings A string

```bot('A ♥', '3 ♦', 'K ♠', 'Q ♣', 'J ♦', n=1) == ['J ♦', 'A ♥', 'Q ♣', 'K ♠']
magician('J ♦', 'A ♥', 'Q ♣', 'K ♠', n=1) == '3 ♦'
```

How it is used: To amaze and impress people with your magic skills.

You should be an authorized user in order to see the full description and start solving this mission.
49
Settings
Code:
Other:
Invalid hot key. Each hot key should be unique and valid
Hot keys:
•  to Run Code: to Check Solution: to Stop:
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`

`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.