Skip to main content

qrs

version status downloads

qrs (kyu-arr-ess) is a tool for Quarrel and other word games. It provides word game-related tools that can be configured with custom settings, letter scores, and wordlists. qrs can solve anagrams and find the best words to play based on your letters.

  • 🐍 Supports Python 3.8 and above. Platform-non-constrained.
  • ⭐ Show your support by leaving a star!

Contents


The qrs library

Install the qrs library to use its functionality in your projects.

python -m pip install --upgrade qrs

Here's an example of using qrs in the REPL:

Click to expand
>>> import json
>>> from qrs import Ruleset
>>>
>>> rs = Ruleset(max=8)  # load 2-to-8-letter words
>>> query = 'wetodlnm'  # query to solve
>>>
>>> solved = rs.solve_query(query)  # solve the query
>>>
>>> if solved.anagram_found:  # check if any anagrams were found; prevents IndexError on next line
...     print(solved.scores[len(query)].words)  # print anagrams as set[str]
{'MELTDOWN'}
>>> print(json.dumps(solved.to_dict(), indent=4))  # full output
{
    "query": "delmnotw",
    "anagram_found": true,
    "scores": {
        "8": {
            "score": 18,
            "words": [
                "MELTDOWN"
            ]
        },
        "5": {
            "score": 14,
            "words": [
                "MOWED"
            ]
        },
        "4": {
            "score": 12,
            "words": [
                "MEWL"
            ]
        },
        "3": {
            "score": 10,
            "words": [
                "MEW",
                "MOW",
                "WEM"
            ]
        },
        "2": {
            "score": 6,
            "words": [
                "OW",
                "WE",
                "EW",
                "WO"
            ]
        }
    }
}
>>> _


Direct execution

$ qrs

qrs: _

Upon being called from the command line, it will display an input screen.

Enter your letters and wait for the program to calculate the best words. Choose one from the list that corresponds with the number of letters you have available, or the next longest. See the example below to find out why you might not need to use all of your spaces.


Example case

Here's an example using the default program settings. Our situation is the following:

  • We're playing Quarrel, so we get eight letters.
  • Our letters are wetodlnm.
  • We have seven spaces to use.

After installing the library, we'll open a command line and run the program.

The program will have to load a wordlist, which takes longer as the range of word lengths increases. Since we know we don't need words longer than eight letters, we can minimise loading time by configuring the program to only calculate for words of that length. We can do this by passing our desired settings as command arguments:

$ qrs --max 8

qrs: _

Once it finishes loading, we can enter our letters.

qrs: wetodlnm

        --- query: delmnotw (8 letters) ---

        8 letters - 18 points
         MELTDOWN

        5 letters - 14 points
         MOWED

        4 letters - 12 points
         MEWL

        3 letters - 10 points
         MEW, MOW, WEM

        2 letters - 6 points
         EW, OW, WE, WO

qrs: _

This output tells us that the anagram is MELTDOWN, but we can't make that word because we can only use seven letters. In this case, our best word is MOWED (14 points). Based on this output, we also know that our opponent cannot score higher than us without all eight spaces.


Settings

Upon being run from the command line, the program will automatically generate (or look for) a qrs.json file in the directory from which the command is run. This file contains the program's settings, which can be changed to suit your needs.

When using qrs as a library, pass any of the following args to a Ruleset to create a new instance. Here are all the currently supported settings:

Setting Shortcut Default Description
🐛 debug -d false Prints the program's inner workings while calculating. Note that many consecutive print statements may negatively affect performance on certain devices or IDEs.
🔀 doubles -b false Shows longer words that tie for score (like the MOWED / LETDOWN example above).
⛔ exclude -e [] List of words that the program will never output.
🎮 game -g "quarrel" Determines the letter scoring system used for calculating points. The value here is passed into build_letter_scores(), and defaults back if invalid.
✔️ include -i [] List of additional words for the wordlist.
💻 lower -l false Displays output in lowercase letters. The default setting displays uppercase letters (in the style of word games like Quarrel and Scrabble), however some people may find lowercase output more readable. Note that this only affects output; all internal operations are performed in lowercase (wordlist and query storage, etc).
🔼 max -m 28 * Determines the maximum word length the program will calculate for.
🔽 min -n 2 Determines the minimum word length the program will calculate for.
💯 noscores -s false Displays all words, not just those with the highest scores. This will sort by word length.
🔁 repeats -r false Determines whether letters can be used more than once. Change this according to your word game's rules; for example, Scrabble tiles can only be used once in a word, whereas New York Times Spelling Bee allows the reuse of letters.

When running directly:

  • To change your settings, do one of the following:
    • Open qrs.json in a text editor and change any values. Make sure to save the file.
    • Pass the setting as a command argument like this: --setting value
      • If applicable, this will automatically update the settings file.
$ qrs --lower --max 8 --debug

  # debug info displayed here (because of --debug flag)

qrs: _
  • If qrs.json is not in your folder, try running the program and letting it fully load. It should then create the file.
  • After saving qrs.json, the program will not change if it's already running. Close the program and rerun it to use the changed settings.

© 2023-2024 silvncr

MIT License

Metadata

Release files for qrs 3.0.0

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

Source distribution (sdist)

Source distribution for qrs 3.0.0
File Size Uploaded
qrs-3.0.0.tar.gz 755.6 kB Details

Built distribution (wheel)

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

Total release size: 1.5 MB

Release files / qrs-3.0.0.tar.gz

Download URL qrs-3.0.0.tar.gz
Size 755.6 kB
Tags Source
SHA-256 checksum
How to use checksums
714194b819a7c8ee1d40b8dcd3c68f14e8cc75cd870183755687d02e0e2618db
BLAKE2b-256 checksum
How to use checksums
fb1ae90baa3f37cce2fab0cbd93729c0031eca29b944ded0f1d33ecabd13e7b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release files / qrs-3.0.0-py3-none-any.whl

Download URL qrs-3.0.0-py3-none-any.whl
Size 750.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d6ca987507b0cbcfaff03c1f806fbc712823494a274933e4eaad79490cee4b6
BLAKE2b-256 checksum
How to use checksums
4af75ea7f4cd581d06c69ad81f2ebeb2588019ed17de32dcb2bb5f374f22891b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release history Release notifications | RSS feed

This release

3.0.0 This release

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