推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
tanteng
V2EX  ›  Python

求一段 python 代码,求一副牌中所有“牛牛”的组合

  •  
  •   tanteng ·
    tanteng · May 6, 2015 · 4045 views
    This topic created in 4065 days ago, the information mentioned may be changed or developed.
    有一种扑克牌游戏叫“牛牛”,什么叫牛牛呢?就是除去大小王,发五张牌,J、Q、K都是10,如果有三张牌数字之和是10的倍数,另外两张牌相加尾数多少就是牛几,如果也是整数,就是牛牛。

    举例说明:
    37JQK (牛牛,牛牛也是最大的牌,不看花色)
    8237J (牛牛)
    12345 (啥都没有,拼不出来)
    82J85 (牛3,前三张牌加起来是10的整数,8+5=13,所以是牛3)
    82358 (牛6,2+3+5=10,是10的倍数,然后8+8=16,所以是牛6)

    怎么用python求出所有牛牛的组合呢?感兴趣的话写个脚本。谢谢,学习python中,联想到过年跟同学玩的扑克游戏。
    Supplement 1  ·  May 7, 2015
    要判断五张牌是否为牛牛很简单,只需把五张牌相加为10的整数就ok了,但问题是13张牌随机取出5个的可能性太多了,不可能遍历一遍判断,这样太慢了。。
    Supplement 2  ·  May 7, 2015
    Supplement 3  ·  May 7, 2015
    牛牛的规则是50张牌随机选5张出来,其中三张牌相加是10的倍数,剩下的两张加起来也是10的倍数,就是牛牛

    以上定义可能有误,以这为准。
    WKPlus
        2
    WKPlus  
       May 7, 2015
    五张牌相加是10的整数倍也不一定是牛牛啊,比如:1234J
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3791 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 05:06 · PVG 13:06 · LAX 22:06 · JFK 01:06
    ♥ Do have faith in what you're doing.