V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
coolicer
V2EX  ›  Python

参加了Coursera的Python课程,Mini-project1的问题。

  •  
  •   coolicer · 2013-04-24 11:46:46 +08:00 · 3312 次点击
    这是一个创建于 4027 天前的主题,其中的信息可能已经有所发展或是发生改变。
    0 — rock
    1 — Spock
    2 — paper
    3 — lizard
    4 — scissors


    剪子剪布;
    布包石头;
    石头砸蜥蜴;
    蜥蜴毒死史巴克;
    史巴克踩碎剪子;
    剪子斩首蜥蜴;
    蜥蜴吃掉布;
    布(纸,英语中与论文同词)证明史巴克不存在;
    史巴克融化石头;
    石头敲坏剪子。

    程序:
    电脑产生一个(0-4)随机数,
    函数接受一个参数,eg:"paper",这个参数也转化成一个数字,
    2个数怎么判断输赢
    #项目的提示是:
    # compute difference of player_number and comp_number modulo five
    这句话看不懂,问了一些有程序基础的人也不知道。

    我的项目代码:http://www.codeskulptor.org/#user10_eVfpXcdah4_1.py
    5 条回复    1970-01-01 08:00:00 +08:00
    skywalker
        1
    skywalker  
       2013-04-24 11:52:39 +08:00
    player_number和comp_number的差值对5取模啊
    coolicer
        2
    coolicer  
    OP
       2013-04-24 11:53:52 +08:00
    @skywalker 我想问为什么要这样写
    chyiz
        3
    chyiz  
       2013-04-24 12:08:23 +08:00
    @coolicer 这个游戏的规则就是把5个数连成圈,每个数都赢它前两个,输给它后两个啊,所以就用取模咯。
    ctrlaltdeletel
        4
    ctrlaltdeletel  
       2013-04-24 12:14:38 +08:00
    每个东西都是克制前面两个、被后面两个克制啊
    做差+5取模,判断是1、2, 还是3、4 就能判断输赢了吧 要是0就是同一个东西吧
    coolicer
        5
    coolicer  
    OP
       2013-04-24 12:22:18 +08:00
    我懂了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2218 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 09:45 · PVG 17:45 · LAX 02:45 · JFK 05:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.