You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exercises/camicia/instructions.md
+21-29Lines changed: 21 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,26 +5,19 @@ Your program will receive the initial configuration of two players’ decks and
5
5
6
6
## Rules
7
7
8
-
* The deck is split between **two players**.
8
+
- The deck is split between **two players**.
9
9
Each player's cards are represented as a string where the leftmost character is the top of the deck.
10
-
11
-
* Players take turns placing the **top card** of their deck onto a central pile.
12
-
13
-
* If the card is a **number card** (`-` in this scenario), play simply passes to the other player.
14
-
15
-
* If the card is a **payment card**, a price needs to be paid:
16
-
17
-
*`J` → opponent must pay 1 card
18
-
*`Q` → opponent must pay 2 cards
19
-
*`K` → opponent must pay 3 cards
20
-
*`A` → opponent must pay 4 cards
21
-
22
-
* If the player paying a penalty reveals another payment card, that player stops paying the penalty and the other player much then pay the penalty.
23
-
24
-
* If the penalty is fully paid without interruption, the player who laid the **last payment card** collects the central pile and places it at the bottom of their deck.
10
+
- Players take turns placing the **top card** of their deck onto a central pile.
11
+
- If the card is a **number card** (`-` in this scenario), play simply passes to the other player.
12
+
- If the card is a **payment card**, a price needs to be paid:
13
+
-`J` → opponent must pay 1 card
14
+
-`Q` → opponent must pay 2 cards
15
+
-`K` → opponent must pay 3 cards
16
+
-`A` → opponent must pay 4 cards
17
+
- If the player paying a penalty reveals another payment card, that player stops paying the penalty and the other player much then pay the penalty.
18
+
- If the penalty is fully paid without interruption, the player who laid the **last payment card** collects the central pile and places it at the bottom of their deck.
25
19
That player then starts the next round.
26
-
27
-
* The game ends when one player has no more cards.
20
+
- The game ends when one player has no more cards.
28
21
29
22
## Example
30
23
@@ -44,17 +37,16 @@ Here’s a simple example of input and output.
44
37
45
38
### Explanation
46
39
47
-
* Player A only has number cards, so can never defend against a payment card.
48
-
* Player B has a long sequence of payment cards: Aces, Kings, Queens, and Jacks.
49
-
* Each payment card forces a payment, which Player A cannot counter with a payment card of their own, so Player B repeatedly wins the pile (repeatedly completes a trick).
50
-
* In the end, player B captures their opponent's entire deck by playing 40 cards in just 4 "tricks" (turns in which a deck is collected).
40
+
- Player A only has number cards, so can never defend against a payment card.
41
+
- Player B has a long sequence of payment cards: Aces, Kings, Queens, and Jacks.
42
+
- Each payment card forces a payment, which Player A cannot counter with a payment card of their own, so Player B repeatedly wins the pile (repeatedly completes a trick).
43
+
- In the end, player B captures their opponent's entire deck by playing 40 cards in just 4 "tricks" (turns in which a deck is collected).
51
44
52
45
## Your Task
53
46
54
-
* Parse the two players' decks from the input.
55
-
* Simulate the game following the rules above.
56
-
* Determine is the final game status is `"finished"` or `"loop"`.
57
-
58
-
*`"status"`: `"finished"` or `"loop"`
59
-
*`"cards"`: total number of cards played throughout the game
60
-
*`"tricks"`: number of times the central pile was collected
47
+
- Parse the two players' decks from the input.
48
+
- Simulate the game following the rules above.
49
+
- Determine is the final game status is `"finished"` or `"loop"`.
50
+
-`"status"`: `"finished"` or `"loop"`
51
+
-`"cards"`: total number of cards played throughout the game
52
+
-`"tricks"`: number of times the central pile was collected
0 commit comments