30
2
Introduction
Long ago, when I used to code card games with usual playing cards, I used to specify a number for each card and call a function with some number to get a card. This somewhat inspired me to make this challenge.
So for the people unaware of the playing cards, a deck of cards consist of 52 cards (13 in each of the four suits, i.e, Hearts, Diamonds, Spades, Clubs). In each suit, there are 13 cards - firstly the cards numbered from 2-10, then the Jack(J), Queen(Q), King(K) and the Ace(A). This is the order
Challenge
The challenge is to take an integer between 1-52 as input and display the card at that position. But, your output must be in words. Also, order must be maintained, i.e, first 13 cards will be of Hearts, then Diamonds, then Spades and finally Clubs.
For example, if someone chooses the number 30
.The card would then belong to the third suit, i.e, the Spades. Also, it would be the fourth card in the suit, which means the number 5. Hence your output in words must be: five of spades
and it should always follow this format, i.e, first the card, followed by an of
and the name of the suit at the end, with required spaces in between.
Input And Output
The input will be an integer between 1-52 (both inclusive). Note that here counting starts from 1. You may choose to start from 0. However, you must maintain the order of the cards which is mentioned above. Your output should be the card at that position written in words. You do not need to handle invalid inputs. Also, your output may be in lower-case or in upper-case.
Given below is the list of all the possible inputs and their outputs:
1 -> two of hearts
2 -> three of hearts
3 -> four of hearts
4 -> five of hearts
5 -> six of hearts
6 -> seven of hearts
7 -> eight of hearts
8 -> nine of hearts
9 -> ten of hearts
10 -> jack of hearts
11 -> queen of hearts
12 -> king of hearts
13 -> ace of hearts
14 -> two of diamonds
15 -> three of diamonds
16 -> four of diamonds
17 -> five of diamonds
18 -> six of diamonds
19 -> seven of diamonds
20 -> eight of diamonds
21 -> nine of diamonds
22 -> ten of diamonds
23 -> jack of diamonds
24 -> queen of diamonds
25 -> king of diamonds
26 -> ace of diamonds
27 -> two of spades
28 -> three of spades
29 -> four of spades
30 -> five of spades
31 -> six of spades
32 -> seven of spades
33 -> eight of spades
34 -> nine of spades
35 -> ten of spades
36 -> jack of spades
37 -> queen of spades
38 -> king of spades
39 -> ace of spades
40 -> two of clubs
41 -> three of clubs
42 -> four of clubs
43 -> five of clubs
44 -> six of clubs
45 -> seven of clubs
46 -> eight of clubs
47 -> nine of clubs
48 -> ten of clubs
49 -> jack of clubs
50 -> queen of clubs
51 -> king of clubs
52 -> ace of clubs
Scoring
This is code-golf, so the shortest code wins.
1Isn't the default order of suits usually hearts, spaces, diamonds, clubs (red, black, red, black). Not that it matters for the challenge, was just wondering why it's in this order. – Kevin Cruijssen – 2018-03-14T07:53:06.757
3It varies from game to game. Different games follow different orders. Also talking about cards, some games even have ace as the lowest card in the suit. – Manish Kundu – 2018-03-14T07:58:31.450
Can I output
two\s\s\sof\shearts
where\s
stands for a space? (Note the two extra space.) – totallyhuman – 2018-03-14T10:03:44.7472@totallyhuman sorry but there must be exactly 1 space in between – Manish Kundu – 2018-03-14T10:19:24.800