Overview
Penney's game, named after its inventor Walter Penney, is a binary (head/tail) sequence generating game between two or more players. Player A selects a sequence of heads and tails (of length 3 or larger), and shows this sequence to player B. Player B then selects another sequence of heads and tails of the same length. Subsequently, a fair coin is tossed until either player A's or player B's sequence appears as a consecutive subsequence of the coin toss outcomes. The player whose sequence appears first wins. Here we have a clone of this game that I wrote during coronavirus quarantine days.
ℹ️ In playing with the computer, the computer selects its sequence randomly
ℹ️ For details about how the winning probability is calculated, you can visit Penney’s game between many players paper
| PyPI Counter | |
| GitHub Stars |
| Branch | master | dev |
| CI |
| Code Quality |
Installation
Source Code
- Download and install Python3.x (>=3.7)
- Select
Add to PATHoption - Select
Install pipoption
- Select
- Download Version 0.5 or Latest Source
- Run
pip install .
PyPI
- Check Python Packaging User Guide
- Run
pip install penney==0.5
Exe Version (Windows)
- Download Exe-Version 0.5
- Run
Penney-0.5.exe
How to Play
ℹ️ You can use penney, python -m penney or Penney.exe to run this program
Screen Record
Try Penney in Your Browser!
You can play Penney's game online in interactive Jupyter Notebooks via the Binder or Colab services! Try it out now!:
- Open
Notebook.ipynb
Contribution
Changes and improvements are more than welcome! ❤️ Feel free to fork and open a pull request.
Please consider the following :
- Fork it!
- Create your feature branch (under
devbranch) - Add your functions/methods to proper files
- Add standard
docstringto your functions/methods - Add tests for your functions/methods (test cases in
testfolder) - Pass all CI tests
- Update
CHANGELOG.md- Describe changes under
[Unreleased]section
- Describe changes under
- Submit a pull request into
dev(please complete the pull request template)
Issues & Bug Reports
Just open an issue and describe it. I'll check it ASAP! or send an email to me@sepand.tech.
- Please complete the issue template
References
1- Penney, Walter. "Problem 95: penney-ante." Journal of Recreational Mathematics 7 (1974): 321.
2- Zajkowski, Krzysztof. "Penney's game between many players." arXiv preprint arXiv:1212.3973 (2012).
3- Guy, R. K., and John Horton Conway. Winning Ways for your Mathematical Plays. Academic Press, London, 1982.
4- Humble, Steve, and Yutaka Nishiyama. "Humble-Nishiyama Randomness Game-A New Variation on Penney's Coin Game." (2010).
Show Your Support
Star This Repo
Give a ⭐️ if this project helped you!
Donate to Our Project
Bitcoin
1KtNLEEeUbTEK9PdN6Ya3ZAKXaqoKUuxCyEthereum
0xcD4Db18B6664A9662123D4307B074aE968535388Litecoin
Ldnz5gMcEeV8BAdsyf8FstWDC6uyYR6pgZDoge
DDUnKpFQbBqLpFVZ9DfuVysBdr249HxVDhTron
TCZxzPZLcJHr2qR3uPUB1tXB6L3FDSSAx7Ripple
rN7ZuRG7HDGHR5nof8nu5LrsbmSB61V1qqBinance Coin
bnb1zglwcf0ac3d0s2f6ck5kgwvcru4tlctt4p5qefTether
0xcD4Db18B6664A9662123D4307B074aE968535388Dash
Xd3Yn2qZJ7VE8nbKw2fS98aLxR5M6WUU3sStellar
GALPOLPISRHIYHLQER2TLJRGUSZH52RYDK6C3HIU4PSMNAV65Q36EGNL
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
Unreleased
0.5 - 2025-09-26
Added
SECURITY.md
Changed
- Logo updated
- Python typing features added to all modules
detfunction renamed tocalculate_determinantlinefunction renamed toprint_linedescriptionfunction renamed toprint_descriptionleft_justifyfunction renamed tojustify_leftjustifyfunction renamed tojustify_textseq_generatorfunction renamed togenerate_sequenceC_calcfunction renamed tocalculate_Cprob_calcfunction renamed tocalculate_probabilityprint_probfunction renamed toprint_probabilitygamefunction renamed torun_gamecheck_seqfunction renamed tovalidate_sequenceget_seqfunction renamed toget_sequencesget_lenfunction renamed toget_lengthcheck_namefunction renamed tovalidate_nameprint_seqfunction renamed toprint_sequencecomputer_seq_genfunction renamed togenerate_computer_sequenceplayer_filterfunction renamed tofilter_playersmenufunction renamed tomenu_handlerprint_probabilityfunction bug fixedget_namesfunction bug fixed- Test system modified
- Build script updated
- CLI mode updated
Notebook.ipynbupdatedcodecovremoved fromdev-requirements.txtPython 3.5support droppedPython 3.6support droppedPython 3.10added totest.ymlPython 3.11added totest.ymlPython 3.12added totest.ymlPython 3.13added totest.ymlREADME.mdmodified- String templates modified
0.4 - 2021-05-19
Added
requirements-splitter.pyprint_seqfunction
Changed
- Test system modified
gamefunction modified- Menu optimized
0.3 - 2020-04-16
Changed
README.mdmodified- Minor issues fixed
print_resultfunction tie condition bug fixed
0.2 - 2020-04-08
Added
detfunctionprob_calcfunctionprint_probfunctionC_calcfunctionNotebook.ipynbfilebuild_unix.shfile- Github action
Changed
README.mdmodifiedversion_check.pyupdated
0.1 - 2020-03-21
Added
- Player mode
- Computer mode
- Exe version
- Test system
Release files for penney 0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| penney-0.5.tar.gz | 255.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| penney-0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 267.2 kB
Release files / penney-0.5.tar.gz
| Download URL | penney-0.5.tar.gz |
|---|---|
| Size | 255.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c7d5d9e702c3a9bd8ec5ed9c3b528fc00c06bc0f208e4ed4400d63eec89ec560
|
|
BLAKE2b-256 checksum How to use checksums |
bbc58ebb50ac891988e4ebc96f8d73f89f2dcbb00f976e4d8137e792f3ba5803
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / penney-0.5-py3-none-any.whl
| Download URL | penney-0.5-py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
66063fdbb3a54e6cebb12c45f58a48714e851b7139f417d9c32238709e406953
|
|
BLAKE2b-256 checksum How to use checksums |
1cce9c390a0a88e2d29a869f966605bda35e0de0a30c1838a62670cbbecf1f67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|