Skip to main content

42-Points-Game

42Points Maintainability codecov PyPI PyPI - Python Version PyPI - License

Python implementation of the fourty-two points game.

Introduction

"42 Points" game is a variation based on the popular and long-lived "24 Points" game. The player should only use addition, subtraction, multiplication, division and parentheses and five integers between 0 and 13 (inclusive) to get 42. It's really simple to understand, as the core of the game still relies on math calculations.

Design Logic

This package is designed to work as a core processing part, providing:

  • Problem database
  • Problem generation (by user / in database)
  • Start / stop the game
  • Timer for solutions
  • Player statistics
  • Equivalent solution detection
  • A bunch of APIs and exceptions

This package is not designed to fully implement everything with the game, so the formatting parts should be written by end-users. But don't worry, the API in this package is enough to create whatever you need.

Usage

As equivalent detection is not a easy issue, we will make several changes to make sure it satisfies our need in the following upgrades. Please just kindly use the latest version.

It's recommended to use pip:

    pip install --upgrade 42Points

But building with setup.py will also work, as no other third-party dependencies are required for this package.

After you have installed the package, you are almost done. If you want to try it out quickly, just open your IDLE (or something like that) and type:

    from ftptsgame import FTPtsGame
    app = FTPtsGame() # initialize
    app.generate_problem(problem=[1, 2, 3, 4, 5]) # generate a problem beforehand
    app.start() # start the game
    app.get_current_problem() # show the problem
    app.solve('2 * 4 * 5 + 3 - 1') # put forward a valid solution
    app.get_current_solutions() # show all solutions
    app.get_remaining_solutions() # show remaining solutions
    app.stop() # stop the game

Well, you can integrate this package into your projects by using just the same way, and you can format problems in all the ways you like.

Exceptions

  • PermissionError: Raised during a status check, some methods must be used in the game, while other can't be used.
  • TypeError: Raised when the problem type is not defined.
  • ValueError: Raised when the parameter of generating a problem is invalid, or a user inputs unmatched numbers.
  • OverflowError: Raised when a user input a too long expression. (greater than or equal to 30 characters after beautifying)
  • SyntaxError: Raised when a user input an expression which can't be parsed.
  • ArithmeticError: Raised when a user inputs a wrong answer.
  • LookupError: Raised when a user inputs an equivalent answer.
  • Other exceptions will be raised when an input fails built-in parameter checks.

License

This package is licensed under the MIT License.

Contribution

Pull requests and issues are warmly welcomed.

Metadata

Release files for 42Points 1.2.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for 42Points 1.2.7
File Size Uploaded
42Points-1.2.7.tar.gz 7.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for 42Points 1.2.7
File Interpreter ABI Platform
42Points-1.2.7-py3-none-any.whl Python 3 none any Details

Total release size: 42.6 kB

Release files / 42Points-1.2.7.tar.gz

Download URL 42Points-1.2.7.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7c238f90ea0d4d37bc3af75a403148a3cfbd9b0bff0079b7ad1793cb102e2d76
BLAKE2b-256 checksum
How to use checksums
4566e94118360e5ca75bda9fcf7d6797fb159cd59d6abd12539311ebb9fdc560
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.7.9

Release files / 42Points-1.2.7-py3-none-any.whl

Download URL 42Points-1.2.7-py3-none-any.whl
Size 34.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e802d81b61da6bbf3a0eff28a0c6bfef83db9b5ab8a2c9b1f84dd9819da73c32
BLAKE2b-256 checksum
How to use checksums
61c8abf6b74bb8d72291625d6673ff661b6d9ae66c8ee2fd60dc9928801942aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.7.9

Release history Release notifications | RSS feed

This release

1.2.7 This release

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page