Feat: add new Markdown parser (#39800)
and change all the challenges to new `md` format.
This commit is contained in:
committed by
GitHub
parent
a07f84c8ec
commit
0bd52f8bd1
@@ -1,12 +1,11 @@
|
||||
---
|
||||
id: 5900f3a21000cf542c50feb5
|
||||
challengeType: 5
|
||||
title: 'Problem 54: Poker hands'
|
||||
challengeType: 5
|
||||
forumTopicId: 302165
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
# --description--
|
||||
|
||||
In the card game poker, a hand consists of five cards and are ranked, from lowest to highest, in the following way:
|
||||
|
||||
@@ -23,76 +22,47 @@ In the card game poker, a hand consists of five cards and are ranked, from lowes
|
||||
<li>Royal Flush: Ten, Jack, Queen, King, Ace, in same suit.</li>
|
||||
</ul>
|
||||
|
||||
The cards are valued in the order:
|
||||
2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, Ace.
|
||||
The cards are valued in the order: 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, Ace.
|
||||
|
||||
If two players have the same ranked hands then the rank made up of the highest value wins; for example, a pair of eights beats a pair of fives (see example 1 below). But if two ranks tie, for example, both players have a pair of queens, then highest cards in each hand are compared (see example 4 below); if the highest cards tie then the next highest cards are compared, and so on.
|
||||
|
||||
Consider the following five hands dealt to two players:
|
||||
|
||||
|Hand|Player 1|Player 2|Winner|
|
||||
|--- |--- |--- |--- |
|
||||
|<strong>1</strong>|5H 5C 6S 7S KD <br> Pair of Fives|2C 3S 8S 8D TD <br> Pair of Eights|Player 2|
|
||||
|<strong>2</strong>|5D 8C 9S JS AC <br> Highest card Ace|2C 5C 7D 8S QH <br> Highest card Queen|Player 1|
|
||||
|<strong>3</strong>|2D 9C AS AH AC <br> Three Aces|3D 6D 7D TD QD <br> Flush with Diamonds|Player 2|
|
||||
|<strong>4</strong>|4D 6S 9H QH QC <br> Pair of Queens <br> Highest card Nine|3D 6D 7H QD QS <br> Pair of Queens <br> Highest card Seven|Player 1|
|
||||
|<strong>5</strong>|2H 2D 4C 4D 4S <br> Full House <br> with Three Fours|3C 3D 3S 9S 9D <br> Full House <br> with Three Threes|Player 1|
|
||||
| Hand | Player 1 | Player 2 | Winner |
|
||||
| ------------------ | --------------------------------------------------------- | ---------------------------------------------------------- | -------- |
|
||||
| <strong>1</strong> | 5H 5C 6S 7S KD <br> Pair of Fives | 2C 3S 8S 8D TD <br> Pair of Eights | Player 2 |
|
||||
| <strong>2</strong> | 5D 8C 9S JS AC <br> Highest card Ace | 2C 5C 7D 8S QH <br> Highest card Queen | Player 1 |
|
||||
| <strong>3</strong> | 2D 9C AS AH AC <br> Three Aces | 3D 6D 7D TD QD <br> Flush with Diamonds | Player 2 |
|
||||
| <strong>4</strong> | 4D 6S 9H QH QC <br> Pair of Queens <br> Highest card Nine | 3D 6D 7H QD QS <br> Pair of Queens <br> Highest card Seven | Player 1 |
|
||||
| <strong>5</strong> | 2H 2D 4C 4D 4S <br> Full House <br> with Three Fours | 3C 3D 3S 9S 9D <br> Full House <br> with Three Threes | Player 1 |
|
||||
|
||||
The global array (`handsArr`) passed to the function, contains one-thousand random hands dealt to two players. Each line of the file contains ten cards (separated by a single space): the first five are Player 1's cards and the last five are Player 2's cards. You can assume that all hands are valid (no invalid characters or repeated cards), each player's hand is in no specific order, and in each hand there is a clear winner.
|
||||
|
||||
How many hands does Player 1 win?
|
||||
|
||||
</section>
|
||||
# --hints--
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>pokerHands(testArr)</code> should return a number.
|
||||
testString: assert(typeof pokerHands(testArr) === 'number');
|
||||
- text: <code>pokerHands(testArr)</code> should return 2.
|
||||
testString: assert.strictEqual(pokerHands(testArr), 2);
|
||||
- text: <code>pokerHands(handsArr)</code> should return 376.
|
||||
testString: assert.strictEqual(pokerHands(handsArr), 376);
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
`pokerHands(testArr)` should return a number.
|
||||
|
||||
```js
|
||||
function pokerHands(arr) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const testArr = [
|
||||
'8C TS KC 9H 4S 7D 2S 5D 3S AC',
|
||||
'5C AD 5D AC 9C 7C 5H 8D TD KS',
|
||||
'3H 7H 6S KC JS QH TD JC 2D 8S',
|
||||
'TH 8H 5C QS TC 9H 4D JC KS JS',
|
||||
'7C 5H KC QH JD AS KH 4C AD 4S'
|
||||
];
|
||||
|
||||
pokerHands(testArr);
|
||||
assert(typeof pokerHands(testArr) === 'number');
|
||||
```
|
||||
|
||||
</div>
|
||||
`pokerHands(testArr)` should return 2.
|
||||
|
||||
```js
|
||||
assert.strictEqual(pokerHands(testArr), 2);
|
||||
```
|
||||
|
||||
`pokerHands(handsArr)` should return 376.
|
||||
|
||||
### Before Test
|
||||
<div id='js-setup'>
|
||||
```js
|
||||
assert.strictEqual(pokerHands(handsArr), 376);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --before-user-code--
|
||||
|
||||
```js
|
||||
const handsArr = [
|
||||
@@ -1099,18 +1069,27 @@ const handsArr = [
|
||||
];
|
||||
```
|
||||
|
||||
</div>
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
function pokerHands(arr) {
|
||||
|
||||
</section>
|
||||
return true;
|
||||
}
|
||||
|
||||
const testArr = [
|
||||
'8C TS KC 9H 4S 7D 2S 5D 3S AC',
|
||||
'5C AD 5D AC 9C 7C 5H 8D TD KS',
|
||||
'3H 7H 6S KC JS QH TD JC 2D 8S',
|
||||
'TH 8H 5C QS TC 9H 4D JC KS JS',
|
||||
'7C 5H KC QH JD AS KH 4C AD 4S'
|
||||
];
|
||||
|
||||
pokerHands(testArr);
|
||||
```
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
|
||||
</section>
|
||||
|
Reference in New Issue
Block a user