Who remembers the game “dead-and-injured”? I don’t remember what the real name is.
I have been playing the game with my colleague on paper and I decided to experiment it on IOS just to put everything I have been learning and reading into good use.
What in this life is dead-and-injured?
It is played between two players. Both players have their secret numbers. The secret numbers are picked by following these rules:
Therefore, 3456 is VALID. 3436 is INVALID because 3 is repeated.
Player A tries to decode the player B’s secret number by using the player’s responses to guess the next set of digits. The response is in the format described below:
|When digits of the guessed number exactly match the digits of the secret number i.e the same positions||Dead|
|When digits of the guessed number exist in the secret number but the positions don’t match||Injured|
For example, my secret number is 5678.
The following guesses will give the corresponding responses.
|1234||0 dead, 0 injured|
|4537||2 injured, 0 dead|
|5479||0 dead, 2 injured|
As simple as the game appears, it needs logic and reasoning to be able to crack the secret number in few steps.
You can find the demo of the IOS app in the video below. Source code can be made available on request.
Shout out to Adeyinka. He worked on the UI while we both worked on the logic.
PS: I forgot to demo the part where the validation of the numbers was done.