Logic of game called 5 CARDS for programming

In case you have not gone through the initial resume writing and programming scenarios, please visit below URL and then you would be good to continue up with this page. 

Interview preparation for IT jobs: Fresher interview preparation for IT jobs

Many people may not aware what exactly this "5 CARDS" game. It would be quite simple card game. 

Prerequisite:

You would need atleast one bundle of cards which inclusive of 13 Hearts, 13 Diamonds, 13 Clubs, 13 Spades and 2 Jokers.

Values for each card:

Joker = 0 points

A = 1 points

Jack = 11 points

Queen = 12 points

King = 13 points

Remaining each number will carry its respective points (example: card 10 Heart holds 10 points, card 3 Spade holds 3 points)

Game protocols:

This game can be played between minimum of 2 players with atleast one bundle of cards. 

Lets consider couple of players for example. Cards can be well shuffled and distributed in manner each player hold 5 cards, and remaining cards should be centralized in closed position without revealing next iteration cards.

Recommending each player to sort their cards in ascending order based on points classified under "Values for each card".

The goal is to reduce the points in your set of cards and declare or showcase in case your total number of points are less than or equal to 10. In case opponent holds equal or lesser number points than the showcased points, then opponent will be considered as winner, or else you would be considered as winner. In general, your showcased points should not be equal to opponent points whereas this rule is not applicable in case your showcased points is 0 (note: Joker holds 0 points). In case you declared with 0 points, then you would be considered to be winner. And only default 2 jokers would be considered in the game, and no external or duplicate jokers applicable like Rummy game (example: predefining random number as Joker before start of the game).

Showcase or declaration can be done only when your turn comes in and need to do so before drawing card from centralized bundle.

Rules during iterations:

You would need to disclose your card first before heading to draw a card from bundle. Example, in case if I hold values as 2 Spade, 3 Heart, 5 Heart, 7 Club, King Spade (total 5 cards on initial iteration), I would drop King Spade first and draw card from enclosed centralized bundle.

Lets consider I have drawn 7 Diamond in my first iteration. Now I hold cards as 2 Spade, 3 Heart, 5 Heart, 7 Club, 7 Diamond. Here, I am eligible to drop 2 cards which are having same number and pick up only one card. In such a way my card will be getting reduced from 5 cards to 4 cards and my points will also go down. In above mentioned case I can disclose or drop 7 Club and 7 Diamond together and draw only one card from bundle. If my new card is 10 Club, I will hold 2 Spade, 3 Heart, 5 Heart, 10 Club alone which means only 4 cards. 


In case you have any number of same value cards, you can drop all at once and pick up only one card from bundle. Example, In case I hold 2 Spade, King Heart, King Spade, King Diamond, King Club, I can drop all 4 Kings once and pick only one card instead which will reduce my number of cards from 5 to 2.

You can also withdraw card from opponent disclosure instead of picking up from centralized bundle. But in case your opponent dropped more than one number of cards you need to pick them all. 

example: You hold cards as 2 Spade, 3 Heart, 10 Spade, King Heart, King Club and your opponent dropped or disclosed 2 cards which are King Diamond and King Spade, I would suggest you may drop your next high points card which is 10 Spade and pick up both the cards dropped by opponent. In the mean, you will be holding 6 cards now which are 2 Spade, 3 Heart, King Heart, King Club, King Diamond and King Spade. In next iteration, you may drop all 4 Kings and pick up only one card. But, you can do so only if you sure that your opponent cannot declare in very next iteration itself.

Personally, I will play till I get one card as Joker which would be exciting with some risk involved. And this way will not allow my opponent for confident showcase or declaration when I am holding only one card in my iteration. 

Finally, your end goal is to write the sample program for this logic. In the end, recruiters will be testing only your ability and logical thinking, they will not expect anything 100% perfect like why no UI or why only command line or privacy about card game. They will only expect your tendency to reach the goal. I prefer you to have some sample physical card game and gain tactical experience before heading for coding.

Enjoy your way of scripting !! all the very best !!

No comments: