Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ Personal solutions to [**Python** track][python_track] exercises from [**Exercis
3. ["**Ghost Gobble Arcade Game**" solution](python/ghost-gobble-arcade-game/arcade_game.py).
4. ["**Currency Exchange**" solution](python/currency-exchange/exchange.py).
5. ["**Meltdown Mitigation**" solution](python/meltdown-mitigation/conditionals.py).
6. ["**Black Jack**" solution](python/black-jack/black_jack.py).
<!-- Put next solution item here! -->

[python_version_badge]: https://img.shields.io/badge/Python%203.13-3776AB?logo=python&logoColor=FFD43B
[track_completion_badge]: https://img.shields.io/badge/Track%20completion-3.4%25-604fcd?logo=exercism&logoColor=604fcd&labelColor=e9ecef
[exercises_completed_badge]: https://img.shields.io/badge/Exercises%20completed-5%2F146-604fcd?logo=exercism&logoColor=604fcd&labelColor=e9ecef
[track_completion_badge]: https://img.shields.io/badge/Track%20completion-4.1%25-604fcd?logo=exercism&logoColor=604fcd&labelColor=e9ecef
[exercises_completed_badge]: https://img.shields.io/badge/Exercises%20completed-6%2F146-604fcd?logo=exercism&logoColor=604fcd&labelColor=e9ecef
[python_track]: https://exercism.org/tracks/python
[exercism]: https://exercism.org
45 changes: 45 additions & 0 deletions python/black-jack/HINTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Hints

[The Python comparisons tutorial][python comparisons tutorial] and [Python comparisons examples][python comparisons examples] are a great introduction covering the content of this exercise.

## 1. Calculate the value of a card

- You can use the equality comparison operator `==` to determine if a card is an ace card: `card == 'A'`.
- You can use the containment operator `in` to determine if a substring is contained inside a string: `'Q' in 'KJQ'`.
- You can use the [`int` constructor][int constructor] to convert a `str` of an `int` to an `int`: `int('13')`.

## 2. Determine which card has a higher value

- Once you have defined the `value_of_card` function, you can call it from other functions.
- You can use the value comparison operators `>` and `<` to determine if specific cards are _greater than_ or _less than_ a given value: `3 < 12`.
- You can use the equality comparison operator `==` to determine if two values are equal to one another.

## 3. Calculate the value of an ace

- Once you have defined the `value_of_card` function, you can call it from other functions.
- You can use the order comparison operator `>` to decide the appropriate course of action here.

## 4. Determine Blackjack

- Remember, you can use the [`if`/`elif`/`else` syntax][if syntax] to handle different combinations of cards.
- You can chain BOTH comparison operators and boolean operators _arbitrarily_: `y < z < x` or `(y or z) and (x or z)`
- You can reuse the already implemented `value_of_card` function.

## 5. Splitting pairs

- You can reuse the already implemented `value_of_card` function.
- You can handle the `A` case (when at least one of the cards in an ace) separately.

## 6. Doubling down

- An `A` scored at 11 will never allow doubling down if there are two cards in the hand.
- Given the first point, you _should_ be able to reuse the already implemented `value_of_card` function.
- You can chain comparison operators _arbitrarily_: `y < z < x`.
- You can use the [conditional expression][conditional expression] (_sometimes called a "ternary operator"_)
to shorten simple `if`/`else` statements: `13 if letter == 'M' else 3`.

[conditional expression]: https://docs.python.org/3/reference/expressions.html#conditional-expressions
[if syntax]: https://docs.python.org/3/tutorial/controlflow.html#if-statements
[int constructor]: https://docs.python.org/3/library/functions.html#int
[python comparisons examples]: https://www.tutorialspoint.com/python/comparison_operators_example.htm
[python comparisons tutorial]: https://docs.python.org/3/reference/expressions.html#comparisons
Loading
Loading