Skip to main content

Penney's game

Project description

Penney's Game

built with Python3 PyPI version


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 [Wikipedia].

Here we have a friendly clone of this game that I wrote during coronavirus quarantine days.

PyPI Counter
Github Stars
Branch master dev
Code Quality CodeFactor codebeat badge


Source Code

  • Download and install Python3.x (>=3.5)
    • <input type="checkbox" checked="" disabled="" /> Select Add to PATH option
      • <input type="checkbox" checked="" disabled="" /> Select Install pip option
  • Download Version 0.3 or Latest Source
  • Run pip install -r requirements.txt or pip3 install -r requirements.txt (Need root access)
  • Run python3 install or python install (Need root access)


Easy Install

  • Run easy_install --upgrade penney (Need root access)

Exe Version (Windows)

DMG Version (MacOS)

  • Download DMG-Version 0.3
  • Open DMG file
  • Copy Penney into your system
  • Run Penney

How to Play

  • Open CMD (Windows) or Terminal (UNIX)
  • Run python -m penney or python3 -m penney (or run proper executable version)


Try Penney in Your Browser!

You can play Penney's game online in interactive Jupyter Notebooks via the Binder service! Try it out now! :


  • Open Notebook.ipynb


Changes and improvements are more than welcome! ❤️ Feel free to fork and open a pull request.

Please consider the following :

  1. Fork it!
  2. Create your feature branch (under dev branch)
  3. Add your functions/methods to proper files
  4. Pass all CI tests
  5. Update
    • Describe changes under [Unreleased] section
  6. Submit a pull request into dev (please complete the pull request template)

Issues & bug reports

Just fill an issue and describe it. I'll check it ASAP! or send an email to

  • Please complete the issue template


master dev
Requirements Status Requirements Status


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).


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.


0.3 - 2020-04-16


  • modified
  • Minor issues fixed
  • print_result function tie condition bug fixed

0.2 - 2020-04-08


  • det function
  • prob_calc function
  • print_prob function
  • C_calc function
  • Notebook.ipynb file
  • file
  • Github action


  • modified
  • updated

0.1 - 2020-03-21


  • Player mode
  • Computer mode
  • Exe version
  • Test system

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for penney, version 0.3
Filename, size File type Python version Upload date Hashes
Filename, size penney-0.3-py2.py3-none-any.whl (10.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size penney-0.3.tar.gz (25.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page