Files
poker_task1/README.md
2025-09-23 17:57:38 +08:00

64 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Poker Task1
实现从7张牌中找出最佳的5张牌组合并返回handranking。
## 支持的手牌类型
1. **皇家同花顺** (Royal Flush) - A♠K♠Q♠J♠T♠
2. **同花顺** (Straight Flush) - 连续的五张同花色牌
3. **四条** (Four of a Kind) - 四张相同点数的牌
4. **满堂红** (Full House) - 三条加一对
5. **同花** (Flush) - 五张同花色的牌
6. **顺子** (Straight) - 五张连续点数的牌包括A-2-3-4-5轮子
7. **三条** (Three of a Kind) - 三张相同点数的牌
8. **两对** (Two Pair) - 两个对子
9. **一对** (One Pair) - 一个对子
10. **高牌** (High Card) - 没有组合的单张高牌
### 环境要求
- Python 3.13+
- uv 包管理器
### 运行程序
```bash
# 基本用法
python main.py "AsKs AhAdAc6s7s"
# 输出: Quad(A)
# 其他示例
python main.py "AhKhQhJhTh2c3c"
# 输出: Royal Flush
python main.py "2h3h4h5h6h7s8s"
# 输出: Straight Flush(6 high)
python main.py "JsJhJdQcQs2h3d"
# 输出: Full House(J over Q)
```
### 输入格式
输入字符串应包含恰好7张牌每张牌用2个字符表示
- 第一个字符是点数:`2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `T`, `J`, `Q`, `K`, `A`
- 第二个字符是花色:`s`(黑桃), `h`(红桃), `d`(方块), `c`(梅花)
### 运行测试
```bash
# 运行自定义测试套件
python run_tests.py
# 如果安装了pytest也可以运行
pytest tests/ -v
```
## 技术栈
- **语言**Python 3.13
- **包管理**uv
- **测试**自定义测试框架也支持pytest
- **开发环境**VS Code