← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Design a standard 52-card playing-card deck. Each card is identified by a two- or three-character string {rank}{suit}:
2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, AC (clubs), D (diamonds), H (hearts), S (spades)
For example, the 3 of clubs is "3C" and the ace of spades is "AS".
Implement the Deck class:Deck() Initializes a fresh 52-card deck. Cards must start in canonical order: sorted first by rank (low to high), then by suit (alphabetical: C, D, H, S). The very first card in a fresh deck is "2C".void shuffle() Randomly permutes the remaining cards in place so that every permutation is equally likely.string draw() Removes and returns the card currently at the top of the deck. Returns "" (empty string) if the deck is empty.string[] order() Returns a snapshot of the remaining cards sorted canonically (by rank, then by suit). This does NOT mutate the internal draw order — subsequent draw() calls still honor the current shuffled order.int size() Returns the number of cards still remaining in the deck.
Because shuffle() is randomized, the auto-grader does not assert specific post-shuffle orderings. Instead, test cases exercise draw(), order(), and size() — order() is deterministic regardless of prior shuffles, so it can be used to verify that shuffle() does not add or lose any cards.A fresh deck has all 52 cards, and order() returns the canonical sorted snapshot.
Fresh deck starts in canonical order, so the first two draws return 2C then 2D. The remaining 50 cards appear in sorted order.
shuffle() permutes internal order but does not add/lose cards, so order() still produces the full 52-card canonical list.