Development Challenge
Development Challenge
Introduction
You are building a card game for 2 players. Use any of programming language you feel comfortable with.
Please include the source code as well as instructions on how to compile and run the game in your
submission. The rules of the game are listed below and split into tasks. For each tasks, please implement
the indicated unit-tests. If you are struggling to complete the challenge, it is okay to submit a solution that
does not solve all tasks. The order of tasks is just a suggestion, feel free to implement in whatever order you
see fit. Please do not spend more than 4 hours on this challenge.
Task 1: Create a shuffled deck of cards
Each card shows a number from 1 to 10. Each number is in the deck four times for a total of 40 cards. At the
beginning of the game, the deck is shuffled (Hint: Look up Fisher-Yates Shuffle Algorithm) to
make sure it is in a random order. Each player receives a stack of 20 cards from the shuffled deck as their
draw pile. The draw pile is kept face-down in front of the player. Each player also keeps a discard pile (see
"Task 3" for more). Tests:
. A new deck should contain 40 cards
. A shuffle function should shuffle a deck
Hint: Consider mocking Math.random() or the equivalent of your chosen language
Task 2: Draw cards
Each turn, both players draw the top card. If there are no more cards in the draw pile, shuffle the discard
pile and use those cards as the new draw pile. Once a player has no cards in either their draw or discard
pile, that player loses. Test: If a player with an empty draw pile tries to draw a card, the discard pile is
shuffled into the draw pile
Task 3: Playing a turn
The players present their drawn card and compare the values. The player with the higher value card, takes
both cards and adds them to their discard pile, next to the draw pile. If the cards show the same value, the
winner of the next turn wins these cards as well Hint: The game will likely result in a stalemate, if this rule is
not implemented. Tests:
. When comparing two cards, the higher card should win
. When comparing two cards of the same value, the winner of the next round should win 4 cards
Task 4: Console Output
Your program should output the cards that are played each turn and who wins. At the end the program
should output the player that won.
Example output:
Player 1 (20 cards): 8
Player 2 (20 cards): 1
Player 1 wins this round
[...]