Created
December 29, 2023 22:43
-
-
Save woctezuma/99142be562174fce902357c68bcd3dcf to your computer and use it in GitHub Desktop.
Find Steam games whose names fullfil a few constraints
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import pathlib | |
import re | |
WORD_LENGTH = 4 | |
START_FIRST_WORD = "a" | |
START_LAST_WORD = "i" | |
WORD_LENGTH = 2 | |
START_FIRST_WORD = "e" | |
START_LAST_WORD = "a" | |
WORD_LENGTH = 4 | |
START_FIRST_WORD = "2" | |
START_LAST_WORD = "d" | |
def main() -> None: | |
# Reference: https://steamapi.xpaw.me/#ISteamApps/GetAppList | |
# Alternatively, use https://steamapi.xpaw.me/#IStoreService/GetAppList | |
with pathlib.Path("api.steampowered.com.json").open(encoding="utf8") as f: | |
data = [e["name"] for e in json.load(f)["applist"]["apps"]] | |
output = [] | |
for s in sorted(set(data)): | |
# Reference: https://stackoverflow.com/a/55902074/376454 | |
e = re.sub(r"[^A-Za-z0-9 ]+", "", s) | |
f = e.lower().split() | |
if ( | |
len(f) == WORD_LENGTH | |
and f[0].startswith(START_FIRST_WORD) | |
and f[-1].startswith(START_LAST_WORD) | |
): | |
output.append(e) | |
print("\n".join(output)) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment