Skip to content

Commit 5585c9e

Browse files
authored
Merge branch 'main' into sync_hangman_tests
2 parents f207633 + ed16ba4 commit 5585c9e

32 files changed

Lines changed: 2225 additions & 34 deletions

concepts/nullability/about.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Whilst accessing a reference variable which has a value of `null` will compile f
2828
int[] arr = null;
2929

3030
// Throws NullPointerException at runtime
31-
arr.Length;
31+
arr.length;
3232
```
3333

3434
A [`NullPointerException` is thrown][null-pointer-exception] when trying to access a reference variable which is null but requires an object.

config.json

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
"if-else-statements",
9696
"switch-statement"
9797
],
98-
"status": "beta"
98+
"status": "active"
9999
},
100100
{
101101
"slug": "squeaky-clean",
@@ -233,7 +233,8 @@
233233
"strings",
234234
"switch-statement",
235235
"constructors"
236-
]
236+
],
237+
"status": "active"
237238
},
238239
{
239240
"slug": "tim-from-marketing",
@@ -245,7 +246,8 @@
245246
"prerequisites": [
246247
"if-else-statements",
247248
"strings"
248-
]
249+
],
250+
"status": "active"
249251
},
250252
{
251253
"slug": "captains-log",
@@ -258,7 +260,8 @@
258260
"arrays",
259261
"numbers",
260262
"strings"
261-
]
263+
],
264+
"status": "active"
262265
},
263266
{
264267
"slug": "booking-up-for-beauty",
@@ -270,7 +273,8 @@
270273
"prerequisites": [
271274
"numbers",
272275
"strings"
273-
]
276+
],
277+
"status": "active"
274278
},
275279
{
276280
"slug": "wizards-and-warriors-2",
@@ -295,7 +299,8 @@
295299
],
296300
"prerequisites": [
297301
"numbers"
298-
]
302+
],
303+
"status": "active"
299304
},
300305
{
301306
"slug": "gotta-snatch-em-all",
@@ -308,7 +313,7 @@
308313
"lists",
309314
"generic-types"
310315
],
311-
"status": "beta"
316+
"status": "active"
312317
},
313318
{
314319
"slug": "international-calling-connoisseur",
@@ -321,7 +326,8 @@
321326
"classes",
322327
"foreach-loops",
323328
"generic-types"
324-
]
329+
],
330+
"status": "active"
325331
}
326332
],
327333
"practice": [
@@ -799,6 +805,16 @@
799805
],
800806
"difficulty": 4
801807
},
808+
{
809+
"slug": "prism",
810+
"name": "Prism",
811+
"uuid": "1fca8759-0236-493c-a4ef-2807cb33fd2b",
812+
"practices": [],
813+
"prerequisites": [
814+
"lists"
815+
],
816+
"difficulty": 4
817+
},
802818
{
803819
"slug": "proverb",
804820
"name": "Proverb",
@@ -981,7 +997,7 @@
981997
"practices": [],
982998
"prerequisites": [
983999
"arrays",
984-
"if-statements"
1000+
"if-else-statements"
9851001
],
9861002
"difficulty": 5
9871003
},
@@ -1275,6 +1291,19 @@
12751291
],
12761292
"difficulty": 6
12771293
},
1294+
{
1295+
"slug": "camicia",
1296+
"name": "Camicia",
1297+
"uuid": "b4f7c3b0-6d3c-45e2-a328-05e09c7467f4",
1298+
"practices": [],
1299+
"prerequisites": [
1300+
"strings",
1301+
"for-loops",
1302+
"arrays",
1303+
"if-else-statements"
1304+
],
1305+
"difficulty": 6
1306+
},
12781307
{
12791308
"slug": "etl",
12801309
"name": "ETL",

docs/RESOURCES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
- [Stack Overflow](http://stackoverflow.com/questions/tagged/java).
44
- [The Java subreddit](https://www.reddit.com/r/java)
5-
- [Official Java documentation](https://docs.oracle.com/en/java/javase/11/docs/api/index.html)
5+
- [Official Java documentation](https://docs.oracle.com/en/java/javase/25/docs/api/index.html)
66
- [Java Programming Books](https://github.com/EbookFoundation/free-programming-books/blob/main/books/free-programming-books-langs.md#java)
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Instructions
2+
3+
In this exercise, you will simulate a game very similar to the classic card game **Camicia**.
4+
Your program will receive the initial configuration of two players' decks and must simulate the game until it ends (or detect that it will never end).
5+
6+
## Rules
7+
8+
- The deck is split between **two players**.
9+
The player's cards are read from left to right, where the leftmost card is the top of the deck.
10+
- A round consists of both players playing at least one card.
11+
- Players take turns placing the **top card** of their deck onto a central pile.
12+
- If the card is a **number card** (2-10), play simply passes to the other player.
13+
- If the card is a **payment card**, a penalty must be paid:
14+
- **J** → opponent must pay 1 card
15+
- **Q** → opponent must pay 2 cards
16+
- **K** → opponent must pay 3 cards
17+
- **A** → opponent must pay 4 cards
18+
- If the player paying a penalty reveals another payment card, that player stops paying the penalty.
19+
The other player must then pay a penalty based on the new payment card.
20+
- If the penalty is fully paid without interruption, the player who placed the **last payment card** collects the central pile and places it at the bottom of their deck.
21+
That player then starts the next round.
22+
- If a player runs out of cards and is unable to play a card (either while paying a penalty or when it is their turn), the other player collects the central pile.
23+
- The moment when a player collects cards from the central pile is called a **trick**.
24+
- If a player has all the cards in their possession after a trick, the game **ends**.
25+
- The game **enters a loop** as soon as the decks are identical to what they were earlier during the game, **not** counting number cards!
26+
27+
## Examples
28+
29+
A small example of a match that ends.
30+
31+
| Round | Player A | Player B | Pile | Penalty Due |
32+
| :---- | :----------- | :------------------------- | :------------------------- | :---------- |
33+
| 1 | 2 A 7 8 Q 10 | 3 4 5 6 K 9 J | | - |
34+
| 1 | A 7 8 Q 10 | 3 4 5 6 K 9 J | 2 | - |
35+
| 1 | A 7 8 Q 10 | 4 5 6 K 9 J | 2 3 | - |
36+
| 1 | 7 8 Q 10 | 4 5 6 K 9 J | 2 3 A | Player B: 4 |
37+
| 1 | 7 8 Q 10 | 5 6 K 9 J | 2 3 A 4 | Player B: 3 |
38+
| 1 | 7 8 Q 10 | 6 K 9 J | 2 3 A 4 5 | Player B: 2 |
39+
| 1 | 7 8 Q 10 | K 9 J | 2 3 A 4 5 6 | Player B: 1 |
40+
| 1 | 7 8 Q 10 | 9 J | 2 3 A 4 5 6 K | Player A: 3 |
41+
| 1 | 8 Q 10 | 9 J | 2 3 A 4 5 6 K 7 | Player A: 2 |
42+
| 1 | Q 10 | 9 J | 2 3 A 4 5 6 K 7 8 | Player A: 1 |
43+
| 1 | 10 | 9 J | 2 3 A 4 5 6 K 7 8 Q | Player B: 2 |
44+
| 1 | 10 | J | 2 3 A 4 5 6 K 7 8 Q 9 | Player B: 1 |
45+
| 1 | 10 | - | 2 3 A 4 5 6 K 7 8 Q 9 J | Player A: 1 |
46+
| 1 | - | - | 2 3 A 4 5 6 K 7 8 Q 9 J 10 | - |
47+
| 2 | - | 2 3 A 4 5 6 K 7 8 Q 9 J 10 | - | - |
48+
49+
status: `"finished"`, cards: 13, tricks: 1
50+
51+
This is a small example of a match that loops.
52+
53+
| Round | Player A | Player B | Pile | Penalty Due |
54+
| :---- | :------- | :------- | :---- | :---------- |
55+
| 1 | J 2 3 | 4 J 5 | - | - |
56+
| 1 | 2 3 | 4 J 5 | J | Player B: 1 |
57+
| 1 | 2 3 | J 5 | J 4 | - |
58+
| 2 | 2 3 J 4 | J 5 | - | - |
59+
| 2 | 3 J 4 | J 5 | 2 | - |
60+
| 2 | 3 J 4 | 5 | 2 J | Player A: 1 |
61+
| 2 | J 4 | 5 | 2 J 3 | - |
62+
| 3 | J 4 | 5 2 J 3 | - | - |
63+
| 3 | J 4 | 2 J 3 | 5 | - |
64+
| 3 | 4 | 2 J 3 | 5 J | Player B: 1 |
65+
| 3 | 4 | J 3 | 5 J 2 | - |
66+
| 4 | 4 5 J 2 | J 3 | - | - |
67+
68+
The start of round 4 matches the start of round 2.
69+
Recall, the value of the number cards does not matter.
70+
71+
status: `"loop"`, cards: 8, tricks: 3
72+
73+
## Your Task
74+
75+
- Using the input, simulate the game following the rules above.
76+
- Determine the following information regarding the game:
77+
- **Status**: `"finished"` or `"loop"`
78+
- **Cards**: total number of cards played throughout the game
79+
- **Tricks**: number of times the central pile was collected
80+
81+
~~~~exercism/advanced
82+
For those who want to take on a more exciting challenge, the hunt for other records for the longest game with an end is still open.
83+
There are 653,534,134,886,878,245,000 (approximately 654 quintillion) possibilities, and we haven't calculated them all yet!
84+
~~~~
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Introduction
2+
3+
One rainy afternoon, you sit at the kitchen table playing cards with your grandmother.
4+
The game is her take on [Camicia][bmn].
5+
6+
At first it feels like just another friendly match: cards slapped down, laughter across the table, the occasional victorious grin from Nonna.
7+
But as the game stretches on, something strange happens.
8+
The same cards keep cycling back.
9+
You play card after card, yet the end never seems to come.
10+
11+
You start to wonder.
12+
_Will this game ever finish?
13+
Or could we keep playing forever?_
14+
15+
Later, driven by curiosity, you search online and to your surprise you discover that what happened wasn't just bad luck.
16+
You and your grandmother may have stumbled upon one of the longest possible sequences!
17+
Suddenly, you're hooked.
18+
What began as a casual game has turned into a quest: _how long can such a game really last?_
19+
_Can you find a sequence even longer than the one you played at the kitchen table?_
20+
_Perhaps even long enough to set a new world record?_
21+
22+
And so, armed with nothing but a deck of cards and some algorithmic ingenuity, you decide to investigate...
23+
24+
[bmn]: https://en.wikipedia.org/wiki/Beggar-my-neighbour
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"authors": [
3+
"thibault2705"
4+
],
5+
"files": {
6+
"solution": [
7+
"src/main/java/Camicia.java",
8+
"src/main/java/CamiciaResult.java"
9+
],
10+
"test": [
11+
"src/test/java/CamiciaTest.java"
12+
],
13+
"example": [
14+
".meta/src/reference/java/Camicia.java",
15+
".meta/src/reference/java/CamiciaResult.java"
16+
],
17+
"invalidator": [
18+
"build.gradle"
19+
]
20+
},
21+
"blurb": "Simulate the card game and determine whether the match ends or enters an infinite loop.",
22+
"source": "Beggar-My-Neighbour",
23+
"source_url": "https://www.richardpmann.com/beggar-my-neighbour-records.html"
24+
}

0 commit comments

Comments
 (0)